#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const double TIME_LIMIT = 1.8;
const int N = 50;
double PROB_REAL = 0.1;

vector<int> di = {1, -1, 0, 0};
vector<int> dj = {0, 0, 1, -1};
vector<char> vc = {'D', 'U', 'R', 'L'};

map<char, pair<int, int>> mp;

int si0, sj0, si1, sj1;
vector<vector<ll>> t, p;
ld final_score;

//状態
struct STATE {
	// 既に訪れたかどうか
	vector<vector<int>> visited = vector<vector<int>>(N, vector<int>(N, 0));

	// タイルの番号とそれに対応する点のベクター(要素は1か2)
	map<int, vector<pair<int, int>>> mp_tile;

	// 道のり
	deque<char> paths;
};

// 状態の初期化
void init (STATE& state) {
	cin >> si0 >> sj0;
	t = vector<vector<ll>>(N, vector<ll>(N));
	p = vector<vector<ll>>(N, vector<ll>(N));
	for (int i=0;i<N;i++) {
		for (int j=0;j<N;j++) {
			cin >> t[i][j];
			state.mp_tile[t[i][j]].push_back(make_pair(i, j));
		}
	}
	for (int i=0;i<N;i++) {
		for (int j=0;j<N;j++) {
			cin >> p[i][j];
		}
	}
	for (int i=0;i<4;i++) {
		mp[vc[i]] = make_pair(di[i], dj[i]);
	}

	int now_i = si0;
	int now_j = sj0;
	for (auto p : state.mp_tile[t[now_i][now_j]]) {
		state.visited[p.first][p.second] = 1;
	}

    double start_time = static_cast<double>(clock())/CLOCKS_PER_SEC; // 開始時刻
    while (true) { // 時間の許す限り回す
        double now_time = static_cast<double>(clock())/CLOCKS_PER_SEC; // 現在時刻
        double time_diff = now_time-start_time;
        if (time_diff > TIME_LIMIT) break;

		bool changed = false;
		int c = uniform_int_distribution<int>(0, 3)(rng);
		int next_i = now_i+di[c];
		int next_j = now_j+dj[c];
		if (0 <= next_i && next_i < N && 0 <= next_j && next_j < N) {
			if (state.visited[next_i][next_j] == 0) {
				changed = true;
				state.paths.push_back(vc[c]);
				for (auto p : state.mp_tile[t[next_i][next_j]]) {
					state.visited[p.first][p.second] = 1;
				}
				now_i = next_i;
				now_j = next_j;
			}
		}

		if (!changed) {
        	double rand_real = uniform_real_distribution<double>(0.0, 1.0)(rng);
			if (!state.paths.empty() && rand_real < PROB_REAL) {
				char rem_c = state.paths.back();
				state.paths.pop_back();
				for (auto p : state.mp_tile[t[now_i][now_j]]) {
					state.visited[p.first][p.second] = 0;
				}
				now_i -= mp[rem_c].first;
				now_j -= mp[rem_c].second;
			}
		}
	}
}

// 状態遷移
void modify (STATE& state) {
}

// 状態のスコア計算
ld calc_score (STATE& state) {
}

// 山登り法
void mountain() {
    STATE state;
    init(state);

	while (!state.paths.empty()) {
		cout << state.paths.front();
		state.paths.pop_front();
	}
	cout << "\n";
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	mountain();
	return 0;
}
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
using ll=int;
using ld=long double;
using pll=pair<ll, ll>;
//using mint = modint1000000007;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
#define PI acos(-1)
#define oo 2e18
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
//priority_queue<ll, vector<ll>, greater<ll>> Q;
/*
01234でタイルの方向管理？
*/
#define TIMEOVER_M 25000
#define TIMEOVER 1950000

ll T[50][50];
bool B[50][50];
ll P[50][50];
ll D[50][50];
char *ans;
char *W;
ll score=0;
ll high=0;
ll dx[]={0, 1, 0, -1};
ll dy[]={-1, 0, 1, 0};
char dc[]={'U', 'R', 'D', 'L'};
bool all_fin;
bool fin;
clock_t start;
clock_t start_m;
ll loop;

void steped(ll y, ll x, bool b){
  ll d=D[y][x];
  if (d){
    --d;
    ll ny=y+dy[d];
    ll nx=x+dx[d];
    B[ny][nx]=b;
  }
  B[y][x] = b;
}

// 行き止まりになったら、その時点でのstringを出力
void dfs(ll y, ll x, ll c){// {y, x, 歩数}
  bool used[4]={};
  rep(i, 4){
    clock_t now = clock();
    if(now-start_m>TIMEOVER_M) fin=true;
    if(now-start>TIMEOVER) all_fin=true;
    ll r=now%4;
    while(used[r]) (r+=1)%=4;
    used[r]=true;
    ll ny=y+dy[r];
    ll nx=x+dx[r];
//    cout << "time:" << now-start << endl;
    if(ny<0 || nx<0 || ny>49 || nx>49 || B[ny][nx] || fin || all_fin){
      if(chmax(high, score)){
        if(ans) free(ans);
        ans=strdup(W);
      }
    }
    else{
      //反映
      score+=P[ny][nx];
      W[c]=dc[r];
      steped(ny, nx, true);

      dfs(ny, nx, c+1);
      //復元
      score-=P[ny][nx];
      W[c]='\0';
      steped(ny, nx, false);
    }
  }
    
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(10);
  W=(char*)calloc(2000, 1);
  start = clock();
  ll si, sj;
  cin >> si >> sj;
  rep(i, 50) rep(j, 50) cin >> T[i][j];
  rep(i, 50) rep(j, 50) cin >> P[i][j];
  // タイルの方向D
  rep(i, 50) rep(j, 50){
    rep(k, 4){
      ll ny=i+dy[k];
      ll nx=j+dx[k];
      if(ny<0 || nx<0 || ny>49 || nx>49) continue;
      if(T[i][j]==T[ny][nx]) D[i][j]=k+1;
    }
  }
  while(!all_fin){
    loop++;
    fin=false;
    start_m = clock();
    score = P[si][sj];
    chmax(high, score);
    rep(y, 50) rep(x, 50) B[y][x]=false;
    rep(i, 2000) W[i]='\0';
    steped(si, sj, true);
    dfs(si, sj, 0);
  }
//  cout << high << " " << loop << endl;
  printf("%s\n", ans);
}
