#include using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); // 盤面サイズ N と操作上限 T を読み込む int N, T; cin >> N >> T; // 盤面を読み込む vector> A(N, vector(N)); for(int i = 0; i < N; i++){ for(int j = 0; j < N; j++){ cin >> A[i][j]; } } // 1) 盤面内の最大値を求める uint32_t maxVal = 0; for(int i = 0; i < N; i++){ for(int j = 0; j < N; j++){ maxVal = max(maxVal, A[i][j]); } } // 2) (0,0) からの距離が最小となる最大値セルを選ぶ int im = 0, jm = 0, bestD = INT_MAX; for(int i = 0; i < N; i++){ for(int j = 0; j < N; j++){ if(A[i][j] == maxVal){ int d = i + j; if(d < bestD){ bestD = d; im = i; jm = j; } } } } // 操作リスト vector ops; // 現在位置 int x = 0, y = 0; // (x,y) -> (tx,ty) へ 1ステップの移動を ops に追加 auto move_to = [&](int tx, int ty){ while(x < tx){ ops.push_back('D'); x++; } while(x > tx){ ops.push_back('U'); x--; } while(y < ty){ ops.push_back('R'); y++; } while(y > ty){ ops.push_back('L'); y--; } }; // 3) 最大値セルへ移動して C 操作 move_to(im, jm); ops.push_back('C'); uint32_t s = A[im][jm]; // 4) (0,0) へ戻る move_to(0, 0); // 5) 蛇行走査で全セルを訪問し、XOR 後に大きければ W して A を更新 for(int i = 0; i < N; i++){ if(i % 2 == 0){ for(int j = 0; j < N; j++){ if(i != 0 || j != 0) move_to(i, j); uint32_t v0 = A[i][j], v1 = v0 ^ s; if(v1 > v0){ ops.push_back('W'); A[i][j] = v1; } } } else { for(int j = N - 1; j >= 0; j--){ move_to(i, j); uint32_t v0 = A[i][j], v1 = v0 ^ s; if(v1 > v0){ ops.push_back('W'); A[i][j] = v1; } } } } // 6) 最終位置は (N-1, 0) ← 左下 // ここでコピー操作を一度だけ行う ops.push_back('C'); s ^= A[x][y]; // 7) 左下 から 0,0 へ逆向き蛇行走査しながら更新 for(int i = N - 1; i >= 0; i--){ if(i % 2 == 1){ // 奇数行:左 → 右 for(int j = 1; j < N; j++){ move_to(i, j); uint32_t v0 = A[i][j], v1 = v0 ^ s; if(v1 > v0){ ops.push_back('W'); A[i][j] = v1; } } } else { // 偶数行:右 → 左 for(int j = N - 2; j >= 0; j--){ move_to(i, j); uint32_t v0 = A[i][j], v1 = v0 ^ s; if(v1 > v0){ ops.push_back('W'); A[i][j] = v1; } } } } // 8) 出力 for(char c : ops){ cout << c << "\n"; } return 0; }