//Author: RingweEH
#include <cstdio>
#include <cstring>
#include <algorithm>
#define ll long long
#define db double
using namespace std;
const int L=1<<20;
char buf[L],*p1,*p2;
#define getchar() (p1==p2?(p2=buf+fread(p1=buf,1,L,stdin),p1==p2?EOF:*p1++):*p1++)
int read()
{
    int x=0,w=1; char ch=getchar();
    while ( ch>'9' || ch<'0' ) { if ( ch=='-' ) w=-1; ch=getchar(); }
    while ( ch<='9' && ch>='0' ) x=x*10+ch-'0',ch=getchar();
    return x*w;
}

const int N=510;
int n,a[N],c[N][N],d[N][N];

int main()
{
//freopen( "exam.in","r",stdin );

	memset( a,0x7f,sizeof(a) );
	n=read();
	for ( int i=1; i<=n; i++ )
		for ( int j=1; j<=n; j++ )
		{
			c[i][j]=read(); a[i]=min(a[i],c[i][j]);
			d[i][j]=c[i][j]-c[i][1];
		}

	for ( int i=1; i<=n; i++ )
		for ( int j=1; j<=n; j++ )
			if ( d[i][j]^d[1][j] ) { puts("No"); return 0; }
	puts("Yes");
	for ( int i=1; i<=n; i++ ) printf("%d ",a[i] );
	puts("");
	for ( int i=1; i<=n; i++ ) printf("%d ",c[1][i]-a[1] );
	puts("");

	return 0;
}
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define ALL(v) v.begin(),v.end()
constexpr ll MOD=1000000007;
constexpr ll INF=2e18;

const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int beamwidth = 300;
const double TL=1.9;
double start;

int n=50;
int sx, sy;
VVI t(n,VI(n));
VVI p(n,VI(n));

struct status{
    int x;
    int y;
    int score;
    int eval;
    VI path;
    VI used;
    bool operator<(const status &another) const {return eval < another.eval;};
};

vector<status> search(const status &base){
    vector<status> res;
    REP(i,4){
        int tox=base.x+dx[i];
        int toy=base.y+dy[i];
        if(tox<0||tox>=n||toy<0||toy>=n)
            continue;
        if(base.used[t[tox][toy]])
            continue;
        int anotp=p[tox][toy];
        REP(j,4){
            int toox=tox+dx[j];
            int tooy=toy+dy[j];
            if(toox<0||toox>=n||tooy<0||tooy>=n)
                continue;
            if(t[tox][toy]==t[toox][tooy]){
                anotp=p[toox][tooy];
                break;
            }
        }
        int newscore=base.score+p[tox][toy]-max(0,anotp-p[tox][toy]);
        int dlx=min(tox,49-tox), dly=min(toy,49-toy);
        int neweval=newscore-(3*(dlx+dly)+min(dlx,dly))*100;
        res.push_back((status){tox,toy,newscore,neweval,base.path,base.used});
        res[res.size()-1].used[t[tox][toy]]=1;
        res[res.size()-1].path.push_back(i);
    }
    return res;
}

int main(){
    start=clock();
    cin >> sx >> sy;
    int maxt=0;
    REP(i,n)REP(j,n){
        cin >> t[i][j];
        maxt=max(maxt,t[i][j]);
    }
    REP(i,n)REP(j,n) cin >> p[i][j];
    priority_queue<status> que, backup;
    VI initused(maxt+1,0); initused[t[sx][sy]]=1;
    que.push({sx,sy,p[sx][sy],0,VI(0),initused});
    int maxscore=0; VI ans;
    int cnt=0;
    while(1){
        priority_queue<status> nxtque;
        VVI mxs(n,VI(n,0));
        while(nxtque.size()<beamwidth){
            if(que.empty())
                break;
            if(que.top().score>maxscore){
                maxscore=que.top().score;
                ans=que.top().path;
            }
            vector<status> res=search(que.top());
            for(auto j:res){
                if(mxs[j.x][j.y]<10){
                    mxs[j.x][j.y]++;
                    nxtque.push(j);
                }
            }
            que.pop();
        }
        if(cnt%10==0&&que.size()>=5){
            REP(j,5){
                vector<status> res=search(que.top());
                for(auto j:res){
                    backup.push(j);
                }
                que.pop();
            }
        }
        que=nxtque;
        double tim=(double)(clock()-start)/CLOCKS_PER_SEC/TL;
        if(tim>=1.0)
            break;
        if(que.empty())
            que=backup;
        cnt++;
    }
    string dir="DRUL";
    for(auto i:ans)
        cout << dir[i];
    cout << endl;
    return 0;
}