#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <sys/time.h>
using namespace std;

struct state
{
  int x;
  int y;
  int score;
  string path;
  vector<bool> used;
};

int main()
{
  struct timeval tmp_time;
  gettimeofday(&tmp_time, NULL);
  long long program_init_time = tmp_time.tv_sec*1000000+tmp_time.tv_usec;
  long long fin_time, current_time;
  fin_time = program_init_time + 1200000;

  int si, sj, count;
  cin >> si >> sj;
  vector<vector<int>> tiling(50,vector<int>(50)), grids(50,vector<int>(50));
  for (int i = 0; i < 50; i++)
  {
    for (int j = 0; j < 50; j++) cin >> tiling.at(i).at(j);
  }
  for (int i = 0; i < 50; i++)
  {
    for (int j = 0; j < 50; j++) cin >> grids.at(i).at(j);
  }
  vector<int> dx{1,-1,0,0}, dy{0,0,1,-1};
  string dir = "DURL";
  vector<bool> used(2500,false);
  used.at(tiling.at(si).at(sj)) = true;
  queue<state> que;
  state now_state, best_state;
  now_state.x = si, now_state.y = sj;
  now_state.score = grids.at(si).at(sj);
  now_state.path = "";
  now_state.used = used;
  best_state = now_state;
  que.push(now_state);
  count = 0;
  while (!que.empty())
  {
    count++;
    now_state = que.front();
    que.pop();
    for (int i = 0; i < 4; i++)
    {
      if (now_state.x+dx.at(i) < 0 || now_state.x+dx.at(i) >= 50 || now_state.y+dy.at(i) < 0 || now_state.y+dy.at(i) >= 50)
        continue;
      if (now_state.used.at(tiling.at(now_state.x+dx.at(i)).at(now_state.y+dy.at(i))))
        continue;
      now_state.score += grids.at(now_state.x+dx.at(i)).at(now_state.y+dy.at(i));
      now_state.path += dir.at(i);
      now_state.used.at(tiling.at(now_state.x+dx.at(i)).at(now_state.y+dy.at(i))) = true;
      now_state.x += dx.at(i), now_state.y += dy.at(i);
      if (best_state.score < now_state.score)
        best_state = now_state;
      que.push(now_state);
      now_state.x -= dx.at(i), now_state.y -= dy.at(i);
      now_state.score -= grids.at(now_state.x+dx.at(i)).at(now_state.y+dy.at(i));
      now_state.path.pop_back();
      now_state.used.at(tiling.at(now_state.x+dx.at(i)).at(now_state.y+dy.at(i))) = false;
    }
    if (count % 100 == 0)
    {
      gettimeofday(&tmp_time, NULL);
      current_time = tmp_time.tv_sec*1000000 + tmp_time.tv_usec;
      if (current_time > fin_time)
        break;
    }
  }
  cout << best_state.path << endl;
}

//  ██████  ██    ██ ██████  ██ ██   ██  ██████ 
// ██       ██    ██ ██   ██ ██ ██  ██  ██    ██ 
// ██   ███ ██    ██ ██████  ██ █████   ██    ██ 
// ██    ██ ██    ██ ██   ██ ██ ██  ██  ██    ██ 
//  ██████   ██████  ██   ██ ██ ██   ██  ██████  


#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const ll MOD=1e9+7;
const int MAX=1e5+10;
const int INF=1e9;
const double PI=acos(-1);

vector<vector<int>> t(50,vector<int>(50)), p(50,vector<int>(50));
vector<vector<P>> ti(2500);
vector<int> di={-1,0,0,1},dj={0,-1,1,0};
string dir="ULRD";
mt19937 mt(1);

pair<int,string> res(int si, int sj, vector<vector<int>> used) {
    int sc=p[si][sj];
    string ans;
    int tmp=t[si][sj];
    rep(m,ti[tmp].size()) {
        used[ti[tmp][m].first][ti[tmp][m].second]=1;
    }
    vector<P> tmp_p;
    rep(k,4) {
        int ni=si+di[k],nj=sj+dj[k];
        if (ni>=0 && ni<50 && nj>=0 && nj<50) {
            if (used[ni][nj]==0) {
                int pp=min(min(49-ni,ni),min(49-nj,nj));
                // tmp_p.push_back({pp,k});
                // tmp_p.push_back({p[ni][nj],k});
                tmp_p.push_back({p[ni][nj]+pp^3,k});
            }
        }
    }
    sort(tmp_p.begin(),tmp_p.end(),greater<>());
    vector<int> thresh={0,90,95,95};

    int max_sc=-1,max_ind=-1;
    string max_str="";
    rep(m,tmp_p.size()) {
        int k=tmp_p[m].second;
        int ni=si+di[k],nj=sj+dj[k];
        int r=mt()%100;
        // cout << r << ' ' << thresh[m] << endl;
        if (r>=thresh[m]) {
            pair<int,string> tmp=res(ni,nj,used);
            int tmp_sc=tmp.first;
            if (tmp_sc>max_sc) {
                max_sc=tmp_sc;
                max_ind=k;
                max_str=tmp.second;
            }
        }
    }
    if (max_sc==-1) return {0, ""};

    else {
        sc+=max_sc;
        si+=di[max_ind];
        sj+=dj[max_ind];
        ans.push_back(dir[max_ind]);
        ans+=max_str;
    }
    // cout << "si=" << si << ",sj=" << sj << ans << endl;
    return {sc, ans};
}

int main() {
    int si,sj;
    cin >> si >> sj;
    rep(i,50) {
        rep(j,50) {
            int tmp;
            cin >> tmp;
            t[i][j]=tmp;
            P pp={i,j};
            ti[tmp].push_back(pp);
            // cout << tmp << ' ' << i << ' ' << j << endl;
        }
    }
    rep(i,50) {
        rep(j,50) cin >> p[i][j];
    }

    string ans="";
    int max_score=0;
    // cout << "-------------------------------------" << endl;

    vector<vector<int>> used(50,vector<int>(50));
    pair<int,string> r=res(si,sj,used);
    cout << r.second << endl;

    return 0;
}
