import sys import math from bisect import bisect_right, bisect_left from itertools import * from collections import * from heapq import heapify, heappush, heappop inf = float('inf') # mod = 1000000007 # mod = 998244353 input = lambda: sys.stdin.readline().rstrip() def error(*args, sep=' ', end='\n'): print(*args, sep=sep, end=end, file=sys.stderr) # sys.setrecursionlimit(10**6) import random random.seed = 148 ################## def can_move(x, y, d): if d == 'U': if y and v[y-1][x] == 0: return 1 elif d == 'D': if y < 19 and v[y][x] == 0: return 1 elif d == 'L': if x and h[y][x-1] == 0: return 1 elif d == 'R': if x < 19 and h[y][x] == 0: return 1 return 0 def cannot_move(x, y, d): if d == 'U': if y and v[y-1][x] == 1: return 1 elif d == 'D': if y < 19 and v[y][x] == 1: return 1 elif d == 'L': if x and h[y][x-1] == 1: return 1 elif d == 'R': if x < 19 and h[y][x] == 1: return 1 return 0 def change_yx(y, x, d): if d == 'U': y -= 1 if d == 'D': y += 1 if d == 'L': x -= 1 if d == 'R': x += 1 return (y, x) def wall_nasi(res): dq = deque(res) nowy, nowx = 0, 0 while dq: d = dq.popleft() move(nowx, nowy, d) nowy, nowx = change_yx(nowy, nowx, d) def move(x, y, d): if d == 'U': v[y-1][x] = 0 if d == 'D': v[y][x] = 0 if d == 'L': h[y][x-1] = 0 if d == 'R': h[y][x] = 0 def wall_ari(res): dq = deque(res) nowy, nowx = 0, 0 while dq: d = dq.popleft() if cannot_move(nowx, nowy, d): move1(nowx, nowy, d) break nowy, nowx = change_yx(nowy, nowx, d) def move1(x, y, d): if d == 'U': v[y-1][x] = 1 if d == 'D': v[y][x] = 1 if d == 'L': h[y][x-1] = 1 if d == 'R': h[y][x] = 1 H, W, P = map(int, input().split()) h = [[-1]*20 for _ in range(20)] v = [[-1]*20 for _ in range(20)] DIRECT = ['U', 'D', 'L', 'R'] dx = [0, 0, -1, 1] dy = [1, -1, 0, 0] def bfs(si, sj): dist = [[-1]*20 for _ in range(20)] dq = deque([(si, sj)]) dist[si][sj] = 0 while dq: nowy, nowx = dq.popleft() d = dist[nowy][nowx] + 1 if can_move(nowx, nowy, 'D') and dist[nowy+1][nowx] == -1: dq.append((nowy+1, nowx)) dist[nowy+1][nowx] = d if can_move(nowx, nowy, 'U') and dist[nowy-1][nowx] == -1: dq.append((nowy-1, nowx)) dist[nowy-1][nowx] = d if can_move(nowx, nowy, 'R') and dist[nowy][nowx+1] == -1: dq.append((nowy, nowx+1)) dist[nowy][nowx+1] = d if can_move(nowx, nowy, 'L') and dist[nowy][nowx-1] == -1: dq.append((nowy, nowx-1)) dist[nowy][nowx-1] = d return dist def get_root(dist, nowy, nowx): root = [] while True: d = dist[nowy][nowx] if d == 0: break if nowy+1 < 20 and v[nowy][nowx] == 0 and dist[nowy+1][nowx] == d-1: root.append('U') nowy += 1 elif nowy-1 >= 0 and v[nowy-1][nowx] == 0 and dist[nowy-1][nowx] == d-1: root.append('D') nowy -= 1 elif nowx+1 < 20 and h[nowy][nowx] == 0 and dist[nowy][nowx+1] == d-1: root.append('L') nowx += 1 elif nowx-1 >= 0 and h[nowy][nowx-1] == 0 and dist[nowy][nowx-1] == d-1: root.append('R') nowx -= 1 return list(reversed(root)) breakflag = False ok = [] trynum = 0 seen = set() while trynum < 990: dist = bfs(0, 0) # solve? if dist[19][19] != -1: print(get_root(dist, 19, 19), flush=True) input() break # search indx = [] for i in range(20): for j in range(20): if dist[i][j] != -1: if (i, j) not in seen: indx.append((i, j)) gy, gx = random.choice(indx) seen.add((gy, gx)) ans = get_root(dist, gy, gx) # error(*dist, sep='\n') # error() # error(*h, sep='\n') # error() # error(*v, sep='\n') for i in range(4): res = ans[:] res.append(DIRECT[i]) pred = len(res) print(''.join(res), flush=True) trynum += 1 resnum = int(input()) if resnum == -1: breakflag = True break if pred == resnum: wall_nasi(res) else: wall_ari(res) if breakflag: break