#include<bits/stdc++.h>
using namespace std;
const int maxn=55;
struct to {
	int x,y,id;
} dd[5],d[5];
int a[maxn][maxn],w[maxn][maxn],ans[maxn*maxn],temp[maxn*maxn],vis[maxn*maxn],sum=0,n=50,finalans=0,s[maxn];
char p[5]= {'\0','D','R','U','L'};
bool cmp(to a,to b) {
	return s[a.id]>s[b.id];
}
int get(int x,int y,to a) {
	x=x+a.x;
	y=y+a.y;
	if(vis[::a[x][y]]||x>n||y>n||x<1||y<1) {
		return -1;
	}
	return w[x][y];
}
void dfs(int x,int y) {
	if(1.0*clock()/CLOCKS_PER_SEC>1.8) {
		if(sum>finalans) {
			finalans=sum;
			memcpy(ans,temp,sizeof(temp));
		}
		for(int i=1; i<=ans[0]; i++) {
			cout<<p[ans[i]];
		}
		exit(0);
	}
	vis[a[x][y]]=1;
//	temp[++temp[0]]=
	sum+=w[x][y];
	int fl=0;
	to d[5];
	memcpy(d,dd,sizeof(d));
//	random_shuffle(d+1,d+4+1);
	for(int i=1;i<=4;i++) {
		s[i]=get(x,y,d[i]);
	}
	sort(d+1,d+4+1,cmp);
	for(int i=1; i<=4; i++) {
		int nx=x+d[i].x,ny=y+d[i].y;
		if(!vis[a[nx][ny]]&&nx<=n&&nx>=1&&ny<=n&&ny>=1) {
			temp[++temp[0]]=d[i].id;
			dfs(nx,ny);
			fl=1;
			--temp[0];
		}
	}
	if(fl==0) {
		if(sum>finalans) {
			finalans=sum;
			memcpy(ans,temp,sizeof(temp));
		}
	}
	sum-=w[x][y];
	vis[a[x][y]]=0;
}
int main() {
	dd[1]=(to) {
		1,0,1
	};
	dd[2]=(to) {
		0,1,2
	};
	dd[3]=(to) {
		-1,0,3
	    };
	dd[4]=(to) {
		0,-1,4
	};
	int x,y;
	cin>>x>>y;
	x++,y++;
	for(int i=1; i<=n; i++) {
		for(int j=1; j<=n; j++) {
			cin>>a[i][j];
		}
	}
	for(int i=1; i<=n; i++) {
		for(int j=1; j<=n; j++) {
			cin>>w[i][j];
		}
	}
	srand(time(0));
	dfs(x,y);
	for(int i=1; i<=ans[0]; i++) {
		cout<<p[ans[i]];
	}
	exit(0);
}
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define MOD 1000000007ll
#define INF 1000000000000000000ll
#define pb push_back
#define fs first
#define sc second
const double pi = acos(-1);

vector<bool> dfs(int start, vector<vector<int>>& adj) {
	stack<int> s;
	s.push(start);
	vector<bool> vis(adj.size(), false);
	vis[start] = true;
	while (s.size()) {
		int cur = s.top();
		s.pop();
		for (int nxt : adj[cur]) {
			if (!vis[nxt]) {
				s.push(nxt);
				vis[nxt] = true;
			}
		}
	}
	return vis;
}

int n;
vector<pair<int, int>> A;
bool can(double r) {
	set<pair<int, int>> points;
	for (int i = 0; i < n; i++) {
		points.insert(A[i]), points.insert(make_pair(A[i].fs, 100)), points.insert(make_pair(A[i].fs, -100));
	}
	map<pair<int, int>, int> from;
	int idx = 0;
	for (pair<int, int> point : points) {
		from[point] = idx++;
	}

	int m = points.size();
	vector<vector<int>> adj(m);
	for (pair<int, int> point1 : points) {
		for (pair<int, int> point2 : points) {
			ll dx = abs(point1.fs - point2.fs), dy = abs(point1.sc - point2.sc);
			if (sqrt(dx * dx + dy * dy) < 2 * r) 
				adj[from[point1]].pb(from[point2]);
		}
	}

	for (int i = 0; i < n; i++) {
		pair<int, int> curs = make_pair(A[i].fs, 100);
		vector<bool> reach = dfs(from[curs], adj);
		for (int j = 0; j < n; j++) {
			pair<int, int> cor = make_pair(A[j].fs, -100);
			if (reach[from[cor]]) {
				return false;
			}
		}
	}
	return true;
}

void solve() {
	cin >> n;
	A = vector<pair<int, int>>(n);
	for (int i = 0; i < n; i++)
		cin >> A[i].fs >> A[i].sc;
	double lo = 0, hi = 200, bst = 0;
	while (abs(hi - lo) > 1e-7) {
		double mid = (hi + lo) / 2;
		if (can(mid)) {
			lo = mid;
			bst = mid;
		}
		else {
			hi = mid;
		}
	}
	cout << fixed << setprecision(12) << bst << endl;
}


signed main() {
	ios_base::sync_with_stdio(false);
	/*int t;
	cin >> t;
	while (t--)*/
		solve();
}