#include using namespace std; constexpr int K = 1000; constexpr std::array DX = {1, -1, 0, 0}; constexpr std::array DY = {0, 0, 1, -1}; constexpr std::array DC = {'R', 'L', 'D', 'U'}; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int H, W, p; cin >> H >> W >> p; vector> B(H, vector(W - 1, 1)); vector> C(H - 1, vector(W, 1)); double T = pow(static_cast(p) / 100, 3); vector>> P(H, vector>(W, nullopt)); for (int k = 0; k < K; k++) { for (auto&& e : P) { fill(e.begin(), e.end(), nullopt); } queue> que; que.emplace(0, 0); while (!que.empty()) { const auto [y, x] = que.front(); que.pop(); for (int i = 0; i < 4; i++) { const int ny = y + DY[i]; const int nx = x + DX[i]; if (ny < 0 || ny >= H || nx < 0 || nx >= W) continue; if (i <= 1 && B[ny][min(x, nx)] <= T) continue; if (2 <= i && C[min(y, ny)][nx] <= T) continue; if (P[ny][nx]) continue; P[ny][nx] = DC[i]; que.emplace(ny, nx); } } bool is_ok = true; string res = ""; int y = H - 1, x = W - 1; while (y != 0 || x != 0) { if (!P[y][x].has_value()) { is_ok = false; break; } res += P[y][x].value(); for (int i = 0; i < 4; i++) { if (DC[i] == P[y][x].value()) { y -= DY[i]; x -= DX[i]; break; } } } if (is_ok) reverse(res.begin(), res.end()); if (!is_ok) { for (auto&& e : B) { fill(e.begin(), e.end(), 0); } for (auto&& e : C) { fill(e.begin(), e.end(), 0); } k--; continue; } cout << res << endl; int r; cin >> r; if (r == -1) break; y = 0, x = 0; for (int i = 0; i <= r; i++) { int py = y, px = x, d = 0; for (int j = 0; j < 4; j++) { if (DC[j] == res[i]) { d = j; y += DY[j]; x += DX[j]; if (i < r && j < 2) { B[y][min(x, px)] = 100; } else if (i < r && j >= 2) { C[min(y, py)][x] = 100; } break; } } if (i == r) { if (d < 2) { if (B[y][min(x, px)] <= 1.0) B[y][min(x, px)] *= static_cast(p) / 100; } else { if (C[min(y, py)][x] <= 1.0) C[min(y, py)][x] *= static_cast(p) / 100; } } } } return 0; }