#include using namespace std; #define rep(i,n) for (int i=0;i<(int)(n);i++) #define all(v) v.begin(),v.end() using ll = long long; using pll = pair; template void chmin(T& a, T b) { if (a > b) { a = b; } } template void chmax(T& a, T b) { if (a < b) { a = b; } } int main() { ll h, w, p; cin >> h >> w >> p; srand((unsigned int)time(NULL)); vector addc = { 'L','U','R','D' }; vector> grid(h * w + 1); vector around = { -1,-h,1,w }; for (int i = 1; i <= h * w; i++) { rep(j, 4) { ll p = i + around[j]; if (i % h == 1 && j == 0) continue; if (i <= w && j == 1) continue; if (i % h == 0 && j == 2) continue; if (h * w - w < i && j == 3) continue; grid[i].push_back(p); } } map mp; mp[h] = 'D'; mp[1] = 'R'; mp[-1] = 'L'; mp[-h] = 'U'; map pd; pd['L'] = -1; pd['U'] = -h; pd['R'] = 1; pd['D'] = h; while (true) { vector dist(h * w + 1, -1); queue q; q.push(1); dist[1] = 0; while (!q.empty()) { ll x = q.front(); q.pop(); for (auto& i : grid[x]) { if (i == -1) continue; if (dist[i] == -1) { dist[i] = dist[x] + 1; q.push(i); } } } string root; vector rootv; rootv.push_back(h * w); ll dt = dist[h * w]; if (dt == -1) { cout << 'D' << endl; ll xx; cin >> xx; if (xx == -1) return 0; continue; } ll dtp = h * w; while (dt != 0) { for (auto& i : grid[dtp]) { if (i == -1) continue; if (dt == dist[i] + 1) { root.push_back(mp[dtp - i]); rootv.push_back(i); dt = dist[i]; dtp = i; break; } } } reverse(all(root)); reverse(all(rootv)); cout << root << endl; ll x = 0; cin >> x; if (x == -1) return 0; for (auto& i : grid[rootv[x]]) { if (i == rootv[x] + pd[root[x]]) { i = -1; break; } } if(x+1!=rootv.size()){ for (auto& i : grid[rootv[x+1]]) { if (i == rootv[x]) { i = -1; break; } } } } }