// ahc002_a
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>
#ifdef LOCAL
#include "../../debug_util/cxx-prettyprint/prettyprint.hpp"
#include "../../debug_util/rng.hpp"
#endif
using namespace std;

using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

#define REP(i, n) for (int i = 0 ; i < (int)(n) ; ++i)
#define REPN(i, m, n) for (int i = m ; i < (int)(n) ; ++i)
#define REP_REV(i, n) for (int i = (int)(n) - 1 ; i >= 0 ; --i)
#define REPN_REV(i, m, n) for (int i = (int)(n) - 1 ; i >= m ; --i)
#define ALL(x) x.begin(), x.end()

#define INF (ll)(1e15)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int idx=0;idx<(n-1);idx++) cout << (vec)[idx] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << "\n";}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
//struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

#include <chrono>
struct Timer {
    std::chrono::time_point<std::chrono::system_clock> begin;

    void init() {
        begin = std::chrono::system_clock::now();
    }

    int get_ms() {
        auto cur = std::chrono::system_clock::now();
        return std::chrono::duration_cast<std::chrono::milliseconds>(cur - begin).count();
    }
};

struct Grid {

    const int H, W;
    const vector<vector<int>> S, T;
    Timer timer;

    const int di[8]={ 1, 0, -1, 0, -1, 1, -1, 1};
    const int dj[8]={ 0, 1, 0, -1, -1, -1, 1, 1};
    bool bound_check(int i, int j) const {return (0 <= i) && (i < H) && (0 <= j) && (j < W);}

    const char order[4] = {'D', 'R', 'U', 'L'};

    [[nodiscard]] int hash_func(int i, int j) const {
        return i * W + j;
    }

    [[nodiscard]] tuple<int, int> rev_hash(int h) const{
        int i = h / W;
        int j = h % W;
        return tie(i, j);
    }

    Grid(int H, int W, vector<vector<int>>& S, vector<vector<int>>& T): H(H), W(W), S(S), T(T) {}

    vector<bool> used;
    int score = 0;
    int max_score = 0;

    string sequence;
    string ans;

    void dfs(int i, int j){

        used[S[i][j]] = true;
        score += T[i][j];

        if (score > max_score){
            max_score = score;
            ans = sequence;
        }

        if (timer.get_ms() > 1900){
            throw 1;
        }

        REP(k, 4){
            int ni = i + di[k];
            int nj = j + dj[k];
            if (not bound_check(ni, nj)) continue;
            if (used[S[ni][nj]]) continue;

            sequence += order[k];
            dfs(ni, nj);
            sequence.pop_back();
        }

        score -= T[i][j];
        used[S[i][j]] = false;

    }

    string dfs_wrap(int si, int sj){

        // init
        int mx = 0;
        REP(i, H) REP(j, W) mx = max(mx, S[i][j]);
        used.assign(mx+1, false);

        // exec
        timer.init();
        try{
            dfs(si, sj);
        } catch(int& n){
            ;
        }
        return ans;
    }

};

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int si, sj;
    cin >> si >> sj;

    vector<vector<int>> S(50, vector<int>(50)), T(50, vector<int>(50));
    REP(i, 50) REP(j, 50) cin >> S[i][j];
    REP(i, 50) REP(j, 50) cin >> T[i][j];

    Grid g(50, 50, S, T);

    string ans = g.dfs_wrap(si, sj);
    print(ans);

#ifdef LOCAL
    print(g.max_score);
#endif

    return 0;
}

#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
using ll = long long;

#define MOD 1000000007
#define SWAP(a,b) ((a != b)? (a += b,b = a - b,a -= b) : 0 ) //数値のみ
#define SWAP(type,a,b) { type temp = a; a = b; b = temp; } //ポインタ, 構造体, 文字列
#define rng(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define pb push_back
#define eb emplace_back
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed

ll jo(ll a, ll n){
  ll tmp = 1;
  rep(i, n) {
    tmp *= a;
    if(tmp <= 0) return -1;
  }
  return tmp;
}

ll jom(ll a, ll n){
  ll tmp = 1;
  rep(i, n) {
    tmp *= a;
    tmp %= MOD;
  }
  return tmp;
}

unsigned digit(unsigned num){
    return std::to_string(num).length();
}

void yn(bool Yes){
  cout << ((Yes)? "Yes" : "No") << endl;
}

void ny(bool No){
  cout << ((No)? "No" : "Yes") << endl;
}

void YN(bool YES){
  cout << ((YES)? "YES" : "NO") << endl;
}

void NY(bool NO){
  cout << ((NO)? "NO" : "YES") << endl;
}

void Yay(bool y){
  cout << ((y)? "Yay!" : ":(") << endl;
}

string move(int &si, int &sj, vector<vector<int>> &t, vector<vector<int>> &p){
  int mi = -1, mj = -1, i = 0;
  if(si < 25) mi = 1;
  if(sj < 25) mj = 1;
  string ans = "";
  while(si+mi >= 0 && si+mi < 50 && sj+mj >= 0 && sj+mj < 50 && i != 50){
    i++;
    t[si][sj] += 10000;
    if(t[si+mi][sj] % 10000 != t[si][sj] % 10000 && t[si+mi][sj] <= 10000){
      if(mi == 1) ans += 'D';
      else ans += 'U';
      si += mi;
    }
    else if(t[si][sj+mj] % 10000 != t[si][sj] % 10000 && t[si][sj+mj] <= 10000){
      if(mj == 1) ans += 'R';
      else ans += 'L';
      sj += mj;
    }
    else {
      break;
      cout << si << " " << sj << endl;
    }
  }
  return ans;
}

int main() {
  int n, si, sj, b, ans = 0, tmp = 0;
  string s = "", s2 = "";
  vector<vector<int>> t(50, vector<int>(50, 0)), p(50, vector<int>(50, 0));
  cin >> si >> sj;
  rep(i, 50) rep(j, 50) cin >> t[i][j];
  rep(i, 50) rep(j, 50) cin >> p[i][j];
  s = move(si, sj, t, p);
  //s2 = move(si, sj, t, p);
  cout << s << endl;
  //printf("%.10lf\n", ans);
}