r""" ______________________ < it's hidehico's code > ---------------------- \ \ .--. |o_o | |:_/ | // \ \ (| | ) /'\_ _/`\ \___)=(___/ """ # ライブラリと関数と便利変数 # ライブラリ import bisect import random import copy import heapq import math import sys from collections import Counter, defaultdict, deque from itertools import accumulate, combinations, permutations from math import gcd, lcm, pi from operator import itemgetter from typing import Any, List, Tuple # from atcoder.segtree import SegTree # from atcoder.lazysegtree import LazySegTree # from atcoder.dsu import DSU # cortedcontainersは使うときだけ wandbox非対応なので # from sortedcontainers import SortedDict, SortedSet, SortedList # import pypyjit # pypyjit.set_param("max_unroll_recursion=-1") sys.setrecursionlimit(5 * 10**5) import io import os import sys from typing import Any, List # インタラクティブ問題の時はIS_INTERACTIVEをTrueにしましょう # IS_INTERACTIVE = False # 標準入力関数 # if sys.argv[0] == "Main.py": # if not IS_INTERACTIVE: # input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline().decode().rstrip def s() -> str: """ 一行に一つのstringをinput """ return input() def sl() -> List[str]: """ 一行に複数のstringをinput """ return s().split() def ii() -> int: """ 一つのint """ return int(s()) def il(add_num: int = 0) -> List[int]: """ 一行に複数のint """ return list(map(lambda i: int(i) + add_num, sl())) def li(n: int, func, *args) -> List[List[Any]]: """ 複数行の入力をサポート """ return [func(*args) for _ in [0] * n] INF = 1 << 63 # コード N, T = il() A = li(N, il) def getscore(L): c = 0 NA = copy.deepcopy(A) t = 0 for i, k in L: c ^= NA[i][k] t += (i + k + 2) * 2 t += 140 for a in range(N): for b in range(N): if i != a or k != b: NA[a][b] = max(NA[a][b], NA[a][b] ^ c) t += 1 if t > T: return -INF return sum([sum(NA[i]) for i in range(N)]) def get_output(L): c = 0 NA = copy.deepcopy(A) res = [] for i, k in L: c ^= NA[i][k] res += ["D"] * i res += ["R"] * k res.append("C") res += ["L"] * k res += ["U"] * i f = False for x in range(N): y = N - 1 if f else 0 while 0 <= y < N: if (x != i or y != k) and NA[x][y] < NA[x][y] ^ c: res.append("W") NA[x][y] ^= c if (f and y != 0) or ((not f) and y != N - 1): res.append("L" if f else "R") y += -1 if f else 1 if x != N - 1: res.append("D") f ^= True res += ["U"] * (N - 1) return res l = [] sc = -INF for i in range(N): for k in range(N): nc = getscore([(i, k)]) if sc < nc: l = [(i, k)] sc = nc for ai in range(N): for ak in range(N): for bi in range(N): for bk in range(N): nc = getscore([(ai, ak), (bi, bk)]) if sc < nc: l = [(ai, ak), (bi, bk)] sc = nc for _ in [0] * 10000: m = random.randrange(3, 7) nl = [] for _ in [0] * m: x, y = random.randrange(N), random.randrange(N) while (x, y) in nl: x, y = random.randrange(N), random.randrange(N) nl += [(x, y)] nc = getscore(nl) if sc < nc: l = nl sc = nc print("\n".join(get_output(l)))