#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

struct xy {
	int x;
	int y;
};

const int n = 50;
vector<vector<int>> t(n, vector<int>(n));
vector<vector<int>> p(n, vector<int>(n));
xy s;
clock_t start;
string ans = "";
int maxPoint = 0;

void input () {
  cin >> s.x >> s.y;
	rep(i, n) rep(j, n) cin >> t[i][j];
	rep(i, n) rep(j, n) cin >> p[i][j];
}

bool isTimeLimit(clock_t start) {
  clock_t end = clock();
  const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
  if (time >= 500) return true;
  else return false;
}

int cnt = 0;
void dfs(int mode, xy now, int point, string tmpans, set<int> step) {
  cnt++;
  // タイムリミット
  if (cnt%500 == 0) {
    if (isTimeLimit(start)) {
      cout << ans << endl;
      exit(0);
    }
  }

  switch (mode) {
    case 0: now.x--; break;
    case 2: now.x++; break;
    case 1: now.y--; break;
    case 3: now.y++; break;
  }

  if (!(now.x >= 0 && now.x <= 49 && now.y >= 0 && now.y <= 49)) {
    return ;
  }
  auto it = step.find(t[now.x][now.y]);
  if (it != step.end()) return;
  step.insert(t[now.x][now.y]);
  switch (mode) {
    case 0: tmpans += "U"; break;
    case 2: tmpans += "D"; break;
    case 1: tmpans += "L"; break;
    case 3: tmpans += "R"; break;
  }

  point += p[now.x][now.y];
  
  if (point > maxPoint) {
    maxPoint = point;
    ans = tmpans;
  }
  
  rep(i, 4) dfs(i, now, point, tmpans, step);
  return;
}

int main() {
	// 入力
  input();

  start = clock();
  rep(i, n) {
    // 初期化
    xy now;
    now.x = s.x;
    now.y = s.y;
    set<int> step; // 踏んだタイル番号を保持
    step.insert(t[now.x][now.y]);
    string tmpans = "";
    int point = 0;


    // 進む方向探索
    // 0：上、1：下、2：左、3：右
    dfs(i, now, point, tmpans, step);
  }
	return 0;
}

#include <time.h>

#include <stdlib.h>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <bitset>
#include <iterator>
#include <deque>
#include <random>

#include <string>
#include <queue>
#include <omp.h>
#include <fstream>   // ifstream, ofstream
typedef int64_t ll;
using namespace std;
const ll INF=1e16;
const double EPS=1e-8;
const ll mod = 1000000007;
const int BOARD_SIZE=50;
struct Status{
	vector<bool> tile_passed;
	int ci=0;
	int cj=0;
	int current_point = 0;
	string route = "";
	bool operator<(const Status& cmp) const{
		return current_point>cmp.current_point;
	}
};
int t[BOARD_SIZE][BOARD_SIZE];
int p[BOARD_SIZE][BOARD_SIZE];
vector<Status> generate_next(Status current, int min_ci, int max_ci, int min_cj, int max_cj){
	vector<Status> retval;
	Status temp;
	if(current.ci>min_ci && !current.tile_passed[t[current.ci-1][current.cj]]){
		temp = Status(current);
		temp.ci=current.ci-1;
		temp.current_point+=p[temp.ci][temp.cj];
		temp.tile_passed[t[temp.ci][temp.cj]]=true;
		temp.route+="U";
		retval.push_back(temp);
	}
	if(current.ci<max_ci && !current.tile_passed[t[current.ci+1][current.cj]]){
		temp = Status(current);
		temp.ci=current.ci+1;
		temp.current_point+=p[temp.ci][temp.cj];
		temp.tile_passed[t[temp.ci][temp.cj]]=true;
		temp.route+="D";
		retval.push_back(temp);
	}
	if(current.cj>min_cj && !current.tile_passed[t[current.ci][current.cj-1]]){
		temp = Status(current);
		temp.cj=current.cj-1;
		temp.current_point+=p[temp.ci][temp.cj];
		temp.tile_passed[t[temp.ci][temp.cj]]=true;
		temp.route+="L";

		retval.push_back(temp);
	}
	if(current.cj<max_cj && !current.tile_passed[t[current.ci][current.cj+1]]){
		temp = Status(current);
		temp.cj=current.cj+1;
		temp.current_point+=p[temp.ci][temp.cj];
		temp.tile_passed[t[temp.ci][temp.cj]]=true;
		temp.route+="R";

		retval.push_back(temp);
	}
	return retval;



}

int main(){
	int si,sj;
	cin>>si>>sj;
	int temp;
	for(int i=0;i<BOARD_SIZE;i++){
		for(int j=0;j<BOARD_SIZE;j++){
			cin>>temp;
			t[i][j]=temp;
		}
	}
	for(int i=0;i<BOARD_SIZE;i++){
		for(int j=0;j<BOARD_SIZE;j++){
			cin>>temp;
			p[i][j]=temp;
		}
	}
	vector<Status> *current = new vector<Status>();
	vector<Status> *next = new vector<Status>();
	Status initial;
	for(int i = 0;i<BOARD_SIZE*BOARD_SIZE;i++){
		initial.tile_passed.push_back(false);
	}
	initial.ci=si;
	initial.cj=sj;
	initial.tile_passed[t[si][sj]]=true;
	initial.current_point=p[si][sj];
	next->push_back(initial);
	int best_point = 0;
	string best_route="";
	int best_ci,best_cj;
	for(int cnt=0;cnt<400;cnt++){
		delete current;
		current = next;
		next = new vector<Status>();
		for(auto i = current->begin();i!=current->end();i++){
			//try 4 neighbour
			vector<Status> next_result = generate_next(*i,0,49,0,49);
			std::copy(next_result.begin(),next_result.end(),std::back_inserter(*next));
		}
		sort(next->begin(),next->end());
		if(next->size()>0 && next->at(0).current_point>best_point){
			best_point = next->at(0).current_point;
			best_route = next->at(0).route;
		}
		/*for(auto i1=next->begin();i1!=next->end();i1++){
			if(i1->ci==17){
				best_point = i1->current_point;
				best_route = i1->route;
				best_ci = i1->ci;
				best_cj = i1->cj;
				break;
			}
		}*/
		if(next->size()>1000){
			vector<Status> *shuffled_next = new vector<Status>();
			copy(next->begin(),next->begin()+200,std::back_inserter(*shuffled_next));
			std::random_device seed_gen;
			std::mt19937 engine(seed_gen());

			shuffle(next->begin()+200,next->end(),engine);
			copy(next->begin()+200,next->begin()+1000,std::back_inserter(*shuffled_next));
			delete next;
			next = shuffled_next;
		}
	}
	cout<<best_route<<endl;

}
