#include <bits/stdc++.h>
using namespace std;

bool check(int row, int col, vector<vector<int>> &maze, int n, vector<vector<int>> &visited) {
    return (row >= 0 && col >= 0 && row < n && col < n &&
            maze[row][col] == 1 && !visited[row][col]);
}

void ratinmaze(int row, int col, vector<vector<int>> &maze, int n,
               vector<vector<int>> &visited, vector<string> &paths, string path) {
    if (row == n - 1 && col == n - 1) {
        paths.push_back(path);
        return;
    }

    visited[row][col] = true;

    if (check(row + 1, col, maze, n, visited))
        ratinmaze(row + 1, col, maze, n, visited, paths, path + 'D');

    if (check(row - 1, col, maze, n, visited))
        ratinmaze(row - 1, col, maze, n, visited, paths, path + 'U');

    if (check(row, col + 1, maze, n, visited))
        ratinmaze(row, col + 1, maze, n, visited, paths, path + 'R');

    if (check(row, col - 1, maze, n, visited))
        ratinmaze(row, col - 1, maze, n, visited, paths, path + 'L');

    visited[row][col] = false;
}

int main() {
    int n;
    cin >> n;
    vector<vector<int>> maze(n, vector<int>(n));
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            cin >> maze[i][j];

    vector<vector<int>> visited(n, vector<int>(n, false));
    vector<string> paths;

    if (maze[0][0] == 1)
        ratinmaze(0, 0, maze, n, visited, paths, "");

    for (string path : paths)
        cout << path << " ";

    if (paths.empty())
        cout << "-1"; // No path found
}