#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 DD = "AAAA";
int di_[] = {1,-1,0,0};
int dj_[] = {0,0,1,-1};
 
double t = 82.0;

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 >= t)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],DD[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';
  vector<int> ind(4);
  ind[0] = 0;
  ind[1] = 1;
  ind[2] = 2;
  ind[3] = 3;
  do{
    for(int i=0;i<4;i++){
      DD[i] = D[ind[i]];
      di_[i] = di[ind[i]];
      dj_[i] = dj[ind[i]];
    }
    calc(si,sj,a);
    t += 82.0;
  }while(NEXTP(ind));


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

}


#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int si, sj, ti, tj, t[50][50], p[50][50],
    dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
bool done[2500] = {};
char c[4] = {'R', 'D', 'L', 'U'};
string ans = "";

pair<int, int> next(int d){
    pair<int, int> res = {ti + dx[d % 4], tj + dy[d % 4]};
    return res;
}

bool check(int i, int j, int d){
    int ni = i + dx[d % 4], nj = j + dy[d % 4];
    bool res = (ni >= 0) && (ni < 50) && (nj >= 0) && (nj < 50);
    if(res) res = !done[t[ni][nj]];
    return res;
}

void change(int d){
    ti = ti + dx[d % 4], tj = tj + dy[d % 4];
    done[t[ti][tj]] = true;
    ans.push_back(c[d % 4]);
    return;
}

int nextok(int d){
	if(!check(ti, tj, d)) return -1;
  	auto [ni, nj] = next(d);
  	int res = 0;
  	for(int i = 0; i < 4; i++){
      	int nni = ni + dx[i], nnj = nj + dy[i];
      	if((nni >= 0) && (nni < 50) && (nnj >= 0) && (nnj < 50)){
			if(!done[t[nni][nnj]] && (t[ni][nj] != t[nni][nnj])) res++;
        }
    }
  	return res;
}

int main(){
    scanf("%d %d", &si, &sj);
    ti = si, tj = sj;  
    for(int i = 0; i < 50; i++)
        for(int j = 0; j < 50; j++)
            scanf("%d", &t[i][j]);
    for(int i = 0; i < 50; i++)
        for(int j = 0; j < 50; j++)
            scanf("%d", &p[i][j]);
    done[t[si][sj]] = true;
    int foo[4] = {49 - sj, 49 - si, sj, si};
    int D = (min_element(foo, foo + 4) - foo) + (1<<20);
  	while(true){
		if(!(check(ti, tj, D) || check(ti, tj, D + 1) || check(ti, tj, D + 2) || check(ti, tj, D + 3))) break;
      	int nd = rand() % 4, md = -1;
      	for(int i = nd; i < nd + 4; i++){
			if(md < nextok(i)){
				D = i;
              	md = nextok(i);
            }
        }
      	change(D);
    }
    /*while(true){
        if(!(check(ti, tj, D - 1) || check(ti, tj, D) || check(ti, tj, D + 1))) break;
        if(check(ti, tj, D))change(D);
        else{
            int td = D - 1 + 2 * (rand() & 1);
            if(check(ti, tj, td)) change(td);
            else change(td + 2);
        }      
    }
    D++;
    while(true){
        if(!(check(ti, tj, D) || check(ti, tj, D + 1) || check(ti, tj, D + 2) || check(ti, tj, D + 3))) break;
        for(int d = D - 1; d < D + 3; d++){
            if(check(ti, tj, d)){
                change(d);
                D = d;
                break;
            }
        }
    }*/
    cout << ans << endl;
    return 0;
}