#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <sys/time.h>

using namespace std;

class XorShift128 {
private:
    uint32_t x, y, z, w;
public:
    XorShift128() : x(123456789), y(362436069), z(521288629), w(88675123) { }
    uint32_t rnd() {
        uint32_t t = x ^ (x << 11);
        x = y;
        y = z;
        z = w;
        return w = (w ^ (w >> 19)) ^ (t ^ (t >> 8));
    }
    uint32_t rnd(int n) {
        return rnd() % n;
    }
    uint32_t rnd(int l, int r) {
        return rnd() % (r - l + 1) + l;
    }
};

long long get_time() {
    struct timeval tv;
    gettimeofday(&tv, NULL);
    long long result =  tv.tv_sec * 1000LL + tv.tv_usec / 1000LL;
    return result;
}

template<typename TYPE>
ostream& operator<<(ostream& ostr, const vector<TYPE>& vec) {
    ostr << "(";
    for(TYPE e : vec) {
        ostr << e << ", ";
    }
    ostr << ")";
    return ostr;
}

long long start;
XorShift128 xor_shift_128;

const int SIZE = 50;

class Solver {
    int sh, sw;
    int tile[SIZE][SIZE];
    int point[SIZE][SIZE];
public:
    Solver();
    void run();
};


Solver::Solver() {
    cin >> sh >> sw;
    for(int hi = 0; hi < SIZE; ++hi) {
        for(int wi = 0; wi < SIZE; ++wi) {
            cin >> tile[hi][wi];
        }
    }
    for(int hi = 0; hi < SIZE; ++hi) {
        for(int wi = 0; wi < SIZE; ++wi) {
            cin >> point[hi][wi];
        }
    }
}

void Solver::run() {

}


int main() {
    start = get_time();

    ios::sync_with_stdio(false);
	cin.tie(nullptr);

    Solver solver;
    solver.run();
}
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define mat vector<vector<int>>
#define vi vector<int>
#define ff first
#define ss second
#define ll long long
#define pb push_back
#define pi pair<int, int>
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for(int i=a; i<b; i++)
#define rrep(i,a,b) for(int i=b; i>=a; i--)
//#define endl "\n"

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
char dir[4]={'D','R','U','L'};

//****DO NOT TOUCH ABOVE THIS LINE****//
//#define kk

const int maxN=1e5+5;

int arr[50][50];
int joiner[50][50];
int vis[50][50];
int maxCost;
string ans;

bool isValid(int x, int y){
	if(x<0 || x>49 || y<0 || y>49 || vis[x][y]) return false;
	return true;
}

void dfs(int x, int y, int cost, string path){
	vis[x][y]=1;
	
	rep(i,0,4){
		int a=x+dx[i], b=y+dy[i];
		if(isValid(a,b) && joiner[a][b]==joiner[x][y]){
			vis[a][b]=1;
		}
	}
	
	int cnt=0;
	
	rep(i,0,4){
		int a=x+dx[i], b=y+dy[i];
		
		if(isValid(a,b)){
			cnt++;
			dfs(a,b,cost+arr[a][b],path+dir[i]);
		}
	}
	
	if(cnt==0){
		if(maxCost<cost){
			maxCost=cost;
			ans=path;
		}
	}
		
	//vis[x][y]=0;
	
	//rep(i,0,4){
		//int a=x+dx[i], b=y+dy[i];
		//if(joiner[a][b]==joiner[x][y]){
			//vis[a][b]=0;
		//}
	//}
}

void solve(){
	int x,y;
	cin>>x>>y;
	
	rep(i,0,50){
		rep(j,0,50){
			cin>>joiner[i][j];
		}
	}
	
	rep(i,0,50){
		rep(j,0,50){
			cin>>arr[i][j];
		}
	}
	
	dfs(x,y,arr[x][y],"");

	cout<<ans<<endl;
}

//****DO NOT TOUCH BELOW THIS LINE****//

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	cout<<fixed<<setprecision(5);

	#ifdef kk
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	
	int T=1;
	//cin>>T;

	while(T--){
		solve();
	}
}
