#include using namespace std; using ll = long long; using pll = pair; #define drep(i, cc, n) for (ll i = (cc); i <= (n); ++i) #define rep(i, n) drep(i, 0, n - 1) #define all(a) (a).begin(), (a).end() #define pb push_back #define fi first #define se second mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count()); const ll MOD1000000007 = 1000000007; const ll MOD998244353 = 998244353; const ll MOD[3] = {999727999, 1070777777, 1000000007}; const ll LINF = 1LL << 60; const int IINF = (1 << 30) - 1; template struct Edge{ int to; T w; Edge(int to_, T w_=1){ to = to_; w=w_; } }; template using Tree = vector>>; template using Graph = vector>>; /* 容量&重み付きエッジ for Dinic */ template struct REdge{ int to; T cap; T cost; int rev; REdge(int to_, T cap_, T cost_=1){ to = to_; cap = cap_; cost = cost_; } REdge(int to_, T cap_, T cost_, int rev_){ to = to_; cap = cap_; cost = cost_; rev = rev_; } }; /* 残余グラフ for Dinic */ template using RGraph = vector>>; int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); int H, W, K, L, R; cin >> H >> W >> K >> L >> R; vector S(H); rep(i, H) cin >> S[i]; if((H+W-2)%2 != K%2){ cout << "No" << endl; return 0; } int di[4] = {0, 0, 1, -1}; int dj[4] = {1, -1, 0, 0}; char ddir[4] = {'R', 'L', 'D', 'U'}; char rdir[4] = {'L', 'R', 'U', 'D'}; map alloc; alloc['R'] = 0; alloc['L'] = 1; alloc['D'] = 2; alloc['U'] = 3; queue Q; vector> sdist(H, vector(W, -1)); vector>> spre(H, vector>(W, {-1, -1})); sdist[0][0] = 0; Q.push({0, 0}); while(!Q.empty()){ int now_i = Q.front().fi; int now_j = Q.front().se; Q.pop(); for(int k=0; k<4; k++){ int nxt_i = now_i + di[k]; int nxt_j = now_j + dj[k]; if(nxt_i<0||nxt_j<0||H<=nxt_i||W<=nxt_j) continue; if(S[nxt_i][nxt_j]=='#') continue; if(sdist[nxt_i][nxt_j]!=-1) continue; sdist[nxt_i][nxt_j] = sdist[now_i][now_j]+1; spre[nxt_i][nxt_j] = {now_i, now_j}; Q.push({nxt_i, nxt_j}); } } vector> tdist(H, vector(W, -1)); vector>> tpost(H, vector>(W, {-1, -1})); tdist[H-1][W-1] = 0; Q.push({H-1, W-1}); while(!Q.empty()){ int now_i = Q.front().fi; int now_j = Q.front().se; Q.pop(); for(int k=0; k<4; k++){ int nxt_i = now_i + di[k]; int nxt_j = now_j + dj[k]; if(nxt_i<0||nxt_j<0||H<=nxt_i||W<=nxt_j) continue; if(S[nxt_i][nxt_j]=='#') continue; if(tdist[nxt_i][nxt_j]!=-1) continue; tdist[nxt_i][nxt_j] = tdist[now_i][now_j]+1; tpost[nxt_i][nxt_j] = {now_i, now_j}; Q.push({nxt_i, nxt_j}); } } function spath = [&](int si, int sj){ string ret = ""; int now_i=si, now_j=sj; while(!(now_i==0&&now_j==0)){ int pre_i = spre[now_i][now_j].fi; int pre_j = spre[now_i][now_j].se; rep(k, 4){ if(pre_i+di[k]==now_i && pre_j+dj[k]==now_j){ ret+=ddir[k]; } } now_i = pre_i; now_j = pre_j; } return ret; }; function tpath = [&](int si, int sj){ string ret = ""; int now_i=si, now_j=sj; while(!(now_i==H-1&&now_j==W-1)){ int post_i = tpost[now_i][now_j].fi; int post_j = tpost[now_i][now_j].se; rep(k, 4){ if(now_i+di[k]==post_i && now_j+dj[k]==post_j){ ret+=ddir[k]; } } now_i = post_i; now_j = post_j; } return ret; }; //L-1回目の行動後の到達頂点 for(int si=0; siL-1) continue; if(S[si][sj]=='#') continue; //横側を確認 if(0<=sj-1 && sj+1