#include using namespace std; using I=int; using C=string; #define L list #define P pair #define B push_back #define G break #define F(V,F) for(I V=0;V>p{};p.B(L

());p.front().B(P(s,t));C d[4]={"U","R","D","L"};I a[4]={-1,0,1,0},b[4]={0,1,0,-1};bool r[60][60]={},f{};P c{};I& i=c.X;I& j=c.Y;LD{};while(!f){L

q{};R(p.back()){F(n,4){i=x->X+a[n];j=x->Y+b[n];if(i==u&&j==v){f=true;}if(0<=i&&i<60&&0<=j&&j<60&&!r[i][j]){C T=S[i].substr(j,1);if(T!="#"&&T!="E"){r[i][j]=true;q.B(c);}}}if(f){G;}}if(!f){p.B(q);}}while(!p.empty()){f=false;R(p.back()){F(n,4){i=x->X+a[n];j=x->Y+b[n];if(i==u&&j==v){D.push_front(n);u=x->X;v=x->Y;p.pop_back();f=true;G;}}if(f){G;}}}R(D){cout<<"M "<