#include<bits/stdc++.h>
using namespace std;
class ExplodingRobots
{
public :
string canExplode( int x1, int y1, int x2, int y2, string a)
{
int u= 0 ,r= 0 ,d= 0 ,l= 0 ,i,len= a.length ( ) ;
for ( i= 0 ; i< len; i++ )
{
if ( a[ i] == 'U' ) u++ ;
else if ( a[ i] == 'L' ) l++ ;
else if ( a[ i] == 'D' ) d++ ;
else r++ ;
}
if ( x2> x1)
{
if ( x2- l> x1+ r) return "Safe" ;
if ( y2> y1)
{
if ( y2- d> y1+ u) return "Safe" ;
return "Explosion" ;
}
else
{
if ( y2+ u< y1- d) return "Safe" ;
return "Explosion" ;
}
}
else
{
if ( x1- l> x2+ r) return "Safe" ;
if ( y2> y1)
{
if ( y2- d> y1+ u) return "Safe" ;
return "Explosion" ;
}
else
{
if ( y2+ u< y1- d) return "Safe" ;
return "Explosion" ;
}
}
}
} ;
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKY2xhc3MgRXhwbG9kaW5nUm9ib3RzCnsKcHVibGljOgogICAgc3RyaW5nIGNhbkV4cGxvZGUoaW50IHgxLCBpbnQgeTEsIGludCB4MiwgaW50IHkyLCBzdHJpbmcgYSkKICAgIHsKICAgICAgICBpbnQgdT0wLHI9MCxkPTAsbD0wLGksbGVuPWEubGVuZ3RoKCk7CiAgICAgICAgZm9yKGk9MDtpPGxlbjtpKyspCiAgICAgICAgewogICAgICAgICAgICBpZihhW2ldPT0nVScpIHUrKzsKICAgICAgICAgICAgZWxzZSBpZihhW2ldPT0nTCcpIGwrKzsKICAgICAgICAgICAgZWxzZSBpZihhW2ldPT0nRCcpIGQrKzsKICAgICAgICAgICAgZWxzZSByKys7CiAgICAgICAgfQogICAgICAgIGlmKHgyPngxKQogICAgICAgIHsKICAgICAgICAgICAgaWYoeDItbD54MStyKSByZXR1cm4gIlNhZmUiOwogICAgICAgICAgICBpZih5Mj55MSkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgaWYoeTItZD55MSt1KSByZXR1cm4gIlNhZmUiOwogICAgICAgICAgICAgICAgcmV0dXJuICJFeHBsb3Npb24iOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGVsc2UKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgaWYoeTIrdTx5MS1kKSByZXR1cm4gIlNhZmUiOwogICAgICAgICAgICAgICAgcmV0dXJuICJFeHBsb3Npb24iOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGVsc2UKICAgICAgICB7CiAgICAgICAgICAgIGlmKHgxLWw+eDIrcikgcmV0dXJuICJTYWZlIjsKICAgICAgICAgICAgaWYoeTI+eTEpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGlmKHkyLWQ+eTErdSkgcmV0dXJuICJTYWZlIjsKICAgICAgICAgICAgICAgIHJldHVybiAiRXhwbG9zaW9uIjsKICAgICAgICAgICAgfQogICAgICAgICAgICBlbHNlCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGlmKHkyK3U8eTEtZCkgcmV0dXJuICJTYWZlIjsKICAgICAgICAgICAgICAgIHJldHVybiAiRXhwbG9zaW9uIjsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KfTsK