#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) begin(v), end(v)
#define sz(v) v.size()
#define INF 1e18+9
#define EPSILON 1e-14
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

ll si, sj;
vector<vector<ll>> p(50, vector<ll>(50));
vector<bool> vst(2500, false);
vector<vector<ll>> t(50, vector<ll>(50));

ll scoring(string S){
    ll score = 0;
    score += p.at(si).at(sj);
    vst.at(t.at(si).at(sj)) = true;
    ll px = si;
    ll py = sj;
    rep(i, sz(S)){
        if(S.at(i) == 'U'){
            px--;
        }
        else if(S.at(i) == 'D'){
            px++;
        }
        else if(S.at(i) == 'L'){
            py--;
        }
        else if(S.at(i) == 'R'){
            py++;
        }
        if(vst.at(t.at(px).at(py))){
            cerr << t.at(px).at(py) << ": twice visited" << endl;
            return -1;
        }
        else{
            vst.at(t.at(px).at(py)) = true;
            score += p.at(px).at(py);
        }
    }
    return score;
}

string solve(){
    string ans = "";
    vector<ll> dx = {-1, 1, 0, 0};
    vector<ll> dy = {0, 0, -1, 1};
    string dir = "UDLR";
    ll px = si;
    ll py = sj;
    vst.at(t.at(si).at(sj)) = true;
    while(true){
        bool move = false;
        rep(i, 4){
            if(0 <= px+dx.at(i) && px+dx.at(i) <= 49 && 0 <= py+dy.at(i) && py+dy.at(i) <= 49 && !vst.at(t.at(px+dx.at(i)).at(py+dy.at(i)))){
                px += dx.at(i);
                py += dy.at(i);
                vst.at(t.at(px).at(py)) = true;
                ans += dir.at(i);
                move = true;
                break;
            }
        }
        if(!move){
            break;
        }
    }
    return ans;
}

string greed(){
    string ans = "";
    vector<ll> dx = {-1, 1, 0, 0};
    vector<ll> dy = {0, 0, -1, 1};
    string dir = "UDLR";
    ll px = si;
    ll py = sj;
    vst.at(t.at(si).at(sj)) = true;
    while(true){
        ll add = 0;
        ll d = -1;
        rep(i, 4){
            if(0 <= px+dx.at(i) && px+dx.at(i) <= 49 && 0 <= py+dy.at(i) && py+dy.at(i) <= 49 && !vst.at(t.at(px+dx.at(i)).at(py+dy.at(i)))){
                if(chmax(add, p.at(px+dx.at(i)).at(py+dy.at(i)))){
                    d = i;
                }
            }
        }
        if(d == -1){
            break;
        }
        px += dx.at(d);
        py += dy.at(d);
        vst.at(t.at(px).at(py)) = true;
        ans += dir.at(d);
    }
    return ans;
}

int main()
{
    cin >> si >> sj;
    rep(i, 50){
        rep(j, 50){
            cin >> t.at(i).at(j);
        }
    }
    rep(i, 50){
        rep(j, 50){
            cin >> p.at(i).at(j);
        }
    }
    cout << greed() << endl;
}
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};

int si, sj;
vector<vector<int>> t(50, vector<int>(50,0));
vector<vector<int>> p(50, vector<int>(50,0));
vector<vector<bool>> used(50, vector<bool>(50, false));
string ans_s;

int score() {
    int ans = 0;
    return ans;
}

void solve() {
    queue<P> q;
    q.push(make_pair(si, sj));
    used.at(si).at(sj) = true;

    for (int i = 0; i < 4; i++) {
        int xd = si + dx[i];
        int yd = sj + dy[i];
        if (xd >= 0 && xd < 50 && yd >= 0 && yd < 50 && t.at(si).at(sj) == t.at(xd).at(yd)) used.at(xd).at(yd) = true;
    }
    ll s = 0;

    mt19937 mt(1234);
    uniform_int_distribution<> rand4(0, 3);
    int cnt = 0, false_cnt = 0;

    while(!q.empty() && false_cnt < 10 && cnt < 100000000) {
        P tmp = q.front();

        int i = rand4(mt);
        int x = tmp.first + dx[i];
        int y = tmp.second + dy[i];

        if (x >= 0 && x < 50 && y >= 0 && y < 50 && !used.at(x).at(y)) {
            false_cnt = 0;
            s += p.at(x).at(y);
            used.at(x).at(y) = true;
            q.pop();
            q.push(make_pair(x, y));
            for (int j = 0; j < 4; j++) {
                int xd = x + dx[j];
                int yd = y + dy[j];
                if (xd >= 0 && xd < 50 && yd >= 0 && yd < 50 && t.at(x).at(y) == t.at(xd).at(yd)) used.at(xd).at(yd) = true;
            }
            if (i == 0) ans_s += 'U';
            else if (i == 1) ans_s += 'L';
            else if (i == 2) ans_s += 'D';
            else ans_s += 'R';
        } else false_cnt++;
        cnt++;
    }
}

int main(){
    cin >> si >> sj;

    for (int i = 0; i < 50; i++) {
        for (int j = 0; j < 50; j++) {
            cin >> t.at(i).at(j);
        }
    }
    for (int i = 0; i < 50; i++) {
        for (int j = 0; j < 50; j++) {
            cin >> p.at(i).at(j);
        }
    }
    solve();
    //ans_s.erase(ans_s.size()-1);
    cout << ans_s << endl;
    return 0;
}