#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd_(ll a,ll b){if(a%b==0)return b;return gcd_(b,a%b);}
ll lcm_(ll a,ll b){ll c=gcd_(a,b);return ((a/c)*b);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}
#define num_l(a,v) POSL(a,v) //v未満の要素数
#define num_eql(a,v) POSU(a,v) //v以下の要素数
#define num_h(a,v) (a.size() - POSU(a,v)) //vより大きい要素数
#define num_eqh(a,v) (a.size() - POSL(a,v)) //v以上の要素数
// static_cast< long long ll >

//chrono::system_clock::time_point start, end;
clock_t start;

bool did[50*52];
int tile[51][51];
int point[51][51];
int N = 50;
int si,sj;

string now = "";
int len = 0;
string ans="";

int score = 0;
int best_s = 0;

string D = "DURL";
int di[] = {1,-1,0,0};
int dj[] = {0,0,1,-1};

string D2 = "RLDU";
int di2[] = {0,0,1,-1};
int dj2[] = {1,-1,0,0};

string D3 = "DRUL";
int di3[] = {1,0,-1,0};
int dj3[] = {0,1,0,-1};


void calc(int i,int j,char &x){
  if(i<0 || j<0 || i>=50 || j>=50)return;
  if(did[ tile[i][j] ])return;
  clock_t end = clock();
  double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
  if(time >= 700)return;


  now[len] = x;
  len++;
  did[ tile[i][j] ] = true;
  score += point[i][j];

  if(score > best_s){
    best_s = score;
    ans = now.substr(0,len);
  }


  FOR(k,0,4){
    calc(i+di[k],j+dj[k],D[k]);
  }


  len--;
  did[ tile[i][j] ] = false;
  score -= point[i][j];
}


void calc2(int i,int j,char &x){
  if(i<0 || j<0 || i>=50 || j>=50)return;
  if(did[ tile[i][j] ])return;
  clock_t end = clock();
  double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
  if(time >= 1330)return;


  now[len] = x;
  len++;
  did[ tile[i][j] ] = true;
  score += point[i][j];

  if(score > best_s){
    best_s = score;
    ans = now.substr(0,len);
  }


  FOR(k,0,4){
    calc2(i+di2[k],j+dj2[k],D2[k]);
  }


  len--;
  did[ tile[i][j] ] = false;
  score -= point[i][j];
}

void calc3(int i,int j,char &x){
  if(i<0 || j<0 || i>=50 || j>=50)return;
  if(did[ tile[i][j] ])return;
  clock_t end = clock();
  double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
  if(time >= 1950)return;

  now[len] = x;
  len++;
  did[ tile[i][j] ] = true;
  score += point[i][j];

  if(score > best_s){
    best_s = score;
    ans = now.substr(0,len);
  }
  FOR(k,0,4){
    calc3(i+di3[k],j+dj3[k],D3[k]);
  }
  len--;
  did[ tile[i][j] ] = false;
  score -= point[i][j];
}

int main(){
  FOR(i,0,N*N) now += 'D';

  mt19937_64 mt(1);
  uniform_real_distribution<double> rnd(0.00,1.00);
  
  cin >> si >> sj;
  FOR(i,0,N)FOR(j,0,N){
    cin >> tile[i][j];
  }
  FOR(i,0,N)FOR(j,0,N){
    cin >> point[i][j];
  }

  start = clock();

  char a = 'U';
  calc(si,sj,a);
  calc2(si,sj,a);
  calc3(si,sj,a);

  if(ans.size() == 0) ans = "U";
  cout << ans.substr(1,ans.size()-1) << endl;

}


#include <iostream>
#include <iterator>
#include <list>
#include <cmath>

constexpr int GRID_SIZE = 50;

struct Pos{
    int i;
    int j;
};

enum MOVE
{
    Up,
    Left,
    Dwon,
    Right,
    LAST
};

char move_char(MOVE move){
    if (move == Up)
    {
        return 'U';
    }
    else if (move == Dwon)
    {
        return 'D';
    }
    else if (move == Right)
    {
        return 'R';
    }
    else if (move == Left)
    {
        return 'L';
    }
    return 'O';
}

struct ListItem
{
    Pos pos;
    int label;
    MOVE move;
};

bool legal(
    Pos pos,
    int pos_label,
    int grid_label[GRID_SIZE][GRID_SIZE],
    std::list<ListItem> lst,
    MOVE move)
{
    if(move == Dwon){
        pos.i += 1;
        if (GRID_SIZE <= pos.i)
            return true;
    }else if(move == Up){
        pos.i -= 1;
        if(pos.i<0)
            return true;
    }else if(move == Right){
        pos.j += 1;
        if (GRID_SIZE <= pos.j)
            return true;
    }else if(move == Left){
        pos.j -= 1;
        if (pos.j < 0)
            return true;
    }

    int label = grid_label[pos.i][pos.j];
    if(label == pos_label){
        return true;
    }
    for (auto itr = lst.rbegin(); itr != lst.rend(); itr++){
        if ((*itr).label == label)
            return true;
    }
    return false;
}

int main()
{
    Pos start;
    int grid_label[GRID_SIZE][GRID_SIZE];
    int grid_score[GRID_SIZE][GRID_SIZE];

    std::cin >> start.i >> start.j;
    for (int x = 0; x < GRID_SIZE; x++)
    {
        for (int y = 0; y < GRID_SIZE; y++)
        {
            std::cin >> grid_label[x][y];
        }
    }
    for (int x = 0; x < GRID_SIZE; x++)
    {
        for (int y = 0; y < GRID_SIZE; y++)
        {
            std::cin >> grid_score[x][y];
        }
    }
    
    std::list<ListItem> lst;
    Pos pos = start;
    MOVE search_order[4] = {Up,Left,Dwon,Right};
    int di = pos.i - GRID_SIZE / 2, dj = pos.j - GRID_SIZE / 2;
    int i_bias, j_bias;
    if(std::abs(di) > std::abs(dj)){
        i_bias = 0;
        j_bias = 1;
    }else{
        i_bias = 1;
        j_bias = 0;
    }

    search_order[i_bias + (0 < di ? 0 : 2)] = Up;
    search_order[i_bias + (0 < di ? 2 : 0)] = Dwon;
    search_order[j_bias + (0 < dj ? 0 : 2)] = Right;
    search_order[j_bias + (0 < dj ? 2 : 0)] = Left;

    while(true)
    {
        int pos_label = grid_label[pos.i][pos.j];
        MOVE illegal_move = LAST;
        for (int move_index = 0; move_index < 4; move_index++)
        {
            MOVE move = search_order[move_index];
            if(!legal(pos, pos_label, grid_label, lst, move)){
                illegal_move = move;
                break;
            }
        }
        
        if(illegal_move == LAST){
            for (auto itr = lst.begin(); itr != lst.end(); itr++)
            {
                MOVE move = (*itr).move;
                std::cout << move_char(move);
            }
            std::cout << std::endl;
            break;
        }else{
            lst.push_back({pos, pos_label, illegal_move});
            if (illegal_move == Dwon)
            {
                pos.i += 1;
            }
            else if (illegal_move == Up)
            {
                pos.i -= 1;
            }
            else if (illegal_move == Right)
            {
                pos.j += 1;
            }
            else if (illegal_move == Left)
            {
                pos.j -= 1;
            }
        }
    }
    return 0;
}