#include<bits/stdc++.h>
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define puts(x) cout << (x) << "\n"
using namespace std;
int si, sj, t[60][60], p[60][60], M;
bool b1[50 * 51];
int score(string s) {
	int xs = si, ys = sj, r = p[xs][ys];
	for (char c : s) {
		if (c == 'U')xs--;
		if (c == 'D')xs++;
		if (c == 'L')ys--;
		if (c == 'R')ys++;
		r += p[xs][ys];
	}
	return r;
}
signed main() {
	cin >> si >> sj; si++; sj++; b1[2525] = 1;
	for0(i, 52)for0(j, 52) {
		if (i * j == 0 || i == 51 || j == 51)t[i][j] = 2525;
		else { cin >> t[i][j]; M = max(M, t[i][j]); }
	}
	for1(i, 50)for1(j, 50)cin >> p[i][j];	
	string s1 = ""; int v1 = score(s1), ti = clock();
	while(clock() - ti <= 1800000) {
		string sp = "";
		int xi = si, yi = sj;
		while (1) {
			b1[t[xi][yi]] = 1;
			int tm = b1[t[xi - 1][yi]] + b1[t[xi + 1][yi]] + b1[t[xi][yi - 1]] + b1[t[xi][yi + 1]];
			if (tm == 4)break;
			int ri = rand() % (4 - tm);
			if (b1[t[xi - 1][yi]] == 0) { if (ri == 0) { sp += 'U'; xi--; } ri--; }
			if (b1[t[xi + 1][yi]] == 0) { if (ri == 0) { sp += 'D'; xi++; } ri--; }
			if (b1[t[xi][yi - 1]] == 0) { if (ri == 0) { sp += 'L'; yi--; } ri--; }
			if (b1[t[xi][yi + 1]] == 0) { if (ri == 0) { sp += 'R'; yi++; } ri--; }
		}
		int vi = score(sp);
		if (vi > v1) {
			s1 = sp; v1 = vi;
		}
		for0(i, M)b1[i] = 0;
	}
	puts(s1);
}
#include <bits/stdc++.h>
using namespace std;
template <typename T>
bool chmin(T &a, const T &b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template <typename T>
bool chmax(T &a, const T &b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
const int n = 50;
const int vi[] = {0, 1, 0, -1};
const int vj[] = {1, 0, -1, 0};
chrono::steady_clock::time_point sTime;
char vtoc(int v) {
	string s = "RDLU";
	return s[v];
}
void mainSolve(string &ans, int si, int sj, const vector<vector<int>> &t, const vector<vector<int>> &p) {
	mt19937 mt(04252021);
	uniform_int_distribution<int> rdV(0, 3);
	const int TL = 2 * 1000 - 25;
	auto passTime = [&]() {
		return chrono::duration_cast<chrono::milliseconds>(chrono::steady_clock::now() - sTime).count();
	};
	auto passTimeNow = passTime();
	int bestScore = 0;
	while (passTimeNow < TL) {
		passTimeNow = passTime();
		string tans;
		int ni = si, nj = sj;
		set<int> visit = {t[ni][nj]};
		int score = p[ni][nj];
		for (int tt = 0; tt < 1000; tt++) {
			int v = rdV(mt);
			int ei = ni + vi[v], ej = nj + vj[v];
			if (0 > ej || ej >= n || 0 > ei || ei >= n) continue;
			if (!visit.count(t[ei][ej])) {
				ni = ei, nj = ej;
				score += p[ei][ej];
				tans += vtoc(v);
				visit.insert(t[ei][ej]);
			}
		}
		if (chmax(bestScore, score)) {
			ans = tans;
		}
	}
}
int main() {
	sTime = chrono::steady_clock::now();
	int si, sj;
	cin >> si >> sj;
	vector<vector<int>> t(n, vector<int>(n));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> t[i][j];
		}
	}
	vector<vector<int>> p(n, vector<int>(n));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			cin >> p[i][j];
		}
	}
	string ans;
	mainSolve(ans, si, sj, t, p);
	cout << ans << endl;
	return 0;
}