#include<bits/stdc++.h>
using namespace std;
bool check(int row,int col,int n,vector<vector<int>> maze,vector<vector<bool>> visited){
    return(row>=0 && col>=0 && row<n && col<n && maze[row][col]==1 &&  !visited[row][col]);
}
void rat(int row,int col,int n,vector<vector<int>> maze,vector<vector<bool>> 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,n,maze,visited)){
        rat(row+1,col,n,maze,visited,paths,path+"D");
    }
     if(check(row-1,col,n,maze,visited)){
        rat(row-1,col,n,maze,visited,paths,path+"U");
    }
     if(check(row,col+1,n,maze,visited)){
        rat(row,col+1,n,maze,visited,paths,path+"R");
    }
     if(check(row,col-1,n,maze,visited)){
        rat(row,col-1,n,maze,visited,paths,path+"L");
    }
}
int main(){
       int n = 6;
vector<vector<int>> maze = {
    {1, 0, 1, 1, 0, 1},
    {1, 1, 1, 0, 1, 1},
    {0, 1, 0, 1, 0, 0},
    {1, 1, 0, 1, 1, 1},
    {1, 0, 0, 1, 0, 1},
    {1, 1, 1, 1, 1, 1}
};
vector<vector<bool>>visited(n,vector<bool>(n,false));
vector<string> paths;
if(maze[0][0]==1){
    rat(0,0,n,maze,visited,paths,"");
    
}
for( string i : paths){
    cout<<paths[i]<<endl;
}
return 0;
    
}