#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
const int INF = 1e9;
const ll LINF = 1e18;
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;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    for (int i = 0; i < int(v.size()); i++) {
        is >> v[i];
    }
    return is;
}
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    for (int i = 0; i < int(v.size()); i++) {
        os << v[i];
        if (i < sz(v) - 1) os << ' ';
    }
    return os;
}

const int n = 50;
const vector<int> dy = {0, 0, -1, 1};
const vector<int> dx = {-1, 1, 0, 0};
int t[n][n], p[n][n];
string dirs = "LRUD";
struct P {
    int y, x;
    char dir;
    P() {
    }
    P(int _y, int _x) : y(_y), x(_x) {
    }
    P(int _y, int _x, char _dir) : y(_y), x(_x), dir(_dir) {
    }
    bool valid() {
        return 0 <= x and x < n and 0 <= y and y < n;
    }
    vector<P> nxt(bitset<2500>& used) {
        vector<P> ret;
        rep(d, 4) {
            int ny = y + dy[d];
            int nx = x + dx[d];
            if (P(ny, nx).valid() and !used[t[ny][nx]]) {
                ret.emplace_back(ny, nx, dirs[d]);
            }
        }
        return ret;
    }
};
int check(P pos, bitset<2500>& used, int dep, int limit = 4) {
    if (dep == limit) return dep;
    int ret = 0;
    used[t[pos.y][pos.x]] = 1;
    for (P nxt : pos.nxt(used)) {
        chmax(ret, check(nxt, used, dep + 1, limit));
    }
    used[t[pos.y][pos.x]] = 0;
    return ret;
}
random_device seed_gen;
mt19937_64 rnd(seed_gen());
int main() {
    clock_t start = clock();
    auto tm = [&]() {
        return static_cast<double>(double(clock() - start) / CLOCKS_PER_SEC *
                                   1000.0);
    };
    auto random_coice = [&](vector<P>& v) -> P {
        int idx = uniform_int_distribution<int>(0, sz(v) - 1)(rnd);
        return v[idx];
    };

    int sy, sx;
    cin >> sy >> sx;
    rep(i, n) rep(j, n) cin >> t[i][j];
    rep(i, n) rep(j, n) cin >> p[i][j];

    string ans;
    int score = 0;
    int try_cnt = 0;
    while (tm() < 1950 && ++try_cnt) {
        bitset<2500> used;
        P pos = {sy, sx};
        string cur;
        int cur_score = 0;

        while (1) {
            cur_score += p[pos.y][pos.x];
            used[t[pos.y][pos.x]] = 1;
            vector<P> nxts;
            int MAX = -1;
            // cerr << pos.y << ' ' << pos.x << '\n';
            for (auto nxt : pos.nxt(used)) {
                int tmp = check(nxt, used, 0);
                // cerr << nxt.dir << " : " << tmp << '\n';
                if (tmp == MAX) {
                    nxts.push_back(nxt);
                } else if (chmax(MAX, tmp)) {
                    nxts.clear();
                    nxts.push_back(nxt);
                }
            }
            if (nxts.empty()) break;
            pos = random_coice(nxts);
            cur += pos.dir;
        }

        if (chmax(score, cur_score)) {
            ans = cur;
        }
    }
    cout << ans << '\n';
    cerr << "score : " << score << '\n';
    cerr << "cnt   : " << try_cnt << '\n';
}
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <ctime>
#include <numeric>
#include <vector>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <complex>
#include <deque>
#include <functional>
#include <list>
#include <map>
#include <string>
#include <sstream>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <forward_list>
#include <thread>
#include <random>
#include <array>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
void io()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}
int main()
{
    io();
    int si,sj; cin>>si>>sj;
    int pos[50][50];
    for(int i=0; i<50; i++){
      for(int j=0; j<50; j++){
        cin>>pos[i][j];
      }
    }
    bool chek[3000];
    memset(chek,false,sizeof(chek));
    int arr[50][50];
    for(int i=0; i<50; i++){
      for(int j=0; j<50; j++){
        cin>>arr[i][j];
      }
    }
    string str="";
    chek[pos[si][sj]]=true;
    while(true){
      if(si!=49 && !chek[pos[si+1][sj]]){
        chek[pos[si+1][sj]]=true;
        si++;
        str+='D';
      }
      else if(sj!=49 && !chek[pos[si][sj+1]]){
        chek[pos[si][sj+1]]=true;
        sj++;
        str+='R';
      }
      else if(si!=0 && !chek[pos[si-1][sj]]){
        chek[pos[si-1][sj]]=true;
        si--;
        str+='U';
      }
      else if(sj!=0 && !chek[pos[si][sj-1]]){
        chek[pos[si][sj-1]]=true;
        sj--;
        str+='L';
      }
      else{
        break;
      }
    }
    cout<<str<<endl;
}
//Aneegha Thithiesha Mahabaduge.
