#include using namespace std; using ll =long long; #define all(v) v.begin(),v.end() #define rep(i,a,b) for(int i=a;i=b;i--) ll INF=2e18; vector A={1,0,-1,0}; vector B={0,1,0,-1}; string t="ULDR"; string T="DRUL"; int main() { ios::sync_with_stdio(false); cin.tie(0); ll H,W,K,L,R;cin>>H>>W>>K>>L>>R; vector S(H); for(ll i=0;i>S[i]; if((R-L+1)%2!=0) { cout<<"No"<> d(H,vector (W,INF)); queue> Q; Q.push(make_pair(0,0)); d[0][0]=0; while(!Q.empty()) { auto q=Q.front(); Q.pop(); for(ll i=0;i<4;i++) { ll x=q.first+A[i]; ll y=q.second+B[i]; if(x<0||y<0||x>=H||y>=W) continue; if(S[x][y]=='#') continue; if(d[x][y]==INF) { d[x][y]=d[q.first][q.second]+1; Q.push(make_pair(x,y)); } } } vector> rd(H,vector (W,INF)); rd[H-1][W-1]=0; Q.push(make_pair(H-1,W-1)); while(!Q.empty()) { auto q=Q.front(); Q.pop(); for(ll i=0;i<4;i++) { ll x=q.first+A[i]; ll y=q.second+B[i]; if(x<0||y<0||x>=H||y>=W) continue; if(S[x][y]=='#') continue; if(rd[x][y]==INF) { rd[x][y]=rd[q.first][q.second]+1; Q.push(make_pair(x,y)); } } } for(ll i=0;i0&&j ans(K,'n'); ll now=d[i][j]; pair p=make_pair(i,j); while(now>0) { for(ll h=0;h<4;h++) { ll x=p.first+A[h]; ll y=p.second+B[h]; if(x<0||x>=H||y<0||y>=W) continue; if(d[x][y]==now-1) { now--; p=make_pair(x,y); ans[now]=t[h]; break; } } } now=rd[i][j]; p=make_pair(i,j); while(now>0) { for(ll h=0;h<4;h++) { ll x=p.first+A[h]; ll y=p.second+B[h]; if(x<0||x>=H||y<0||y>=W) continue; if(rd[x][y]==now-1) { now--; p=make_pair(x,y); ans[K-1-now]=T[h]; break; } } } ll count=0; for(ll h=0;h0&&i ans(K,'n'); ll now=d[i][j]; pair p=make_pair(i,j); while(now>0) { for(ll h=0;h<4;h++) { ll x=p.first+A[h]; ll y=p.second+B[h]; if(x<0||x>=H||y<0||y>=W) continue; if(d[x][y]==now-1) { now--; p=make_pair(x,y); ans[now]=t[h]; break; } } } now=rd[i][j]; p=make_pair(i,j); while(now>0) { for(ll h=0;h<4;h++) { ll x=p.first+A[h]; ll y=p.second+B[h]; if(x<0||x>=H||y<0||y>=W) continue; if(rd[x][y]==now-1) { now--; p=make_pair(x,y); ans[K-1-now]=T[h]; break; } } } ll count=0; for(ll h=0;h