#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include<numeric>//gcd(,),lcm(,)
#include<cmath>//sin(),cos(),tan()  kodoho
#define _GLIBCXX_DEBUG
using namespace std;
const long long INF = 10000000;
using ll = long long;
using graph = vector<vector<int>>;



int main() {
	int si, sj;
	cin >> si >> sj;
	vector<vector<int>>t(50,vector<int>(50));
	vector<vector<int>>p(50,vector<int>(50));
	for (int i = 0; i < 50; i++) {
		for (int h = 0; h < 50; h++) {
			cin >> t[i][h];
		 }
	}
	for (int i = 0; i < 50; i++) {
		for (int h = 0; h < 50; h++) {
			cin >> p[i][h];
		}
	}
	set<int>watched;
	watched.insert(t[si][sj]);
      	while (true) {
			bool remain = false;
			int r, l, u, d;
			r = 0;
			l = 0;
			u = 0;
			d = 0;
			if (sj < 49) {
				if (!watched.count(t[si][sj + 1])) {
					r = p[si][sj + 1];
					remain = true;
				}
				else {
					r = -1;
				}
			}
			else {
				r = -1;
			}
			if (sj > 0) {
				if (!watched.count(t[si][sj - 1])) {
					l = p[si][sj - 1];
					remain = true;
				}
				else {
					l = -1;
				}
			}
			else {
				l = -1;
			}
			if (si > 0) {
				if (!watched.count(t[si - 1][sj]) ) {
					u = p[si - 1][sj];
					remain = true;
				}
				else {
					u = -1;
				}
			}
			else {
				u = -1;
			}
			if (si <49) {
				if (!watched.count(t[si +1][sj])) {
					d = p[si + 1][sj];
					remain = true;
				}
				else {
					d = -1;
				}
			}
			else {
				d = -1;
			}
		if (remain == false) {
			break;
		}
		if (max(l, r) == l && max(l, d) == l && max(l, u) == l) {
			cout << "L";
			watched.insert(t[si][sj-1]);
			sj = sj - 1;
			continue;
		}
		if (max(r, l) == r && max(r, d) == r && max(r, u) == r) {
			cout << "R";
			watched.insert(t[si][sj+1]);
			sj = sj + 1;
			continue;
		}
		if (max(u, l) == u && max(u, d) == u && max(r, u) == u) {
			cout << "U";
			
			watched.insert(t[si-1][sj]);
			si = si - 1;
			continue;
		}
		if (max(d, l) == d && max(r, d) == d && max(d, u) == d) {
			cout << "D";
			
			watched.insert(t[si+1][sj]);
			si = si + 1;
			continue;
		}
	}
}
#include <bits/stdc++.h>
#include <iostream>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  vector<int> tileID(50 * 50);
  vector<int> steped(50 * 50);
  int x, y;
  string ans = "";
  cin >> y >> x;
  rep(i,50 * 50) {
    cin >> tileID[i];
  }
  steped[0] = tileID[50 * y + x];
  int i = 0;
  while(true) {
    if (*find(steped.begin(), steped.end(), tileID[50 * (y - 1) + x]) != tileID[50 * (y - 1) + x] && y != 0) {
      y -= 1;
      ans += 'U';
    } else if (*find(steped.begin(), steped.end(), tileID[50 * y + x - 1]) != tileID[50 * y + x - 1] && x != 0) {
      x -= 1;
      ans += 'L';
    } else if (*find(steped.begin(), steped.end(), tileID[50 * (y + 1) + x]) != tileID[50 * (y + 1) + x] && y != 49) {
      y += 1;
      ans += 'D';
    } else if (*find(steped.begin(), steped.end(), tileID[50 * y + x + 1]) != tileID[50 * y + x + 1] && x != 49) {
      x += 1;
      ans += 'R';
    } else {
      break;
    }
    i++;
    steped[i] = tileID[50 * y + x];
  }
  cout << ans << endl;
  return 0;
}
