#include<bits/stdc++.h>
using namespace std;
int N,M;
int P[51][51];
int main(void)
{
	register int i,j;
	cin>>N>>M;
	for(i=1;i<=50;i++)for(j=1;j<=50;j++)cin>>P[i][j];
	N++,M++;
	if(M>1&&P[N][M-1]!=P[N][M])cout<<"L"<<endl,exit(0);
	if(M<50&&P[N][M+1]!=P[N][M])cout<<"R"<<endl,exit(0);
	if(N>1&&P[N-1][M]!=P[N][M])cout<<"U"<<endl,exit(0);
	if(N<50&&P[N+1][M]!=P[N][M])cout<<"D"<<endl,exit(0);
	cout<<"D"<<endl;
	return 0;
}
#include <bits/stdc++.h>
#define LIMTIME 1930
using namespace std;

using P = pair<int, int>;
using B = bitset<2500>;

struct dat {
  B b;
  int x, y;
  dat(int _x = 0, int _y = 0, B _b = B()) : b(_b), x(_x), y(_y) {}
  bool operator<(const dat r) const {
    if (x != r.x) return x < r.x;
    if (y != r.y) return y < r.y;
    for (int i = 0; i < 2500; ++i)
      if (b[i] != r.b[i]) return b[i];
    return 0;
  }
};

using node = pair<int, dat>;

const int n = 50;
int d[4] = {0, 1, 0, -1};
string dir = "RDLU";
vector<vector<int>> t, p;
P st;
map<dat, int> dp;
map<dat, string> memo;

string solve();
bool isvalid(int x, int y) { return x >= 0 && x < n && y >= 0 && y < n; }

int main() {
  cin >> st.first >> st.second;
  t.resize(n);
  for (auto& v : t) {
    v.resize(n);
    for (auto& x : v) cin >> x;
  }
  p.resize(n);
  for (auto& v : p) {
    v.resize(n);
    for (auto& x : v) cin >> x;
  }
  cout << solve() << endl;
  return 0;
}

string solve() {
  vector<node> v;
  string ress;
  int resp;
  {  // make start node
    B stb;
    stb[t[st.first][st.second]] = 1;
    dat stdat(st.first, st.second, stb);
    resp = dp[stdat] = p[st.first][st.second];
    memo[stdat] = "";
    v.push_back(node(dp[stdat], stdat));
  }
  auto start = chrono::system_clock::now();
  auto nowt = chrono::system_clock::now();
  auto dur = nowt - start;
  auto msec = chrono::duration_cast<chrono::milliseconds>(dur).count();
  int cnt = 0;
  vector<int> did = {0, 1, 2, 3};
  {
    vector<int> dists = {49 - st.second, 49 - st.first, st.second, st.first};
    sort(did.begin(), did.end(),
         [&](int l, int r) { return dists[l] > dists[r]; });
  }
  int bf = resp, nch = 0;
  while (v.size() && msec < LIMTIME) {
    {
      if (bf == resp) {
        if (++nch >= 300) {
          int len = max(1, (int)v.size() / 2);
          while (v.size() > len) v.pop_back();
          nch = -1e8;
        }
      } else
        nch = 0, bf = resp;
    }
    // cerr << cnt++ << " " << resp << " " << v.size() << " " << msec << endl;
    const auto [score, now] = v.back();
    v.pop_back();
    string s = memo[now];
    if (score != dp[now]) continue;
    for (int i : did) {
      int tx = now.x + d[i], ty = now.y + d[1 ^ i];
      if (!isvalid(tx, ty)) continue;
      int id = t[tx][ty], tscore = score + p[tx][ty];
      if (now.b[id]) continue;
      // pushed = 1;
      dat to(tx, ty, now.b);
      to.b[id] = 1;
      if (dp.count(to) && dp[to] >= tscore) continue;
      dp[to] = tscore;
      memo[to] = s + dir[i];
      v.push_back(node(tscore, to));
      if (resp < tscore) resp = tscore, ress = memo[to];
    }
    nowt = chrono::system_clock::now();
    dur = nowt - start;
    msec = chrono::duration_cast<chrono::milliseconds>(dur).count();
  }
  cerr << cnt << " " << v.size() << " " << resp << endl;
  return ress;
}