#include <bits/stdc++.h>
// #include <atcoder/modint>
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define INF 2000000000000000000
#define ll long long
#define ld long double
#define pll pair<ll, ll>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

//==================param==========
ll depth = 10;
//=================================

ll si, sj;
vector<vector<ll>> board(50, vector<ll>(50));
vector<vector<ll>> point(50, vector<ll>(50));
map<ll, bool> already;
vector<char> way_char = {'R', 'D', 'L', 'U'};
vector<vector<ll>> ways = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};
stack<ll> max_ans;
stack<ll> ans;
ll max_point = 0;
ll now_point = 0;
clock_t start;

void get_input() {
  cin >> si >> sj;
  for (ll i = 0; i < 50; ++i) {
    for (ll j = 0; j < 50; ++j) {
      cin >> board.at(i).at(j);
    }
  }
  for (ll i = 0; i < 50; ++i) {
    for (ll j = 0; j < 50; ++j) {
      cin >> point.at(i).at(j);
    }
  }
  already[board.at(si).at(sj)] = true;
}

bool can_move(ll way) {
  ll nh = si + ways.at(way).at(0), nw = sj + ways.at(way).at(1);
  if (nh < 0 || nw < 0 || nh >= 50 || nw >= 50) {
    return false;
  }
  if (already[board.at(nh).at(nw)]) {
    return false;
  }
  return true;
}

void make_move(ll way) {
  si += ways.at(way).at(0), sj += ways.at(way).at(1);
  already[board.at(si).at(sj)] = true;
  ans.push(way);
  now_point += point.at(si).at(sj);
  if (now_point > max_point) {
    max_ans = ans;
    max_point = now_point;
  }
}
void rev_move() {
  ll way = ans.top();
  ans.pop();
  now_point -= point.at(si).at(sj);
  already[board.at(si).at(sj)] = false;
  si -= ways.at(way).at(0), sj -= ways.at(way).at(1);
}

ll cnt = 0;
bool fin = false;
void dfs() {
  if (fin) {
    return;
  }
  cnt += 1;
  if (cnt % 100 == 0) {
    clock_t end = clock();
    ld time = (ld)(end - start) / CLOCKS_PER_SEC * 1000.0;
    if (time > 1.9) {
      fin = true;
      return;
    }
  }
  for (ll i = 0; i < 4; ++i) {
    if (can_move(i)) {
      make_move(i);
      dfs();
      rev_move();
    }
  }
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  start = clock();
  get_input();
  dfs();
  string s_ans = "";
  while (!max_ans.empty()) {
    s_ans += way_char.at(max_ans.top());
    max_ans.pop();
  }
  reverse(rng(s_ans));
  cout << s_ans << "\n";
}

#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}void pr(){ln;}
template<class A,class...B>void pr(const A &a,const B&...b){cout<<a<<(sizeof...(b)?" ":"");pr(b...);}
template<class A>void PR(A a,ll n){rep(i,n)cout<<(i?" ":"")<<a[i];ln;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;
typedef pair<string,string> PS;
typedef pair<ll,PS> PP;

const int n=50;
ll a[n][n],b[n][n];

ll dr(char c) {
  if(c=='U') return 0;
  else if(c=='R') return 1;
  else if(c=='D') return 2;
  return 3;
}
priority_queue<PP,vector<PP>,greater<PP> > que[2500];

void Main() {
  srand((unsigned)time(NULL));
  ll sx,sy;
  cin >> sx >> sy;
  rep(i,n)rep(j,n) R a[i][j];
  rep(i,n)rep(j,n) R b[i][j];
  ll e[4]={0,1,2,3};
  string w="URDL";
  que[0].push(PP(0,PS("","")));
  ll M=-1;
  string ans="";
  rep(l,2000) {
    while(!que[l].empty()) {
      PP p=que[l].top();que[l].pop();
      string t=p.S.F,r=p.S.S;
      vector<ll> u(2500,0);
      ll x=sx,y=sy,sum=0;
      u[a[x][y]]=1;
      sum+=b[x][y];
      rep(i,t.size()) {
        ll k=dr(t[i]);
        x+=dx[k],y+=dy[k];
        u[a[x][y]]=1;
        sum+=b[x][y];
      }

      rep(jj,r.size()+1) {
        rep(o,10) {
          string rr=r.substr(0,jj);
          vector<ll> uu=u;
          ll ss=sum,x1=x,y1=y;
          REP(kk,jj,20) {
            random_shuffle(e,e+4);
            ll f=0;
            rep(j,4) {
              ll x2=x1+dx[e[j]],y2=y1+dy[e[j]];
              if(check(n,n,x2,y2)&&!uu[a[x2][y2]]&&a[x1][y1]!=a[x2][y2]) {
                uu[a[x2][y2]]=1;
                x1=x2,y1=y2;
                f=1;
                rr+=w[e[j]];
                ss+=b[x1][x2];
                break;
              }
            }
            if(!f) break;
          }
          if(ss>M) {
            M=ss;
            ans=t+rr;
          }
          if(rr.size()==0) break;
          string tt=t;
          tt+=rr[0];
          rr=rr.substr(1);
          que[l+1].push(PP(ss,PS(tt,rr)));
          while(que[l+1].size()>=10) que[l+1].pop();
        }
        if(jj>=t.size()) break;
        ll k=dr(r[jj]);
        x+=dx[k],y+=dy[k];
        u[a[x][y]]=1;
        sum+=b[x][y];
      }
    }
  }
  pr(ans);
}

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