#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <numeric>
#include <iomanip>
#include <algorithm>
using namespace std;

string rus;
int point = 0;

void move(vector<vector<int>> &mdata, vector<vector<int>> &pdata, vector<int> cdata,int x,int y,int p,int dir, string sdata){
	if (point < p) {
		rus = sdata;
		point = p;
	}
	if (x > 50 || y > 50 || x <= 0 || y <= 0) {
		return;
	}
	if (cdata.at(mdata.at(y).at(x)) == 0) {
		return;
	}
	cdata.at(mdata.at(y).at(x)) = 0;
	p = p + pdata.at(y).at(x);

	if (dir == 1)
		sdata += 'D';
	else if (dir == 2)
		sdata += 'U';
	else if (dir == 3)
		sdata += 'R';
	else if (dir == 4)
		sdata += 'L';

	map<int, int> hp;
	int cnt = 0;
	if(cdata.at(mdata.at(y + 1).at(x)) != 0)
		hp[pdata.at(y + 1).at(x)] = 1;
	if (cdata.at(mdata.at(y - 1).at(x)) != 0)
		hp[pdata.at(y - 1).at(x)] = 2;
	if (cdata.at(mdata.at(y).at(x + 1)) != 0)
		hp[pdata.at(y).at(x + 1)] = 3;
	if (cdata.at(mdata.at(y).at(x - 1)) != 0)
		hp[pdata.at(y).at(x - 1)] = 4;
	
	for (auto i = hp.rbegin();i != hp.rend();i++) {
		if (i->second == 1) {
			move(mdata, pdata, cdata, x, y + 1, p, 1, sdata);
		}
		else if (i->second == 2) {
			move(mdata, pdata, cdata, x, y - 1, p, 2, sdata);
		}
		else if (i->second == 3) {
			move(mdata, pdata, cdata, x + 1, y, p, 3, sdata);
		}
		else {
			move(mdata, pdata, cdata, x - 1, y, p, 4, sdata);
		}

		//cout << i->second << endl;
		cnt++;
		if (cnt == 1 && dir != 0) break;
	}
}

int main(void) {
	int sx, sy;
	string sdata;

	cin >> sy >> sx;

	vector<int> cdata(52 * 52, 0);
	vector<vector<int>> mdata(52, vector<int>(52));
	vector<vector<int>> pdata(52, vector<int>(52));
	for (int i = 1;i <= 50;i++) {
		for (int j = 1;j <= 50;j++) {
			cin >> mdata.at(i).at(j);
			cdata.at(mdata.at(i).at(j)) = 1;
		}
	}
	for (int i = 1;i <= 50;i++) {
		for (int j = 1;j <= 50;j++) {
			cin >> pdata.at(i).at(j);
		}
	}
	move(mdata,pdata, cdata, sx+1, sy+1,pdata.at(sy+1).at(sx+1),0,sdata);

	cout << rus << endl;
}
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
    char c=getchar();bool f=0;x=0;
    while(!isdigit(c)) f|=c=='-',c=getchar();
    while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
    if(f) x=-x;return x;
}
template<class t> inline void write(t x){
    if(x<0) putchar('-'),write(-x);
    else{if(x>9) write(x/10);putchar('0'+x%10);}
}

const int N=505;
int n,a[N],b[N],c[N][N];

signed main(){
	read(n);
	for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) read(c[i][j]);
	for(int i=1;i<=n;i++) a[i]=c[i][1]-c[1][1];
	for(int i=1;i<=n;i++) b[i]=c[1][i];
	for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) if(a[i]+b[j]!=c[i][j]) return puts("No"),0;
	int ma=*min_element(a+1,a+1+n),mb=*min_element(b+1,b+1+n);
	if(ma+mb<0) return puts("No"),0;
	puts("Yes");
	for(int i=1;i<=n;i++) write(a[i]-ma),putchar(' ');puts("");
	for(int i=1;i<=n;i++) write(b[i]+ma),putchar(' ');
}