#include //#include using namespace std; //using namespace atcoder; //using mint = modint1000000007; //const int mod = 1000000007; //using mint = modint998244353; //const int mod = 998244353; const int INF = 1e9; //const long long LINF = 1e18; #define rep(i, n) for (int i = 0; i < (n); ++i) #define rep2(i,l,r)for(int i=(l);i<(r);++i) #define rrep(i, n) for (int i = (n-1); i >= 0; --i) #define rrep2(i,l,r)for(int i=(r-1);i>=(l);--i) #define all(x) (x).begin(),(x).end() #define allR(x) (x).rbegin(),(x).rend() #define endl "\n" #define P pair template inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; } template inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; } const int dx[] = { 1,0,-1,0 }; const int dy[] = { 0,-1,0,1 }; char cr[] = { 'U','R','D','L' }; char cr2[] = { 'D','L','U','R' }; string f(string s, int l, int r) { rep(i, s.size()) { if (l - 1 <= i && i < r) { if ('U' == s[i])s[i] = 'D'; else if ('D' == s[i])s[i] = 'U'; else if ('R' == s[i])s[i] = 'L'; else if ('L' == s[i])s[i] = 'R'; } } return s; } void check(bool mode = true) { int h, w, k, l, r; cin >> h >> w >> k >> l >> r; vectors(h); rep(i, h)cin >> s[i]; string str; cin >> str; str = f(str, l, r); cout << str << endl; int x = 0, y = 0; rep(i, str.size()) { if ('U' == str[i])x--; if ('D' == str[i])x++; if ('R' == str[i])y++; if ('L' == str[i])y--; if (s[x][y] == '#') { cout << "!!" << endl; return; } } cout << "ok" << endl; } int main() { //check(); //return 0; ios::sync_with_stdio(false); cin.tie(nullptr); int h, w, k, l, r; cin >> h >> w >> k >> l >> r; vectors(h); rep(i, h)cin >> s[i]; if (0 == (r - l) % 2) { cout << "No" << endl; return 0; } vector> dp(h, vector(w, INF)); vector> dpR(h, vector(w, INF)); rep(_, 2) { queue> q; if (0 == _) { q.emplace(0, 0); dp[0][0] = 0; } else { q.emplace(h - 1, w - 1); dp[h - 1][w - 1] = 0; } while (!q.empty()) { int x = q.front().first; int y = q.front().second; q.pop(); rep(i, 4) { int nx = x + dx[i]; int ny = y + dy[i]; if ((0 <= nx) && (h > nx) && (0 <= ny) && (w > ny) && ('#' != s[nx][ny])) { if (chmin(dp[nx][ny], dp[x][y] + 1)) q.emplace(nx, ny); } } } swap(dp, dpR); } if (0 != abs(dp[h - 1][w - 1] - k) % 2) { cout << "No" << endl; return 0; } auto f = [&](int x, int y)->string { string ret; while (0 != dp[x][y]) { rep(i, 4) { int nx = x + dx[i]; int ny = y + dy[i]; if (nx < 0)continue; if (ny < 0)continue; if (nx >= h)continue; if (ny >= w)continue; char c = cr[i]; if (dp[nx][ny] + 1 == dp[x][y]) { x = nx; y = ny; ret += c; break; } } } return ret; }; rep(i, h)rep(j, w) { if (INF == dp[i][j])continue; int he = dp[i][j]; int ta = dpR[i][j]; int bo = k - he - ta; if (he >= l)continue; if (bo < 0)continue; if (he + bo < r)continue; if (0 != (r - he) % 2)continue; if ((0 != j) && ('.' == s[i][j - 1]) && (w != j + 1) && ('.' == s[i][j + 1])) { string ans0 = f(i, j); reverse(all(ans0)); swap(dp, dpR); swap(cr, cr2); string ans1; rep(i, bo / 2)ans1 += "LR"; string ans2 = f(i, j); cout << "Yes" << endl; string ans = ans0 + ans1 + ans2; cout << ans << endl; return 0; } if ((0 != i) && ('.' == s[i - 1][j]) && (h != (i + 1)) && ('.' == s[i + 1][j])) { string ans0 = f(i, j); reverse(all(ans0)); swap(dp, dpR); swap(cr, cr2); string ans1; rep(i, bo / 2)ans1 += "DU"; string ans2 = f(i, j); cout << "Yes" << endl; string ans = ans0 + ans1 + ans2; cout << ans << endl; return 0; } } cout << "No" << endl; return 0; }