import java.awt.*;
import java.io.*;
import java.util.*;

public class Abc implements Runnable{
    static Point p[][];
    static int n;
    static char ans[][];
    static boolean vis[][];
    public static void main(String[] args) throws Exception {
//        Scanner sc = new Scanner(System.in);
        new Thread(null,new Abc(),"abc",(1<<26)).start();
    }
    static boolean dfs(int r,int c,int pr,int pc,int sr,int sc){
        if (ans[r][c]!='-')return false;
        ans[r][c]=res(r,c,pr,pc);
        vis[r][c]=true;
        for (int i=0;i<4;i++){
            int newR=dirR[i]+r;
            int newC=dirC[i]+c;
            if (isValid(newR,newC) && !vis[newR][newC] && p[newR][newC].equals(new Point(sr,sc))){
                if (!dfs(newR,newC,r,c,sr,sc))return false;
            }
        }
        return true;
    }
    static int dirR[]={-1,1,0,0};
    static int dirC[]={0,0,1,-1};
    static char chrs[]={'D','U','L','R'};
    static boolean isValid(int r,int c){
        if (r>=0 && c>=0 && c<n && r<n)return true;
        return false;
    }
    static char res(int r,int c,int pr,int pc){
        for (int i=0;i<4;i++){
            if (r==pr+dirR[i] && c==pc+dirC[i]){
                return chrs[i];
            }
        }
        return 'X';
    }
    public void run(){
        FastReader sc=new FastReader();
        n=sc.nextInt();
        p=new Point[n][n];
        vis=new boolean[n][n];
        for (int i=0;i<n;i++){
            for (int j=0;j<n;j++){
                int x=sc.nextInt(),y=sc.nextInt();
                if (x==-1){
                    p[i][j]=new Point(-1,-1);
                }else {
                    p[i][j]=new Point(x-1,y-1);
                }
            }
        }
        ans=new char[n][n];
        for (char ar[]:ans)Arrays.fill(ar,'-');
        for (int i=0;i<n;i++){
            for (int j=0;j<n;j++){
                if (!vis[i][j] && p[i][j].equals(new Point(-1,-1))) {
                    if (p[i][j].equals(new Point(-1, -1)) && i + 1 < n && p[i + 1][j].equals(new Point(-1, -1))) {
                        ans[i][j] = 'D';
                        vis[i][j]=true;
                        ans[i+1][j] = 'U';
                        vis[i+1][j]=true;
                    } else if (j + 1 < n && p[i][j].equals(new Point(-1, -1)) && p[i][j + 1].equals(new Point(-1, -1))) {
                        ans[i][j] = 'R';
                        ans[i][j + 1] = 'L';
                        vis[i][j]=true;
                        vis[i][j+1]=true;
                    } else if(i-1>=0 && p[i-1][j].equals(new Point(-1, -1))){
                        vis[i-1][j]=true;
                        vis[i][j]=true;
                        ans[i][j]='U';
                        ans[i-1][j]='D';
                    }else if (j-1>=0 && p[i][j-1].equals(new Point(-1, -1))){
                        vis[i][j-1]=true;
                        vis[i][j]=true;
                        ans[i][j-1]='R';
                        ans[i][j]='L';
                    }else {
                        System.out.println("INVALID");
                        return;
                    }
                }
//                System.out.print(ans[i][j]);
            }
//            System.out.println();
        }
        for (int i=0;i<n;i++){
            for (int j=0;j<n;j++){
                if (!vis[i][j]){
                    if (!p[p[i][j].x][p[i][j].y].equals(p[i][j])){
                        System.out.println("INVALID");
                        return;
                    }else if (vis[p[i][j].x][p[i][j].y]){
                        System.out.println("INVALID");
                        return;
                    }else {
                        if (!dfs(p[i][j].x,p[i][j].y,p[i][j].x,p[i][j].y,p[i][j].x,p[i][j].y)){
//                            System.out.println(p[i][j]);
                            System.out.println("INVALID");
                            return;
                        }
                    }
                }
            }
        }
        StringBuilder sb=new StringBuilder();
        sb.append("VALID\n");
        for (int i=0;i<n;i++){
            for (int j=0;j<n;j++){
                sb.append(ans[i][j]);
            }
            sb.append("\n");
        }
        System.out.print(sb);
    }
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


import java.awt.*;
import java.io.*;
import java.util.*;

public class Abc {
    static Point p[][];
    static int n;
    static char ans[][];
    static boolean vis[][];
    public static void main(String[] args) throws Exception {
//        Scanner sc = new Scanner(System.in);
        FastReader sc=new FastReader();
        n=sc.nextInt();
        p=new Point[n][n];
        vis=new boolean[n][n];
        for (int i=0;i<n;i++){
            for (int j=0;j<n;j++){
                int x=sc.nextInt(),y=sc.nextInt();
                if (x==-1){
                    p[i][j]=new Point(-1,-1);
                }else {
                    p[i][j]=new Point(x-1,y-1);
                }
            }
        }
        ans=new char[n][n];
        for (char ar[]:ans)Arrays.fill(ar,'-');
        for (int i=0;i<n;i++){
            for (int j=0;j<n;j++){
                if (p[i][j].equals(new Point(-1,-1)) && !vis[i][j]){
                    boolean f=false;
                    for (int k=0;k<4;k++){
                        int newR=i+dirR[k];
                        int newC=j+dirC[k];
                        if (isValid(newR,newC) && !vis[newR][newC]){
                            f=true;
                            if (cirdfs(newR,newC,i,j,i,j)==-1){
                                System.out.println("INVALID");
                                return;
                            }
                            break;
                        }
                    }
                    if (!f){
                        System.out.println("INVALID");
                        return;
                    }
                }
            }
        }
        for (int i=0;i<n;i++){
            for (int j=0;j<n;j++){
                if (!vis[i][j]){
                    if (vis[p[i][j].x][p[i][j].y]){
                        System.out.println("INVALID");
                        return;
                    }else {
                        if (!dfs(p[i][j].x,p[i][j].y,p[i][j].x,p[i][j].y,p[i][j].x,p[i][j].y)){
                            System.out.println("INVALID");
                            return;
                        }
                    }
                }
            }
        }
        StringBuilder sb=new StringBuilder();
        sb.append("VALID\n");
        for (int i=0;i<n;i++){
            for (int j=0;j<n;j++){
                sb.append(ans[i][j]);
            }
            sb.append("\n");
        }
        System.out.print(sb);
    }
    static int cirdfs(int r,int c,int pr,int pc,int sr,int sc){
//        System.out.println(r+" "+c);
        vis[r][c]=true;
        if (ans[r][c]!='-')return -1;
        ans[r][c]=res(r,c,pr,pc);
        if (r==sr && c==sc)return 0;
        int f=-1;
        for (int i=0;i<4;i++){
            int newR=dirR[i]+r;
            int newC=dirC[i]+c;
            if (isValid(newR,newC) && (newR!=pr || newC!=pc) && p[newR][newC].equals(new Point(-1,-1))){
                int x=cirdfs(newR,newC,r,c,sr,sc);
                f=1;
                if (x!=1)return x;
            }
        }
        return f;
    }
    static boolean dfs(int r,int c,int pr,int pc,int sr,int sc){
        if (ans[r][c]!='-')return false;
        ans[r][c]=res(r,c,pr,pc);
        vis[r][c]=true;
        for (int i=0;i<4;i++){
            int newR=dirR[i]+r;
            int newC=dirC[i]+c;
            if (isValid(newR,newC) && (newC!=pc || newR!=pr) && p[newR][newC].equals(new Point(sr,sc))){
                if (!dfs(newR,newC,r,c,sr,sc))return false;
            }
        }
        return true;
    }
    static int dirR[]={-1,1,0,0};
    static int dirC[]={0,0,1,-1};
    static char chrs[]={'D','U','L','R'};
    static boolean isValid(int r,int c){
        if (r>=0 && c>=0 && c<n && r<n)return true;
        return false;
    }
    static char res(int r,int c,int pr,int pc){
        for (int i=0;i<4;i++){
            if (r==pr+dirR[i] && c==pc+dirC[i]){
                return chrs[i];
            }
        }
        return 'X';
    }
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


import java.awt.*;
import java.io.*;
import java.util.*;

public class Abc implements Runnable{
    static Point p[][];
    static int n;
    static char ans[][];
    static boolean vis[][];
    public static void main(String[] args) throws Exception {
//        Scanner sc = new Scanner(System.in);
        new Thread(null,new Abc(),"main",1<<26).start();
    }
    static boolean dfs(int r,int c,int pr,int pc,int sr,int sc){
        vis[r][c]=true;
        if (ans[r][c]!='-')return false;
        ans[r][c]=res(r,c,pr,pc);
        for (int i=0;i<4;i++){
            int newR=dirR[i]+r;
            int newC=dirC[i]+c;
            if (isValid(newR,newC) && !vis[newR][newC] && p[newR][newC].equals(new Point(sr,sc))){
                if (!dfs(newR,newC,r,c,sr,sc))return false;
            }
        }
        return true;
    }
    static int dirR[]={-1,1,0,0};
    static int dirC[]={0,0,1,-1};
    static char chrs[]={'D','U','L','R'};
    static boolean isValid(int r,int c){
        if (r>=0 && c>=0 && c<n && r<n)return true;
        return false;
    }
    static char res(int r,int c,int pr,int pc){
        for (int i=0;i<4;i++){
            if (r==pr+dirR[i] && c==pc+dirC[i]){
                return chrs[i];
            }
        }
        return 'X';
    }
    public void run(){
        FastReader sc=new FastReader();
        n=sc.nextInt();
        p=new Point[n][n];
        vis=new boolean[n][n];
        for (int i=0;i<n;i++){
            for (int j=0;j<n;j++){
                int x=sc.nextInt(),y=sc.nextInt();
                if (x==-1){
                    p[i][j]=new Point(-1,-1);
                }else {
                    p[i][j]=new Point(x-1,y-1);
                }
            }
        }
        ans=new char[n][n];
        for (char ar[]:ans)Arrays.fill(ar,'-');
        for (int i=0;i<n;i++){
            for (int j=0;j<n;j++){
                if (!vis[i][j] && p[i][j].equals(new Point(-1,-1))) {
                    if (p[i][j].equals(new Point(-1, -1)) && i + 1 < n && p[i + 1][j].equals(new Point(-1, -1))) {
                        ans[i][j] = 'D';
                        vis[i][j]=true;
                        ans[i+1][j] = 'U';
                        vis[i+1][j]=true;
                    } else if (j + 1 < n && p[i][j].equals(new Point(-1, -1)) && p[i][j + 1].equals(new Point(-1, -1))) {
                        ans[i][j] = 'R';
                        ans[i][j + 1] = 'L';
                        vis[i][j]=true;
                        vis[i][j+1]=true;
                    } else if(i-1>=0 && p[i-1][j].equals(new Point(-1, -1))){
                        vis[i-1][j]=true;
                        vis[i][j]=true;
                        ans[i][j]='U';
                        ans[i-1][j]='D';
                    }else if (j-1>=0 && p[i][j-1].equals(new Point(-1, -1))){
                        vis[i][j-1]=true;
                        vis[i][j]=true;
                        ans[i][j-1]='R';
                        ans[i][j]='L';
                    }else {
                        System.out.println("INVALID");
                        return;
                    }
                }
//                System.out.print(ans[i][j]);
            }
//            System.out.println();
        }
        for (int i=0;i<n;i++){
            for (int j=0;j<n;j++){
                if (!vis[i][j]){
                    if (!p[p[i][j].x][p[i][j].y].equals(p[i][j])){
                        System.out.println("INVALID");
                        return;
                    }else if (vis[p[i][j].x][p[i][j].y]){
                        System.out.println("INVALID");
                        return;
                    }else {
                        if (!dfs(p[i][j].x,p[i][j].y,p[i][j].x,p[i][j].y,p[i][j].x,p[i][j].y)){
//                            System.out.println(p[i][j]);
                            System.out.println("INVALID");
                            return;
                        }
                    }
                }
            }
        }
        StringBuilder sb=new StringBuilder();
        sb.append("VALID\n");
        for (int i=0;i<n;i++){
            for (int j=0;j<n;j++){
                sb.append(ans[i][j]);
            }
            sb.append("\n");
        }
        System.out.print(sb);
    }
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


import java.awt.*;
import java.io.*;
import java.util.*;

public class Abc {
    static int n;
    static Point arr[][];
    static char ans[][];
    public static void main(String[] args) throws Exception {
//        Scanner sc = new Scanner(System.in);
        FastReader sc=new FastReader();
        n=sc.nextInt();
        arr=new Point[n][n];
        for (int i=0;i<n;i++) {
            for (int j = 0; j < n; j++) {
                int x=sc.nextInt(),y=sc.nextInt();
                if (x==-1){
                    arr[i][j]=new Point(-1,-1);
                    continue;
                }
                arr[i][j]=new Point(x-1,y-1);
            }
        }
        ans=new char[n][n];
        for (char ar[]:ans){
            Arrays.fill(ar,'-');
        }
        for (int i=0;i<n;i++){
            for (int j=0;j<n;j++){
                if (arr[i][j].equals(new Point(-1,-1))){
                    if (ans[i][j]!='-')continue;
                    boolean f=false;
                    for (int k=0;k<4;k++){
                        int newR=i+dirX[k];
                        int newC=j+dirY[k];
                        if (isValid(newR,newC) && arr[newR][newR].equals(new Point(-1,-1))){
                            f=true;
                            if (!dfs(newR,newC,arr[i][j],i,j,true)){
                                System.out.println("INVALID");
                                return;
                            }
                            break;
                        }
                    }
                    if (!f)ans[i][j]='X';
                }else {
                    if (ans[arr[i][j].x][arr[i][j].y]!='-')continue;
                    if (!dfs(arr[i][j].x,arr[i][j].y,arr[i][j],arr[i][j].x,arr[i][j].y,false)){
                        System.out.println("INVALID");
                        return;
                    }
                }
            }
        }
        StringBuilder sb=new StringBuilder();
        sb.append("VALID\n");
        for(int i=0;i<n;i++){
            for (int j=0;j<n;j++){
                sb.append(ans[i][j]);
            }
            sb.append("\n");
        }
        System.out.print(sb);
    }
    static int dirX[]={-1,1,0,0};
    static int dirY[]={0,0,-1,1};
    static char cc[]={'U','D','L','R'};
    static boolean dfs(int r,int c,Point ch,int pr,int pc,boolean cir){
        if (!cir && ans[r][c]!='-'){
            return false;
        }else if (cir && ans[r][c]=='-'){
            if (!arr[r][c].equals(new Point(-1,-1)))return false;
            ans[r][c] = res(r, c, pr, pc);
        }else if (cir && ans[r][c]!='-')return true;
        else if (!cir && ans[r][c]=='-'){
            ans[r][c]=res(r,c,pr,pc);
//            System.out.println(r+" "+c+" "+pr+" "+pc);
        }
        for (int i=0;i<4;i++){
            int newR=r+dirX[i];
            int newC=c+dirY[i];
            if (isValid(newR,newC)){
                if(arr[newR][newC].equals(ch) && (pr!=newR || pc!=newC)){
//                    System.out.println(r+" "+c);
                    if (!dfs(newR,newC,ch,r,c,cir)){
                        return false;
                    }
                }
            }
        }
        return true;
    }
    static char res(int r,int c,int pr,int pc){
        for (int i=0;i<4;i++){
            if (r+dirX[i]==pr && c+dirY[i]==pc){
                return cc[i];
            }
        }
        return 'X';
    }
    static boolean isValid(int r,int c){
        if (r>=0 && r<n && c>=0 && c<n)return true;
        return false;
    }
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


import java.awt.*;
import java.io.*;
import java.util.*;

public class Abc {
    static Point p[][];
    static int n;
    static char ans[][];
    static boolean vis[][];
    public static void main(String[] args) throws Exception {
//        Scanner sc = new Scanner(System.in);
        FastReader sc=new FastReader();
        n=sc.nextInt();
        p=new Point[n][n];
        vis=new boolean[n][n];
        for (int i=0;i<n;i++){
            for (int j=0;j<n;j++){
                int x=sc.nextInt(),y=sc.nextInt();
                if (x==-1){
                    p[i][j]=new Point(-1,-1);
                }else {
                    p[i][j]=new Point(x-1,y-1);
                }
            }
        }
        ans=new char[n][n];
        for (char ar[]:ans)Arrays.fill(ar,'-');
        for (int i=0;i<n;i++){
            for (int j=0;j<n;j++){
                boolean f=false;
                if (ans[i][j]=='-') {
                    if (j + 1 < n && p[i][j].equals(new Point(-1, -1)) && p[i][j + 1].equals(new Point(-1, -1))) {
                        ans[i][j] = 'R';
                        ans[i][j + 1] = 'L';
                        vis[i][j]=true;
                        vis[i][j+1]=true;
                        f=true;
//                        System.out.print(ans[i][j]+""+ans[i][j+1]);
                        j++;
                    } else if (p[i][j].equals(new Point(-1, -1))) {
                        ans[i][j] = 'D';
                        vis[i][j]=true;
                        if (i + 1 < n && p[i + 1][j].equals(new Point(-1, -1))) {
                            ans[i+1][j] = 'U';
                            vis[i+1][j]=true;
                        } else {
                            System.out.println("INVALID");
                            return;
                        }
                    }
                }
//                if (!f) {
//                    System.out.print(ans[i][j]);
//                }
            }
//            System.out.println();
        }
        for (int i=0;i<n;i++){
            for (int j=0;j<n;j++){
                if (!vis[i][j]){
                    if (!p[p[i][j].x][p[i][j].y].equals(p[i][j])){
                        System.out.println("INVALID");
                        return;
                    }else if (vis[p[i][j].x][p[i][j].y]){
                        System.out.println("INVALID");
                        return;
                    }else {
                        if (!dfs(p[i][j].x,p[i][j].y,p[i][j].x,p[i][j].y,p[i][j].x,p[i][j].y)){
                            System.out.println("INVALID");
                            return;
                        }
                    }
                }
            }
        }
        StringBuilder sb=new StringBuilder();
        sb.append("VALID\n");
        for (int i=0;i<n;i++){
            for (int j=0;j<n;j++){
                sb.append(ans[i][j]);
            }
            sb.append("\n");
        }
        System.out.print(sb);
    }
    static boolean dfs(int r,int c,int pr,int pc,int sr,int sc){
        if (ans[r][c]!='-')return false;
        ans[r][c]=res(r,c,pr,pc);
        vis[r][c]=true;
        for (int i=0;i<4;i++){
            int newR=dirR[i]+r;
            int newC=dirC[i]+c;
            if (isValid(newR,newC) && (newC!=pc || newR!=pr) && p[newR][newC].equals(new Point(sr,sc))){
                if (!dfs(newR,newC,r,c,sr,sc))return false;
            }
        }
        return true;
    }
    static int dirR[]={-1,1,0,0};
    static int dirC[]={0,0,1,-1};
    static char chrs[]={'D','U','L','R'};
    static boolean isValid(int r,int c){
        if (r>=0 && c>=0 && c<n && r<n)return true;
        return false;
    }
    static char res(int r,int c,int pr,int pc){
        for (int i=0;i<4;i++){
            if (r==pr+dirR[i] && c==pc+dirC[i]){
                return chrs[i];
            }
        }
        return 'X';
    }
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


import java.awt.*;
import java.io.*;
import java.util.*;

public class CandidateCode {
    public static void main(String[] args) throws Exception {
//        Scanner sc = new Scanner(System.in);
        FastReader sc = new FastReader();
        int t=sc.nextInt();
        StringBuilder sb=new StringBuilder();
        while (t-->0){
            int n=sc.nextInt();
            StringBuilder s=new StringBuilder(sc.next());
            String ans=s.toString();
            int ind=1;
            for (int k=2;k<=n;k++){
                if ((n-(k-1))%2==0){
                    String y=s.substring(k-1)+s.substring(0,k-1);
//                    System.out.println(s);
                    if (y.compareTo(ans)<0){
                        ans=y;
                        ind=k;
                    }
                }else {
                    StringBuilder tmp=new StringBuilder(s.substring(0,k-1));
                    String y=s.substring(k-1)+tmp.reverse();
                    if (y.compareTo(ans)<0){
                        ans=y;
                        ind=k;
                    }
                }
            }
            sb.append(ans+"\n");
            sb.append(ind+"\n");
        }
        System.out.print(sb);
    }
    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class CodeCraft20_D {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer(br.readLine());
    int n = Integer.parseInt(st.nextToken());
    int[][][] matrix = new int[n][n][2];
    for (int i = 0; i < n; i++) {
      st = new StringTokenizer(br.readLine());
      for (int j = 0; j < n; j++) {
        matrix[i][j][0] = Integer.parseInt(st.nextToken());
        matrix[i][j][1] = Integer.parseInt(st.nextToken());
      }
    }

    char[][] dirs = new char[n][n];

    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (dirs[i][j] > 'A') continue;
        if (matrix[i][j][0] == i + 1 && matrix[i][j][1] == j + 1) {
          dfs(matrix, dirs, i, j, i, j);
          dirs[i][j] = 'X';
        } else if (matrix[i][j][0] == -1 && matrix[i][j][1] == -1) {
          int x = -1;
          int y = -1;

          if (i - 1 >= 0) {
            if (matrix[i - 1][j][0] == -1 && matrix[i - 1][j][1] == -1) {
              dirs[i - 1][j] = 'D';
              dirs[i][j] = 'U';
              x = i - 1;
              y = j;
            }
          }
          if (j - 1 >= 0) {
            if (matrix[i][j - 1][0] == -1 && matrix[i][j - 1][1] == -1) {
              dirs[i][j - 1] = 'R';
              dirs[i][j] = 'L';
              x = i;
              y = j - 1;
            }
          }
          if (i + 1 < matrix.length) {
            if (matrix[i + 1][j][0] == -1 && matrix[i + 1][j][1] == -1) {
              dirs[i + 1][j] = 'U';
              dirs[i][j] = 'D';
              x = i + 1;
              y = j;
            }
          }
          if (j + 1 < matrix.length) {
            if (matrix[i][j + 1][0] == -1 && matrix[i][j + 1][1] == -1) {
              dirs[i][j + 1] = 'L';
              dirs[i][j] = 'R';
              x = i;
              y = j + 1;
            }
          }
          if (x != -1) {
            dfs(matrix, dirs, i, j, -2, -2);
            dfs(matrix, dirs, x, y, -2, -2);
          }
        }
      }
    }

    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (dirs[i][j] < 'A') {
          System.out.println(i);
          System.out.println(j);
          System.out.println("INVALID");
          return;
        }
      }
    }

    System.out.println("VALID");

    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        System.out.print(dirs[i][j]);
      }
      System.out.println();
    }
  }

  private static void dfs(int[][][] matrix, char[][] dirs, int i, int j, int startI, int startJ) {
    if (i - 1 >= 0) {
      if (matrix[i - 1][j][0] == startI + 1 && matrix[i - 1][j][1] == startJ + 1) {
        if (dirs[i - 1][j] < 'A') {
          dirs[i - 1][j] = 'D';
          dfs(matrix, dirs, i - 1, j, startI, startJ);
        }
      }
    }
    if (j - 1 >= 0) {
      if (matrix[i][j - 1][0] == startI + 1 && matrix[i][j - 1][1] == startJ + 1) {
        if (dirs[i][j - 1] < 'A') {
          dirs[i][j - 1] = 'R';
          dfs(matrix, dirs, i, j - 1, startI, startJ);
        }
      }
    }
    if (i + 1 < matrix.length) {
      if (matrix[i + 1][j][0] == startI + 1 && matrix[i + 1][j][1] == startJ + 1) {
        if (dirs[i + 1][j] < 'A') {
          dirs[i + 1][j] = 'U';
          dfs(matrix, dirs, i + 1, j, startI, startJ);
        }
      }
    }
    if (j + 1 < matrix.length) {
      if (matrix[i][j + 1][0] == startI + 1 && matrix[i][j + 1][1] == startJ + 1) {
        if (dirs[i][j + 1] < 'A') {
          dirs[i][j + 1] = 'L';
          dfs(matrix, dirs, i, j + 1, startI, startJ);
        }
      }
    }
  }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class CodeCraft20_D {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer(br.readLine());
    int n = Integer.parseInt(st.nextToken());
    int[][][] matrix = new int[n][n][2];
    for (int i = 0; i < n; i++) {
      st = new StringTokenizer(br.readLine());
      for (int j = 0; j < n; j++) {
        matrix[i][j][0] = Integer.parseInt(st.nextToken());
        matrix[i][j][1] = Integer.parseInt(st.nextToken());
      }
    }

    char[][] dirs = new char[n][n];

    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (dirs[i][j] > 'A') continue;
        if (matrix[i][j][0] == i + 1 && matrix[i][j][1] == j + 1) {
          dfs(matrix, dirs, i, j, i, j);
          dirs[i][j] = 'X';
        } else if (matrix[i][j][0] == -1 && matrix[i][j][1] == -1) {
          int x = -1;
          int y = -1;

          if (i - 1 >= 0) {
            if (matrix[i - 1][j][0] == -1 && matrix[i - 1][j][1] == -1) {
              dirs[i - 1][j] = 'D';
              dirs[i][j] = 'U';
              x = i - 1;
              y = j;
            }
          }
          if (j - 1 >= 0) {
            if (matrix[i][j - 1][0] == -1 && matrix[i][j - 1][1] == -1) {
              dirs[i][j - 1] = 'R';
              dirs[i][j] = 'L';
              x = i;
              y = j - 1;
            }
          }
          if (i + 1 < matrix.length) {
            if (matrix[i + 1][j][0] == -1 && matrix[i + 1][j][1] == -1) {
              dirs[i + 1][j] = 'U';
              dirs[i][j] = 'D';
              x = i + 1;
              y = j;
            }
          }
          if (j + 1 < matrix.length) {
            if (matrix[i][j + 1][0] == -1 && matrix[i][j + 1][1] == -1) {
              dirs[i][j + 1] = 'L';
              dirs[i][j] = 'R';
              x = i;
              y = j + 1;
            }
          }
          if (x!=-1) {
            dfs(matrix, dirs, i, j, -2, -2);
            dfs(matrix, dirs, x, y, -2, -2);
          }
        }
      }
    }

    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (dirs[i][j] < 'A') {
          System.out.println("INVALID");
          return;
        }
      }
    }

    System.out.println("VALID");

    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        System.out.print(dirs[i][j] + " ");
      }
      System.out.println();
    }
  }

  private static void dfs(int[][][] matrix, char[][] dirs, int i, int j, int startI, int startJ) {
    if (dirs[i][j] > 0) return;
    if (i - 1 >= 0) {
      if (matrix[i - 1][j][0] == startI + 1 && matrix[i - 1][j][1] == startJ + 1) {
        dirs[i - 1][j] = 'D';
        dfs(matrix, dirs, i - 1, j, startI, startJ);
      }
    }
    if (j - 1 >= 0) {
      if (matrix[i][j - 1][0] == startI + 1 && matrix[i][j - 1][1] == startJ + 1) {
        dfs(matrix, dirs, i, j - 1, startI, startJ);
        dirs[i][j - 1] = 'R';
      }
    }
    if (i + 1 < matrix.length) {
      if (matrix[i + 1][j][0] == startI + 1 && matrix[i + 1][j][1] == startJ + 1) {
        dirs[i + 1][j] = 'U';
        dfs(matrix, dirs, i + 1, j, startI, startJ);
      }
    }
    if (j + 1 < matrix.length) {
      if (matrix[i][j + 1][0] == startI + 1 && matrix[i][j + 1][1] == startJ + 1) {
        dirs[i][j + 1] = 'L';
        dfs(matrix, dirs, i, j + 1, startI, startJ);
      }
    }
  }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class CodeCraft20_D {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer(br.readLine());
    int n = Integer.parseInt(st.nextToken());
    int[][][] matrix = new int[n][n][2];
    for (int i = 0; i < n; i++) {
      st = new StringTokenizer(br.readLine());
      for (int j = 0; j < n; j++) {
        matrix[i][j][0] = Integer.parseInt(st.nextToken());
        matrix[i][j][1] = Integer.parseInt(st.nextToken());
      }
    }

    char[][] dirs = new char[n][n];

    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (dirs[i][j] > 'A') continue;
        if (matrix[i][j][0] == i + 1 && matrix[i][j][1] == j + 1) {
          dfs(matrix, dirs, i, j, i, j);
          dirs[i][j] = 'X';
        } else if (matrix[i][j][0] == -1 && matrix[i][j][1] == -1) {
          int x = -1;
          int y = -1;

          if (i - 1 >= 0) {
            if (matrix[i - 1][j][0] == -1 && matrix[i - 1][j][1] == -1) {
              dirs[i - 1][j] = 'D';
              dirs[i][j] = 'U';
              x = i - 1;
              y = j;
            }
          }
          if (j - 1 >= 0) {
            if (matrix[i][j - 1][0] == -1 && matrix[i][j - 1][1] == -1) {
              dirs[i][j - 1] = 'R';
              dirs[i][j] = 'L';
              x = i;
              y = j - 1;
            }
          }
          if (i + 1 < matrix.length) {
            if (matrix[i + 1][j][0] == -1 && matrix[i + 1][j][1] == -1) {
              dirs[i + 1][j] = 'U';
              dirs[i][j] = 'D';
              x = i + 1;
              y = j;
            }
          }
          if (j + 1 < matrix.length) {
            if (matrix[i][j + 1][0] == -1 && matrix[i][j + 1][1] == -1) {
              dirs[i][j + 1] = 'L';
              dirs[i][j] = 'R';
              x = i;
              y = j + 1;
            }
          }
          if (x!=-1) {
            dfs(matrix, dirs, i, j, -2, -2);
            dfs(matrix, dirs, x, y, -2, -2);
          }
        }
      }
    }

    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (dirs[i][j] < 'A') {
          System.out.println("INVALID");
          return;
        }
      }
    }

    System.out.println("VALID");

    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        System.out.print(dirs[i][j]);
      }
      System.out.println();
    }
  }

  private static void dfs(int[][][] matrix, char[][] dirs, int i, int j, int startI, int startJ) {
    if (dirs[i][j] > 0) return;
    if (i - 1 >= 0) {
      if (matrix[i - 1][j][0] == startI + 1 && matrix[i - 1][j][1] == startJ + 1) {
        dirs[i - 1][j] = 'D';
        dfs(matrix, dirs, i - 1, j, startI, startJ);
      }
    }
    if (j - 1 >= 0) {
      if (matrix[i][j - 1][0] == startI + 1 && matrix[i][j - 1][1] == startJ + 1) {
        dfs(matrix, dirs, i, j - 1, startI, startJ);
        dirs[i][j - 1] = 'R';
      }
    }
    if (i + 1 < matrix.length) {
      if (matrix[i + 1][j][0] == startI + 1 && matrix[i + 1][j][1] == startJ + 1) {
        dirs[i + 1][j] = 'U';
        dfs(matrix, dirs, i + 1, j, startI, startJ);
      }
    }
    if (j + 1 < matrix.length) {
      if (matrix[i][j + 1][0] == startI + 1 && matrix[i][j + 1][1] == startJ + 1) {
        dirs[i][j + 1] = 'L';
        dfs(matrix, dirs, i, j + 1, startI, startJ);
      }
    }
  }
}


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.StringTokenizer;

public class CodeCraft20_D {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer(br.readLine());
    BufferedWriter log = new BufferedWriter(new OutputStreamWriter(System.out));

    int n = Integer.parseInt(st.nextToken());
    int[][][] matrix = new int[n][n][2];
    for (int i = 0; i < n; i++) {
      st = new StringTokenizer(br.readLine());
      for (int j = 0; j < n; j++) {
        matrix[i][j][0] = Integer.parseInt(st.nextToken());
        matrix[i][j][1] = Integer.parseInt(st.nextToken());
      }
    }

    char[][] dirs = new char[n][n];

    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (dirs[i][j] > 'A') continue;
        if (matrix[i][j][0] == i + 1 && matrix[i][j][1] == j + 1) {
          dfs(matrix, dirs, i, j, i, j);
          dirs[i][j] = 'X';
        } else if (matrix[i][j][0] == -1 && matrix[i][j][1] == -1) {
          int x = -1;
          int y = -1;

          if (i - 1 >= 0) {
            if (matrix[i - 1][j][0] == -1 && matrix[i - 1][j][1] == -1) {
              dirs[i - 1][j] = 'D';
              dirs[i][j] = 'U';
              x = i - 1;
              y = j;
            }
          }
          if (j - 1 >= 0) {
            if (matrix[i][j - 1][0] == -1 && matrix[i][j - 1][1] == -1) {
              dirs[i][j - 1] = 'R';
              dirs[i][j] = 'L';
              x = i;
              y = j - 1;
            }
          }
          if (i + 1 < matrix.length) {
            if (matrix[i + 1][j][0] == -1 && matrix[i + 1][j][1] == -1) {
              dirs[i + 1][j] = 'U';
              dirs[i][j] = 'D';
              x = i + 1;
              y = j;
            }
          }
          if (j + 1 < matrix.length) {
            if (matrix[i][j + 1][0] == -1 && matrix[i][j + 1][1] == -1) {
              dirs[i][j + 1] = 'L';
              dirs[i][j] = 'R';
              x = i;
              y = j + 1;
            }
          }
          if (x != -1) {
            dfs(matrix, dirs, i, j, -2, -2);
            dfs(matrix, dirs, x, y, -2, -2);
          }
        }
      }
    }

    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (dirs[i][j] < 'A') {
          System.out.println("INVALID");
          return;
        }
      }
    }

    log.write("VALID\n");

    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        log.write(dirs[i][j]);
      }
      log.write("\n");
    }
    log.flush();
  }

  private static void dfs(int[][][] matrix, char[][] dirs, int i, int j, int startI, int startJ) {
    if (i - 1 >= 0) {
      if (matrix[i - 1][j][0] == startI + 1 && matrix[i - 1][j][1] == startJ + 1) {
        if (dirs[i - 1][j] < 'A') {
          dirs[i - 1][j] = 'D';
          dfs(matrix, dirs, i - 1, j, startI, startJ);
        }
      }
    }
    if (j - 1 >= 0) {
      if (matrix[i][j - 1][0] == startI + 1 && matrix[i][j - 1][1] == startJ + 1) {
        if (dirs[i][j - 1] < 'A') {
          dirs[i][j - 1] = 'R';
          dfs(matrix, dirs, i, j - 1, startI, startJ);
        }
      }
    }
    if (i + 1 < matrix.length) {
      if (matrix[i + 1][j][0] == startI + 1 && matrix[i + 1][j][1] == startJ + 1) {
        if (dirs[i + 1][j] < 'A') {
          dirs[i + 1][j] = 'U';
          dfs(matrix, dirs, i + 1, j, startI, startJ);
        }
      }
    }
    if (j + 1 < matrix.length) {
      if (matrix[i][j + 1][0] == startI + 1 && matrix[i][j + 1][1] == startJ + 1) {
        if (dirs[i][j + 1] < 'A') {
          dirs[i][j + 1] = 'L';
          dfs(matrix, dirs, i, j + 1, startI, startJ);
        }
      }
    }
  }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class CodeCraft20_D {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer(br.readLine());
    int n = Integer.parseInt(st.nextToken());
    int[][][] matrix = new int[n][n][2];
    for (int i = 0; i < n; i++) {
      st = new StringTokenizer(br.readLine());
      for (int j = 0; j < n; j++) {
        matrix[i][j][0] = Integer.parseInt(st.nextToken());
        matrix[i][j][1] = Integer.parseInt(st.nextToken());
      }
    }

    char[][] dirs = new char[n][n];

    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (dirs[i][j] > 'A') continue;
        if (matrix[i][j][0] == i + 1 && matrix[i][j][1] == j + 1) {
          dfs(matrix, dirs, i, j, i, j);
          dirs[i][j] = 'X';
        } else if (matrix[i][j][0] == -1 && matrix[i][j][1] == -1) {
          int x = -1;
          int y = -1;

          if (i - 1 >= 0) {
            if (matrix[i - 1][j][0] == -1 && matrix[i - 1][j][1] == -1) {
              dirs[i - 1][j] = 'D';
              dirs[i][j] = 'U';
              x = i - 1;
              y = j;
            }
          }
          if (j - 1 >= 0) {
            if (matrix[i][j - 1][0] == -1 && matrix[i][j - 1][1] == -1) {
              dirs[i][j - 1] = 'R';
              dirs[i][j] = 'L';
              x = i;
              y = j - 1;
            }
          }
          if (i + 1 < matrix.length) {
            if (matrix[i + 1][j][0] == -1 && matrix[i + 1][j][1] == -1) {
              dirs[i + 1][j] = 'U';
              dirs[i][j] = 'D';
              x = i + 1;
              y = j;
            }
          }
          if (j + 1 < matrix.length) {
            if (matrix[i][j + 1][0] == -1 && matrix[i][j + 1][1] == -1) {
              dirs[i][j + 1] = 'L';
              dirs[i][j] = 'R';
              x = i;
              y = j + 1;
            }
          }
          if (x != -1) {
            dfs(matrix, dirs, i, j, -2, -2);
            dfs(matrix, dirs, x, y, -2, -2);
          }
        }
      }
    }

    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (dirs[i][j] < 'A') {
          System.out.println("INVALID");
          return;
        }
      }
    }

    System.out.println("VALID");

    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        System.out.print(dirs[i][j]);
      }
      System.out.println();
    }
  }

  private static void dfs(int[][][] matrix, char[][] dirs, int i, int j, int startI, int startJ) {
    if (i - 1 >= 0) {
      if (matrix[i - 1][j][0] == startI + 1 && matrix[i - 1][j][1] == startJ + 1) {
        if (dirs[i - 1][j] < 'A') {
          dirs[i - 1][j] = 'D';
          dfs(matrix, dirs, i - 1, j, startI, startJ);
        }
      }
    }
    if (j - 1 >= 0) {
      if (matrix[i][j - 1][0] == startI + 1 && matrix[i][j - 1][1] == startJ + 1) {
        if (dirs[i][j - 1] < 'A') {
          dirs[i][j - 1] = 'R';
          dfs(matrix, dirs, i, j - 1, startI, startJ);
        }
      }
    }
    if (i + 1 < matrix.length) {
      if (matrix[i + 1][j][0] == startI + 1 && matrix[i + 1][j][1] == startJ + 1) {
        if (dirs[i + 1][j] < 'A') {
          dirs[i + 1][j] = 'U';
          dfs(matrix, dirs, i + 1, j, startI, startJ);
        }
      }
    }
    if (j + 1 < matrix.length) {
      if (matrix[i][j + 1][0] == startI + 1 && matrix[i][j + 1][1] == startJ + 1) {
        if (dirs[i][j + 1] < 'A') {
          dirs[i][j + 1] = 'L';
          dfs(matrix, dirs, i, j + 1, startI, startJ);
        }
      }
    }
  }
}


import java.util.*;
import java.io.*;
import java.text.*;
public class Main{
    //SOLUTION BEGIN
    //Into the Hardware Mode
    int[][] D = new int[][]{
            {-1, 0},
            {1, 0},
            {0, -1},
            {0, 1}
    };
    void pre() throws Exception{}
    void solve(int TC)throws Exception {
        int n = ni();
        int[][][] g = new int[n][n][2];
        char[][] ans = new char[n][n];
        Queue<Pos> q = new ArrayDeque<>();
        for(int i = 0; i< n; i++){
            for(int j = 0; j< n; j++){
                g[i][j] = new int[]{ni(), ni()};
                if(g[i][j][0] != -1 && g[i][j][1] != -1){
                    g[i][j][0]--;g[i][j][1]--;
                }
                ans[i][j] = ' ';
                if(g[i][j][0] == i && g[i][j][1] == j){
                    ans[i][j] = 'X';
                    q.add(new Pos(i, j));
                }
            }
        }
        char[] f = new char[]{'D', 'U', 'R', 'L'};
        while(!q.isEmpty()){
            Pos p = q.poll();
            int c = 0;
            for(int[] d:D){
                int xx = p.x+d[0], yy = p.y+d[1];
                char ch = f[c];
                c++;
                if(Math.min(xx, yy) < 0 || Math.max(xx, yy) >= n || g[xx][yy][0] != g[p.x][p.y][0] || g[xx][yy][1] != g[p.x][p.y][1] || ans[xx][yy] != ' ')continue;
                ans[xx][yy] = ch;
                q.add(new Pos(xx, yy));
            }
        }
        boolean valid = true;
        for(int i = 0; i< n; i++){
            for(int j = 0; j< n; j++){
                if(g[i][j][0] == -1 && g[i][j][1] == -1){
                    int c = 0, cnt = 0;
                    for(int[] d:D){
                        int ii = i+d[0], jj = j+d[1];char ch = f[cnt];
                        cnt++;
                        if(Math.min(ii, jj) < 0 || Math.max(ii, jj) >= n)continue;
                        if(g[ii][jj][0] == -1 && g[ii][jj][1] == -1){
                            ans[ii][jj] = ch;
                            c++;
                            ans[i][j] = op(ch);
                            break;
                        }
                    }
                    if(c == 0)valid = false;
                }
            }
        }
        if(!valid)pn("INVALID");
        else{
            pn("VALID");
            for(char[] cc:ans){
                for(char c:cc)p(c);pn("");
            }
        }
    }
    char op(char ch){
        switch (ch){
            case 'R':return 'L';
            case 'L':return 'R';
            case 'U':return 'D';
            case 'D':return 'U';
        }
        return 'X';
    }
    class Pos{
        int x, y;
        public Pos(int X, int Y){x = X;y = Y;}
    }
    //SOLUTION END
    void hold(boolean b)throws Exception{if(!b)throw new Exception("Hold right there, Sparky!");}
    void exit(boolean b){if(!b)System.exit(0);}
    long IINF = (long)1e15;
    final int INF = (int)1e9+2, MX = (int)2e6+5;
    DecimalFormat df = new DecimalFormat("0.00000000000");
    double PI = 3.141592653589793238462643383279502884197169399, eps = 1e-8;
    static boolean multipleTC = false, memory = false, fileIO = false;
    FastReader in;PrintWriter out;
    void run() throws Exception{
        long ct = System.currentTimeMillis();
        if (fileIO) {
            in = new FastReader("");
            out = new PrintWriter("");
        } else {
            in = new FastReader();
            out = new PrintWriter(System.out);
        }
        //Solution Credits: Taranpreet Singh
        int T = (multipleTC) ? ni() : 1;
        pre();
        for (int t = 1; t <= T; t++) solve(t);
        out.flush();
        out.close();
        System.err.println(System.currentTimeMillis() - ct);
    }
    public static void main(String[] args) throws Exception{
        if(memory)new Thread(null, new Runnable() {public void run(){try{new Main().run();}catch(Exception e){e.printStackTrace();}}}, "1", 1 << 28).start();
        else new Main().run();
    }
    int[][] make(int n, int[] from, int[] to, boolean f){
        int[][] g = new int[n][];int[]cnt = new int[n];
        for(int i:from)cnt[i]++;if(f)for(int i:to)cnt[i]++;
        for(int i = 0; i< n; i++)g[i] = new int[cnt[i]];
        for(int i = 0; i< from.length; i++){
            g[from[i]][--cnt[from[i]]] = to[i];
            if(f)g[to[i]][--cnt[to[i]]] = from[i];
        }
        return g;
    }
    int find(int[] set, int u){return set[u] = (set[u] == u?u:find(set, set[u]));}
    int digit(long s){int ans = 0;while(s>0){s/=10;ans++;}return ans;}
    long gcd(long a, long b){return (b==0)?a:gcd(b,a%b);}
    int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}
    int bit(long n){return (n==0)?0:(1+bit(n&(n-1)));}
    void p(Object o){out.print(o);}
    void pn(Object o){out.println(o);}
    void pni(Object o){out.println(o);out.flush();}
    String n()throws Exception{return in.next();}
    String nln()throws Exception{return in.nextLine();}
    int ni()throws Exception{return Integer.parseInt(in.next());}
    long nl()throws Exception{return Long.parseLong(in.next());}
    double nd()throws Exception{return Double.parseDouble(in.next());}

    class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastReader(String s) throws Exception{
            br = new BufferedReader(new FileReader(s));
        }

        String next() throws Exception{
            while (st == null || !st.hasMoreElements()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (IOException  e){
                    throw new Exception(e.toString());
                }
            }
            return st.nextToken();
        }

        String nextLine() throws Exception{
            String str;
            try{
                str = br.readLine();
            }catch (IOException e){
                throw new Exception(e.toString());
            }
            return str;
        }
    }
}


import java.util.*;
import java.io.*;
import java.text.*;
public class Main{
    //SOLUTION BEGIN
    //Into the Hardware Mode
    int[][] D = new int[][]{
            {-1, 0},
            {1, 0},
            {0, -1},
            {0, 1}
    };
    char[] f = new char[]{'D', 'U', 'R', 'L'};
    void pre() throws Exception{}
    void solve(int TC)throws Exception {
        int n = ni();
        int[][][] g = new int[n][n][2];
        char[][] ans = new char[n][n];
        Queue<Pos> q = new ArrayDeque<>();
        for(int i = 0; i< n; i++){
            for(int j = 0; j< n; j++){
                g[i][j] = new int[]{ni()-1, ni()-1};
                ans[i][j] = ' ';
                if(g[i][j][0] == i && g[i][j][1] == j){
                    ans[i][j] = 'X';
                    q.add(new Pos(i, j));
                }
            }
        }
        char[] f = new char[]{'D', 'U', 'R', 'L'};
        while(!q.isEmpty()){
            Pos p = q.poll();
            int c = 0;
            for(int[] d:D){
                int xx = p.x+d[0], yy = p.y+d[1];
                char ch = f[c];
                c++;
                if(Math.min(xx, yy) < 0 || Math.max(xx, yy) >= n || g[xx][yy][0] != g[p.x][p.y][0] || g[xx][yy][1] != g[p.x][p.y][1] || ans[xx][yy] != ' ')continue;
                ans[xx][yy] = ch;
                q.add(new Pos(xx, yy));
            }
        }
        boolean valid = true;
        for(int i = 0; i< n; i++){
            for(int j = 0; j< n; j++){
                if(g[i][j][0] == -2 && g[i][j][1] == -2){
                    int c = 0, cnt = 0;
                    for(int[] d:D){
                        int ii = i+d[0], jj = j+d[1];char ch = f[cnt];
                        cnt++;
                        if(Math.min(ii, jj) < 0 || Math.max(ii, jj) >= n)continue;
                        if(g[ii][jj][0] == -2 && g[ii][jj][1] == -2){
                            ans[ii][jj] = ch;
                            c++;
                            ans[i][j] = op(ch);
                            break;
                        }
                    }
                    if(c == 0)valid = false;
                }
            }
        }
        for(char[] cc:ans)for(char c:cc)valid &= c != ' ';
        if(!valid)pn("INVALID");
        else{
            pn("VALID");
            for(char[] cc:ans){
                for(char c:cc)p(c);pn("");
            }
        }
    }
    char op(char ch){
        switch (ch){
            case 'R':return 'L';
            case 'L':return 'R';
            case 'U':return 'D';
            case 'D':return 'U';
        }
        return 'X';
    }
    class Pos{
        int x, y;
        public Pos(int X, int Y){x = X;y = Y;}
    }
    //SOLUTION END
    void hold(boolean b)throws Exception{if(!b)throw new Exception("Hold right there, Sparky!");}
    void exit(boolean b){if(!b)System.exit(0);}
    long IINF = (long)1e15;
    final int INF = (int)1e9+2, MX = (int)2e6+5;
    DecimalFormat df = new DecimalFormat("0.00000000000");
    double PI = 3.141592653589793238462643383279502884197169399, eps = 1e-8;
    static boolean multipleTC = false, memory = false, fileIO = false;
    FastReader in;PrintWriter out;
    void run() throws Exception{
        long ct = System.currentTimeMillis();
        if (fileIO) {
            in = new FastReader("");
            out = new PrintWriter("");
        } else {
            in = new FastReader();
            out = new PrintWriter(System.out);
        }
        //Solution Credits: Taranpreet Singh
        int T = (multipleTC) ? ni() : 1;
        pre();
        for (int t = 1; t <= T; t++) solve(t);
        out.flush();
        out.close();
        System.err.println(System.currentTimeMillis() - ct);
    }
    public static void main(String[] args) throws Exception{
        if(memory)new Thread(null, new Runnable() {public void run(){try{new Main().run();}catch(Exception e){e.printStackTrace();}}}, "1", 1 << 28).start();
        else new Main().run();
    }
    int[][] make(int n, int[] from, int[] to, boolean f){
        int[][] g = new int[n][];int[]cnt = new int[n];
        for(int i:from)cnt[i]++;if(f)for(int i:to)cnt[i]++;
        for(int i = 0; i< n; i++)g[i] = new int[cnt[i]];
        for(int i = 0; i< from.length; i++){
            g[from[i]][--cnt[from[i]]] = to[i];
            if(f)g[to[i]][--cnt[to[i]]] = from[i];
        }
        return g;
    }
    int find(int[] set, int u){return set[u] = (set[u] == u?u:find(set, set[u]));}
    int digit(long s){int ans = 0;while(s>0){s/=10;ans++;}return ans;}
    long gcd(long a, long b){return (b==0)?a:gcd(b,a%b);}
    int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}
    int bit(long n){return (n==0)?0:(1+bit(n&(n-1)));}
    void p(Object o){out.print(o);}
    void pn(Object o){out.println(o);}
    void pni(Object o){out.println(o);out.flush();}
    String n()throws Exception{return in.next();}
    String nln()throws Exception{return in.nextLine();}
    int ni()throws Exception{return Integer.parseInt(in.next());}
    long nl()throws Exception{return Long.parseLong(in.next());}
    double nd()throws Exception{return Double.parseDouble(in.next());}

    class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastReader(String s) throws Exception{
            br = new BufferedReader(new FileReader(s));
        }

        String next() throws Exception{
            while (st == null || !st.hasMoreElements()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (IOException  e){
                    throw new Exception(e.toString());
                }
            }
            return st.nextToken();
        }

        String nextLine() throws Exception{
            String str;
            try{
                str = br.readLine();
            }catch (IOException e){
                throw new Exception(e.toString());
            }
            return str;
        }
    }
}


import java.io.*;
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static PrintWriter out = new PrintWriter(System.out);
	static int n, grid[][], dx[], dy[];
	static boolean memo[][];
	static Pair adj[][];

	static boolean valid(int r, int c) {
		return r >= 0 && r < n && c >= 0 && c < n;
	}

	static boolean dfs1(int r, int c) {
		for (int i = 0; i < 4; i++) {
			int nr = r + dx[i], nc = c + dy[i];
			if (valid(nr, nc) && grid[nr][nc] == -1) {
				if (adj[nr][nc].r == -2) {
					grid[r][c] = i;
					return dfs1(nr, nc);
				}
			}
		}

		for (int i = 0; i < 4; i++) {
			int nr = r + dx[i], nc = c + dy[i];
			if (valid(nr, nc) && adj[nr][nc].r == -2) {
				grid[r][c] = i;
				return true;
			}
		}

		return false;
	}

	static boolean dfs2(int r, int c) {
		if (adj[r][c].r == r && adj[r][c].c == c) {
			grid[r][c] = 4;
			return memo[r][c] = true;
		}

		for (int i = 0; i < 4; i++) {
			int nr = r + dx[i], nc = c + dy[i];
			if (valid(nr, nc) && adj[nr][nc].r == adj[r][c].r) {
				if (memo[nr][nc] && adj[nr][nc].c == adj[r][c].c) {
					grid[r][c] = i;
					return memo[r][c] = true;
				}
			}
		}

		for (int i = 0; i < 4; i++) {
			int nr = r + dx[i], nc = c + dy[i];
			if (valid(nr, nc) && grid[nr][nc] == -1) {
				if (adj[nr][nc].r == adj[r][c].r && adj[nr][nc].c == adj[r][c].c) {
					grid[r][c] = i;
					return memo[r][c] = dfs2(nr, nc);
				}
			}
		}

		return false;
	}

	public static void main(String[] args) throws Exception {
		n = sc.nextInt();
		grid = new int[n][n];
		adj = new Pair[n][n];
		memo = new boolean[n][n];
		dx = new int[] { 0, 1, 0, -1 };
		dy = new int[] { 1, 0, -1, 0 };

		for (int[] arr : grid)
			Arrays.fill(arr, -1);

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				adj[i][j] = new Pair(sc.nextInt() - 1, sc.nextInt() - 1);
			}
		}

		boolean flag = true;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (grid[i][j] == -1) {
					if (adj[i][j].r == -2) {
						flag &= dfs1(i, j);
					} else {
						flag &= dfs2(i, j);
					}
				}
			}
		}

		out.println(flag ? "VALID" : "INVALID");
		if (flag) {
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					int x = grid[i][j];
					if (x == 0)
						out.print("R");
					else if (x == 1)
						out.print("D");
					else if (x == 2)
						out.print("L");
					else if (x == 3)
						out.print("U");
					else
						out.print("X");
				}
				out.println();
			}
		}

		out.close();
	}

	static class Pair {
		int r, c;

		public Pair(int r, int c) {
			this.r = r;
			this.c = c;
		}
	}

}

class Scanner {
	StringTokenizer st;
	BufferedReader br;

	public Scanner(InputStream system) {
		br = new BufferedReader(new InputStreamReader(system));
	}

	public Scanner(String file) throws Exception {
		br = new BufferedReader(new FileReader(file));
	}

	public String next() throws IOException {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}

	public String nextLine() throws IOException {
		return br.readLine();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}

	public Long nextLong() throws IOException {
		return Long.parseLong(next());
	}
}


import java.io.*;
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static PrintWriter out = new PrintWriter(System.out);
	static int n, grid[][], dx[], dy[];
	static Pair adj[][];

	static boolean valid(int r, int c) {
		return r >= 0 && r < n && c >= 0 && c < n;
	}

	static boolean dfs(int r, int c) {
		for (int i = 0; i < 4; i++) {
			int nr = r + dx[i], nc = c + dy[i];
			if (valid(nr, nc) && adj[nr][nc].r == -2) {
				grid[r][c] = i;
				return true;
			}
		}
		return false;
	}

	static void dfs2(int r, int c) {
		for (int i = 0; i < 4; i++) {
			int nr = r + dx[i], nc = c + dy[i];
			if (valid(nr, nc) && grid[nr][nc] == -1) {
				if (adj[nr][nc].r == adj[r][c].r && adj[nr][nc].c == adj[r][c].c) {
					grid[nr][nc] = (i + 2) % 4;
					dfs2(nr, nc);
				}
			}
		}
	}

	static void bfs(Pair p) {
		Queue<Pair> q = new LinkedList<>();
		q.add(p);
		while (!q.isEmpty()) {
			Pair u = q.poll();
			for (int i = 0; i < 4; i++) {
				int nr = u.r + dx[i], nc = + dy[i];
				if (valid(nr, nc) && grid[nr][nc] == -1) {
					if (adj[nr][nc].r == adj[u.r][u.c].r && adj[nr][nc].c == adj[u.r][u.c].c) {
						grid[nr][nc] = (i + 2) % 4;
						q.add(new Pair(nr,nc));
					}
				}
			}
		}
	}

	public static void main(String[] args) throws Exception {
		n = sc.nextInt();
		grid = new int[n][n];
		adj = new Pair[n][n];
		dx = new int[] { 0, 1, 0, -1 };
		dy = new int[] { 1, 0, -1, 0 };

		for (int[] arr : grid)
			Arrays.fill(arr, -1);

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				adj[i][j] = new Pair(sc.nextInt() - 1, sc.nextInt() - 1);
			}
		}

		boolean flag = true;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (grid[i][j] == -1) {
					if (adj[i][j].r == -2) {
						flag &= dfs(i, j);
					} else {
						if (adj[i][j].r == i && adj[i][j].c == j) {
							grid[i][j] = 4;
							bfs(new Pair(i,j));
						}
					}
				}
			}
		}

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (grid[i][j] == -1)
					flag = false;
			}
		}

		out.println(flag ? "VALID" : "INVALID");
		if (flag) {
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					int x = grid[i][j];
					if (x == 0)
						out.print("R");
					else if (x == 1)
						out.print("D");
					else if (x == 2)
						out.print("L");
					else if (x == 3)
						out.print("U");
					else
						out.print("X");
				}
				out.println();
			}
		}

		out.close();
	}

	static class Pair {
		int r, c;

		public Pair(int r, int c) {
			this.r = r;
			this.c = c;
		}
	}

}

class Scanner {
	StringTokenizer st;
	BufferedReader br;

	public Scanner(InputStream system) {
		br = new BufferedReader(new InputStreamReader(system));
	}

	public Scanner(String file) throws Exception {
		br = new BufferedReader(new FileReader(file));
	}

	public String next() throws IOException {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}

	public String nextLine() throws IOException {
		return br.readLine();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}

	public Long nextLong() throws IOException {
		return Long.parseLong(next());
	}
}


import java.io.*;
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static PrintWriter out = new PrintWriter(System.out);
	static int n, grid[][], dx[], dy[];
	static Pair adj[][];

	static boolean valid(int r, int c) {
		return r >= 0 && r < n && c >= 0 && c < n;
	}

	static boolean dfs1(int r, int c) {
		for (int i = 0; i < 4; i++) {
			int nr = r + dx[i], nc = c + dy[i];
			if (valid(nr, nc) && grid[nr][nc] == -1) {
				if (adj[nr][nc].r == -2) {
					grid[r][c] = i;
					return dfs1(nr, nc);
				}
			}
		}

		for (int i = 0; i < 4; i++) {
			int nr = r + dx[i], nc = c + dy[i];
			if (valid(nr, nc) && adj[nr][nc].r == -2) {
				grid[r][c] = i;
				return true;
			}
		}

		return false;
	}

	static boolean dfs2(int r, int c) {
		if (adj[r][c].r == r && adj[r][c].c == c) {
			grid[r][c] = 4;
			return true;
		}

		for (int i = 0; i < 4; i++) {
			int nr = r + dx[i], nc = c + dy[i];
			if (valid(nr, nc) && grid[nr][nc] == -1) {
				if (adj[nr][nc].r == adj[r][c].r && adj[nr][nc].c == adj[r][c].c) {
					grid[r][c] = i;
					return dfs2(nr, nc);
				}
			}
		}
		for (int i = 0; i < 4; i++) {
			int nr = r + dx[i], nc = c + dy[i];
			if (valid(nr, nc) && nr == adj[r][c].r && nc == adj[r][c].c) {
				if (grid[nr][nc] == 4) {
					grid[r][c] = i;
					return true;
				}
			}

			if(valid(nr,nc) && adj[nr][nc].r == adj[r][c].r && adj[nr][nc].c == adj[r][c].c) {
				grid[r][c] = i;
				return true;
			}
		}

		return false;
	}

	public static void main(String[] args) throws Exception {
		n = sc.nextInt();
		grid = new int[n][n];
		adj = new Pair[n][n];
		dx = new int[] { 0, 1, 0, -1 };
		dy = new int[] { 1, 0, -1, 0 };

		for (int[] arr : grid)
			Arrays.fill(arr, -1);

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				adj[i][j] = new Pair(sc.nextInt() - 1, sc.nextInt() - 1);
			}
		}

		boolean flag = true;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (grid[i][j] == -1) {
					if (adj[i][j].r == -2) {
						flag &= dfs1(i, j);
					} else {
						flag &= dfs2(i, j);
					}
					out.println(!flag ? i + " "+ j:"");
				}
			}
		}

		out.println(flag ? "VALID" : "INVALID");
		if (flag) {
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					int x = grid[i][j];
					if (x == 0)
						out.print("R");
					else if (x == 1)
						out.print("D");
					else if (x == 2)
						out.print("L");
					else if (x == 3)
						out.print("U");
					else
						out.print("X");
				}
				out.println();
			}
		}

		out.close();
	}

	static class Pair {
		int r, c;

		public Pair(int r, int c) {
			this.r = r;
			this.c = c;
		}
	}

}

class Scanner {
	StringTokenizer st;
	BufferedReader br;

	public Scanner(InputStream system) {
		br = new BufferedReader(new InputStreamReader(system));
	}

	public Scanner(String file) throws Exception {
		br = new BufferedReader(new FileReader(file));
	}

	public String next() throws IOException {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}

	public String nextLine() throws IOException {
		return br.readLine();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}

	public Long nextLong() throws IOException {
		return Long.parseLong(next());
	}
}


import java.io.*;
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static PrintWriter out = new PrintWriter(System.out);
	static int n, grid[][], dx[], dy[];
	static boolean memo[][];
	static Pair adj[][];

	static boolean valid(int r, int c) {
		return r >= 0 && r < n && c >= 0 && c < n;
	}

	static boolean dfs1(int r, int c) {
//		for (int i = 0; i < 4; i++) {
//			int nr = r + dx[i], nc = c + dy[i];
//			if (valid(nr, nc) && grid[nr][nc] == -1) {
//				if (adj[nr][nc].r == -2) {
//					grid[r][c] = i;
//					return dfs1(nr, nc);
//				}
//			}
//		}

		for (int i = 0; i < 4; i++) {
			int nr = r + dx[i], nc = c + dy[i];
			if (valid(nr, nc) && adj[nr][nc].r == -2) {
				grid[r][c] = i;
				return true;
			}
		}

		return false;
	}

	static boolean dfs2(int r, int c) {
		if (adj[r][c].r == r && adj[r][c].c == c) {
			grid[r][c] = 4;
			return memo[r][c] = true;
		}

		for (int i = 0; i < 4; i++) {
			int nr = r + dx[i], nc = c + dy[i];
			if (valid(nr, nc) && adj[nr][nc].r == adj[r][c].r) {
				if (memo[nr][nc] && adj[nr][nc].c == adj[r][c].c) {
					grid[r][c] = i;
					return memo[r][c] = true;
				}
			}
		}

		for (int i = 0; i < 4; i++) {
			int nr = r + dx[i], nc = c + dy[i];
			if (valid(nr, nc) && grid[nr][nc] == -1) {
				if (adj[nr][nc].r == adj[r][c].r && adj[nr][nc].c == adj[r][c].c) {
					grid[r][c] = i;
					return memo[r][c] = dfs2(nr, nc);
				}
			}
		}

		return false;
	}

	public static void main(String[] args) throws Exception {
		n = sc.nextInt();
		grid = new int[n][n];
		adj = new Pair[n][n];
		memo = new boolean[n][n];
		dx = new int[] { 0, 1, 0, -1 };
		dy = new int[] { 1, 0, -1, 0 };

		for (int[] arr : grid)
			Arrays.fill(arr, -1);

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				adj[i][j] = new Pair(sc.nextInt() - 1, sc.nextInt() - 1);
			}
		}

		boolean flag = true;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (grid[i][j] == -1) {
					if (adj[i][j].r == -2) {
						flag &= dfs1(i, j);
					} else {
						flag &= dfs2(i, j);
					}
				}
			}
		}

		out.println(flag ? "VALID" : "INVALID");
		if (flag) {
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					int x = grid[i][j];
					if (x == 0)
						out.print("R");
					else if (x == 1)
						out.print("D");
					else if (x == 2)
						out.print("L");
					else if (x == 3)
						out.print("U");
					else
						out.print("X");
				}
				out.println();
			}
		}

		out.close();
	}

	static class Pair {
		int r, c;

		public Pair(int r, int c) {
			this.r = r;
			this.c = c;
		}
	}

}

class Scanner {
	StringTokenizer st;
	BufferedReader br;

	public Scanner(InputStream system) {
		br = new BufferedReader(new InputStreamReader(system));
	}

	public Scanner(String file) throws Exception {
		br = new BufferedReader(new FileReader(file));
	}

	public String next() throws IOException {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}

	public String nextLine() throws IOException {
		return br.readLine();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}

	public Long nextLong() throws IOException {
		return Long.parseLong(next());
	}
}


import java.io.*;
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static PrintWriter out = new PrintWriter(System.out);
	static int n, grid[][], dx[], dy[];
	static Pair adj[][];

	static boolean valid(int r, int c) {
		return r >= 0 && r < n && c >= 0 && c < n;
	}

	static boolean dfs1(int r, int c) {
		for (int i = 0; i < 4; i++) {
			int nr = r + dx[i], nc = c + dy[i];
			if (valid(nr, nc) && grid[nr][nc] == -1) {
				if (adj[nr][nc].r == -2) {
					grid[r][c] = i;
					return dfs1(nr, nc);
				}
			}
		}

		for (int i = 0; i < 4; i++) {
			int nr = r + dx[i], nc = c + dy[i];
			if (valid(nr, nc) && adj[nr][nc].r == -2) {
				grid[r][c] = i;
				return true;
			}
		}

		return false;
	}

	static boolean dfs2(int r, int c) {
		if (adj[r][c].r == r && adj[r][c].c == c) {
			grid[r][c] = 4;
			return true;
		}

		for (int i = 0; i < 4; i++) {
			int nr = r + dx[i], nc = c + dy[i];
			if (valid(nr, nc) && grid[nr][nc] == -1) {
				if (adj[nr][nc].r == adj[r][c].r && adj[nr][nc].c == adj[r][c].c) {
					grid[r][c] = i;
					return dfs2(nr, nc);
				}
			}
		}
		for (int i = 0; i < 4; i++) {
			int nr = r + dx[i], nc = c + dy[i];
			if (valid(nr, nc) && nr == adj[r][c].r && nc == adj[r][c].c) {
				if (grid[nr][nc] == 4) {
					grid[r][c] = i;
					return true;
				}
			}

			if(valid(nr,nc) && adj[nr][nc].r == adj[r][c].r && adj[nr][nc].c == adj[r][c].c) {
				grid[r][c] = i;
				return true;
			}
		}

		return false;
	}

	public static void main(String[] args) throws Exception {
		n = sc.nextInt();
		grid = new int[n][n];
		adj = new Pair[n][n];
		dx = new int[] { 0, 1, 0, -1 };
		dy = new int[] { 1, 0, -1, 0 };

		for (int[] arr : grid)
			Arrays.fill(arr, -1);

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				adj[i][j] = new Pair(sc.nextInt() - 1, sc.nextInt() - 1);
			}
		}

		boolean flag = true;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (grid[i][j] == -1) {
					if (adj[i][j].r == -2) {
						flag &= dfs1(i, j);
					} else {
						flag &= dfs2(i, j);
					}
				}
			}
		}

		out.println(flag ? "VALID" : "INVALID");
		if (flag) {
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					int x = grid[i][j];
					if (x == 0)
						out.print("R");
					else if (x == 1)
						out.print("D");
					else if (x == 2)
						out.print("L");
					else if (x == 3)
						out.print("U");
					else
						out.print("X");
				}
				out.println();
			}
		}

		out.close();
	}

	static class Pair {
		int r, c;

		public Pair(int r, int c) {
			this.r = r;
			this.c = c;
		}
	}

}

class Scanner {
	StringTokenizer st;
	BufferedReader br;

	public Scanner(InputStream system) {
		br = new BufferedReader(new InputStreamReader(system));
	}

	public Scanner(String file) throws Exception {
		br = new BufferedReader(new FileReader(file));
	}

	public String next() throws IOException {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}

	public String nextLine() throws IOException {
		return br.readLine();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}

	public Long nextLong() throws IOException {
		return Long.parseLong(next());
	}
}


import java.io.*;
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static PrintWriter out = new PrintWriter(System.out);
	static int n, grid[][], dx[], dy[];
	static Pair adj[][];

	static boolean valid(int r, int c) {
		return r >= 0 && r < n && c >= 0 && c < n;
	}

	static boolean dfs1(int r, int c) {
		for (int i = 0; i < 4; i++) {
			int nr = r + dx[i], nc = c + dy[i];
			if (valid(nr, nc) && grid[nr][nc] == -1) {
				if (adj[nr][nc].r == -2) {
					grid[r][c] = i;
					return dfs1(nr, nc);
				}
			}
		}

		for (int i = 0; i < 4; i++) {
			int nr = r + dx[i], nc = c + dy[i];
			if (valid(nr, nc) && adj[nr][nc].r == -2) {
				grid[r][c] = i;
				return true;
			}
		}

		return false;
	}

	static boolean dfs2(int r, int c) {
		if (adj[r][c].r == r && adj[r][c].c == c) {
			grid[r][c] = 4;
			return true;
		}

		for (int i = 0; i < 4; i++) {
			int nr = r + dx[i], nc = c + dy[i];
			if (valid(nr, nc) && grid[nr][nc] == -1) {
				if (adj[nr][nc].r == adj[r][c].r && adj[nr][nc].c == adj[r][c].c) {
					grid[r][c] = i;
					return dfs2(nr, nc);
				}
			}
		}
		for (int i = 0; i < 4; i++) {
			int nr = r + dx[i], nc = c + dy[i];
			if (valid(nr, nc) && nr == adj[r][c].r && nc == adj[r][c].c) {
				if (grid[nr][nc] == 4) {
					grid[r][c] = i;
					return true;
				}
			}
		}

		return false;
	}

	public static void main(String[] args) throws Exception {
		n = sc.nextInt();
		grid = new int[n][n];
		adj = new Pair[n][n];
		dx = new int[] { 0, 1, 0, -1 };
		dy = new int[] { 1, 0, -1, 0 };

		for (int[] arr : grid)
			Arrays.fill(arr, -1);

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				adj[i][j] = new Pair(sc.nextInt() - 1, sc.nextInt() - 1);
			}
		}

		boolean flag = true;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (grid[i][j] == -1) {
					if (adj[i][j].r == -2) {
						flag &= dfs1(i, j);
					} else {
						flag &= dfs2(i, j);
					}
				}
			}
		}

		out.println(flag ? "VALID" : "INVALID");
		if (flag) {
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					int x = grid[i][j];
					if (x == 0)
						out.print("R");
					else if (x == 1)
						out.print("D");
					else if (x == 2)
						out.print("L");
					else if (x == 3)
						out.print("U");
					else
						out.print("X");
				}
				out.println();
			}
		}

		out.close();
	}

	static class Pair {
		int r, c;

		public Pair(int r, int c) {
			this.r = r;
			this.c = c;
		}
	}

}

class Scanner {
	StringTokenizer st;
	BufferedReader br;

	public Scanner(InputStream system) {
		br = new BufferedReader(new InputStreamReader(system));
	}

	public Scanner(String file) throws Exception {
		br = new BufferedReader(new FileReader(file));
	}

	public String next() throws IOException {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}

	public String nextLine() throws IOException {
		return br.readLine();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}

	public Long nextLong() throws IOException {
		return Long.parseLong(next());
	}
}


import java.io.*;
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static PrintWriter out = new PrintWriter(System.out);
	static int n, grid[][], dx[], dy[];
	static Pair adj[][];

	static boolean valid(int r, int c) {
		return r >= 0 && r < n && c >= 0 && c < n;
	}

	static boolean dfs1(int r, int c) {
		for (int i = 0; i < 4; i++) {
			int nr = r + dx[i], nc = c + dy[i];
			if (valid(nr, nc) && adj[nr][nc].r == -2) {
				grid[r][c] = i;
				return true;
			}
		}
		return false;
	}

	static void dfs2(int r, int c) {
		for (int i = 0; i < 4; i++) {
			int nr = r + dx[i], nc = c + dy[i];
			if(valid(nr,nc) && grid[nr][nc] == -1) {
				if(adj[nr][nc].r == adj[r][c].r && adj[nr][nc].c == adj[r][c].c) {
					grid[nr][nc] = (i + 2) % 4;
					dfs2(nr,nc);
				}
			}
		}
	}

	public static void main(String[] args) throws Exception {
		n = sc.nextInt();
		grid = new int[n][n];
		adj = new Pair[n][n];
		dx = new int[] { 0, 1, 0, -1 };
		dy = new int[] { 1, 0, -1, 0 };

		for (int[] arr : grid)
			Arrays.fill(arr, -1);

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				adj[i][j] = new Pair(sc.nextInt() - 1, sc.nextInt() - 1);
			}
		}

		boolean flag = true;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (grid[i][j] == -1) {
					if (adj[i][j].r == -2) {
						flag &= dfs1(i, j);
					} else {
						if(adj[i][j].r == i && adj[i][j].c == j) {
							grid[i][j] = 4;
							dfs2(i,j);
						}
					}
				}
			}
		}

		for(int i = 0; i < n; i++) {
			for(int j = 0; j < n; j++) {
				if(grid[i][j] == -1) flag = false;
			}
		}

		out.println(flag ? "VALID" : "INVALID");
		if (flag) {
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					int x = grid[i][j];
					if (x == 0)
						out.print("R");
					else if (x == 1)
						out.print("D");
					else if (x == 2)
						out.print("L");
					else if (x == 3)
						out.print("U");
					else
						out.print("X");
				}
				out.println();
			}
		}

		out.close();
	}

	static class Pair {
		int r, c;

		public Pair(int r, int c) {
			this.r = r;
			this.c = c;
		}
	}

}

class Scanner {
	StringTokenizer st;
	BufferedReader br;

	public Scanner(InputStream system) {
		br = new BufferedReader(new InputStreamReader(system));
	}

	public Scanner(String file) throws Exception {
		br = new BufferedReader(new FileReader(file));
	}

	public String next() throws IOException {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}

	public String nextLine() throws IOException {
		return br.readLine();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}

	public Long nextLong() throws IOException {
		return Long.parseLong(next());
	}
}


import java.io.*;
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static PrintWriter out = new PrintWriter(System.out);
	static int n, grid[][], dx[], dy[];
	static Pair adj[][];

	static boolean valid(int r, int c) {
		return r >= 0 && r < n && c >= 0 && c < n;
	}

	static boolean dfs1(int r, int c) {
		for (int i = 0; i < 4; i++) {
			int nr = r + dx[i], nc = c + dy[i];
			if (valid(nr, nc) && grid[nr][nc] == -1) {
				if (adj[nr][nc].r == -2) {
					grid[r][c] = i;
					return dfs1(nr, nc);
				}
			}
		}

		for (int i = 0; i < 4; i++) {
			int nr = r + dx[i], nc = c + dy[i];
			if (valid(nr, nc) && adj[nr][nc].r == -2) {
				grid[r][c] = i;
				return true;
			}
		}

		return false;
	}

	static boolean dfs2(int r, int c) {
		if (adj[r][c].r == r && adj[r][c].c == c) {
			grid[r][c] = 4;
			return true;
		}

		for (int i = 0; i < 4; i++) {
			int nr = r + dx[i], nc = c + dy[i];
			if (valid(nr, nc) && grid[nr][nc] == -1) {
				if (adj[nr][nc].r == adj[r][c].r && adj[nr][nc].c == adj[r][c].c) {
					grid[r][c] = i;
					return dfs2(nr, nc);
				}
			}
		}
		for(int i = 0; i < 4; i++) {
			int nr = r + dx[i], nc = c + dy[i];
			if(valid(nr,nc) && nr == adj[r][c].r && nc == adj[r][c].c) {
				grid[r][c] = i;
				return true;
			}
		}

		return false;
	}

	public static void main(String[] args) throws Exception {
		n = sc.nextInt();
		grid = new int[n][n];
		adj = new Pair[n][n];
		dx = new int[] { 0, 1, 0, -1 };
		dy = new int[] { 1, 0, -1, 0 };

		for (int[] arr : grid)
			Arrays.fill(arr, -1);

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				adj[i][j] = new Pair(sc.nextInt() - 1, sc.nextInt() - 1);
			}
		}

		boolean flag = true;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (grid[i][j] == -1) {
					if (adj[i][j].r == -2) {
						flag &= dfs1(i, j);
					} else {
						flag &= dfs2(i, j);
					}
				}
			}
		}

		out.println(flag ? "VALID" : "INVALID");
		if(flag) {
			for(int i = 0; i < n; i++) {
				for(int j = 0; j < n; j++) {
					int x = grid[i][j];
					if(x == 0) out.print("R");
					else if(x == 1) out.print("D");
					else if(x == 2) out.print("L");
					else if(x == 3) out.print("U");
					else out.print("X");
				}
				out.println();
			}
		}

		out.close();
	}

	static class Pair {
		int r, c;

		public Pair(int r, int c) {
			this.r = r;
			this.c = c;
		}
	}

}

class Scanner {
	StringTokenizer st;
	BufferedReader br;

	public Scanner(InputStream system) {
		br = new BufferedReader(new InputStreamReader(system));
	}

	public Scanner(String file) throws Exception {
		br = new BufferedReader(new FileReader(file));
	}

	public String next() throws IOException {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}

	public String nextLine() throws IOException {
		return br.readLine();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}

	public Long nextLong() throws IOException {
		return Long.parseLong(next());
	}
}


import java.io.*;
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static PrintWriter out = new PrintWriter(System.out);
	static int n, grid[][], dx[], dy[];
	static Pair adj[][];

	static boolean valid(int r, int c) {
		return r >= 0 && r < n && c >= 0 && c < n;
	}

	static boolean dfs(int r, int c) {
		for (int i = 0; i < 4; i++) {
			int nr = r + dx[i], nc = c + dy[i];
			if (valid(nr, nc) && adj[nr][nc].r == -2) {
				grid[r][c] = i;
				return true;
			}
		}
		return false;
	}

	static void dfs2(int r, int c) {
		for (int i = 0; i < 4; i++) {
			int nr = r + dx[i], nc = c + dy[i];
			if (valid(nr, nc) && grid[nr][nc] == -1) {
				if (adj[nr][nc].r == adj[r][c].r && adj[nr][nc].c == adj[r][c].c) {
					grid[nr][nc] = (i + 2) % 4;
					dfs2(nr, nc);
				}
			}
		}
	}

	static void bfs(Pair p) {
		Queue<Pair> q = new LinkedList<>();
		q.add(p);
		while (!q.isEmpty()) {
			Pair u = q.poll();
			for (int i = 0; i < 4; i++) {
				int nr = u.r + dx[i], nc = u.c + dy[i];
				if (valid(nr, nc) && grid[nr][nc] == -1) {
					if (adj[nr][nc].r == adj[u.r][u.c].r && adj[nr][nc].c == adj[u.r][u.c].c) {
						grid[nr][nc] = (i + 2) % 4;
						q.add(new Pair(nr,nc));
					}
				}
			}
		}
	}

	public static void main(String[] args) throws Exception {
		n = sc.nextInt();
		grid = new int[n][n];
		adj = new Pair[n][n];
		dx = new int[] { 0, 1, 0, -1 };
		dy = new int[] { 1, 0, -1, 0 };

		for (int[] arr : grid)
			Arrays.fill(arr, -1);

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				adj[i][j] = new Pair(sc.nextInt() - 1, sc.nextInt() - 1);
			}
		}

		boolean flag = true;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (grid[i][j] == -1) {
					if (adj[i][j].r == -2) {
						flag &= dfs(i, j);
					} else {
						if (adj[i][j].r == i && adj[i][j].c == j) {
							grid[i][j] = 4;
							bfs(new Pair(i,j));
						}
					}
				}
			}
		}

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				if (grid[i][j] == -1)
					flag = false;
			}
		}

		out.println(flag ? "VALID" : "INVALID");
		if (flag) {
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					int x = grid[i][j];
					if (x == 0)
						out.print("R");
					else if (x == 1)
						out.print("D");
					else if (x == 2)
						out.print("L");
					else if (x == 3)
						out.print("U");
					else
						out.print("X");
				}
				out.println();
			}
		}

		out.close();
	}

	static class Pair {
		int r, c;

		public Pair(int r, int c) {
			this.r = r;
			this.c = c;
		}
	}

}

class Scanner {
	StringTokenizer st;
	BufferedReader br;

	public Scanner(InputStream system) {
		br = new BufferedReader(new InputStreamReader(system));
	}

	public Scanner(String file) throws Exception {
		br = new BufferedReader(new FileReader(file));
	}

	public String next() throws IOException {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}

	public String nextLine() throws IOException {
		return br.readLine();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}

	public Long nextLong() throws IOException {
		return Long.parseLong(next());
	}
}


import java.io.*;
import java.util.*;
import java.math.*;
import java.awt.Point;

public class Main {
	//static final long MOD = 998244353L;
	static final long INF = 1000000000000000007L;
	//static final long MOD = 1000000007L;
	//static final int INF = 1000000007;

	//static long[] factorial;

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter pw = new PrintWriter(System.out);
		int N = sc.ni();
		int[][][] ends = new int[N][N][2];
		char[][] grid = new char[N][N];
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++)
				grid[i][j] ='-';
		}
		int[][] cnt = new int[N][N];
		boolean[][] vis = new boolean[N][N];
		int[][] reg = new int[N][N];
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				int r = sc.ni()-1;
				int c = sc.ni()-1;
				ends[i][j][0] = r;
				ends[i][j][1] = c;
				if (r != -2 && c != -2) {
					grid[r][c] = 'X';
					cnt[r][c] += 1;
				}
			}
		}
		ArrayDeque<int[]> bfs = new ArrayDeque<int[]>();
		int[][] dirs = {{-1,0},{0,1},{0,-1},{1,0}};
		char[] move = {'D','L','R','U'};

		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				if (vis[i][j]) continue;
				if (grid[i][j] != 'X' && ends[i][j][0] != -2) continue;
				int[] type = ends[i][j];
				vis[i][j] = true;
				int size = 0;
				bfs.add(new int[]{i,j});
				while (!bfs.isEmpty()) {
					int[] point = bfs.poll();
					size++;
					for (int d = 0; d < 4; d++) {
						int[] dir = dirs[d];
						int newR = point[0]+dir[0];
						int newC = point[1]+dir[1];
						if (newR >= 0 && newR < N && newC >= 0 && newC < N && ends[newR][newC][0]==ends[i][j][0] && ends[newR][newC][1]==ends[i][j][1] && !vis[newR][newC]) {
							vis[newR][newC] = true;
							bfs.add(new int[]{newR,newC});
							grid[newR][newC] = move[d];
						}
					}
				}

				if (type[0]==-2&&type[1]==-2) {
					if (size == 1) {
						pw.println("INVALID");
						pw.close();
						return;
					} else {
						for (int d = 0; d < 4; d++) {
							int[] dir = dirs[d];
							int newR = i+dir[0];
							int newC = j+dir[1];
							if (newR >= 0 && newR < N && newC >= 0 && newC < N && ends[newR][newC][0]==ends[i][j][0] && ends[newR][newC][1]==ends[i][j][1]) {
								grid[i][j] = move[3-d];
								break;
							}
						}
					}
				} else {
					if (size < cnt[i][j]) {
						pw.println("INVALID");
						pw.close();
						return;
					}
				}
			}
		}

		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				if (grid[i][j]=='-') {
					pw.println("INVALID");
					pw.close();
					return;
				}
			}
		}
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				if (grid[i][j]=='X'&&(ends[i][j][0]!=i||ends[i][j][1]!=j)) {
					pw.println("INVALID");
					pw.close();
					return;
				}
			}
		}
		pw.println("VALID");
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++)
				pw.print(grid[i][j]);
			pw.println();
		}
		pw.close();
	}

	public static long dist(long[] p1, long[] p2) {
		return (Math.abs(p2[0]-p1[0])+Math.abs(p2[1]-p1[1]));
	}

	//Find the GCD of two numbers
	public static long gcd(long a, long b) {
		if (a < b) return gcd(b,a);
		if (b == 0)
			return a;
		else
			return gcd(b,a%b);
	}

	//Fast exponentiation (x^y mod m)
	public static long power(long x, long y, long m) {
		if (y < 0) return 0L;
		long ans = 1;
		x %= m;
		while (y > 0) {
			if(y % 2 == 1)
				ans = (ans * x) % m;
			y /= 2;
			x = (x * x) % m;
		}
		return ans;
	}

	public static int[][] shuffle(int[][] array) {
		Random rgen = new Random();
		for (int i = 0; i < array.length; i++) {
		    int randomPosition = rgen.nextInt(array.length);
		    int[] temp = array[i];
		    array[i] = array[randomPosition];
		    array[randomPosition] = temp;
		}
		return array;
	}

    public static int[][] sort(int[][] array) {
    	//Sort an array (immune to quicksort TLE)

		Arrays.sort(array, new Comparator<int[]>() {
			  @Override
        	  public int compare(int[] a, int[] b) {
				  //return a[0]-b[0]; //ascending order
				  if (a[1] != b[1]) {
					  return (a[1]-b[1]);
				  } else {
					  return (a[0]-b[0]);
				  }
	          }
		});
		return array;
	}

    public static long[][] sort(long[][] array) {
    	//Sort an array (immune to quicksort TLE)
		Random rgen = new Random();
		for (int i = 0; i < array.length; i++) {
		    int randomPosition = rgen.nextInt(array.length);
		    long[] temp = array[i];
		    array[i] = array[randomPosition];
		    array[randomPosition] = temp;
		}
		Arrays.sort(array, new Comparator<long[]>() {
			  @Override
        	  public int compare(long[] a, long[] b) {
				  if (a[0] < b[0])
					  return -1;
				  else
					  return 1;
	          }
		});
		return array;
	}

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int ni() {
            return Integer.parseInt(next());
        }

        long nl() {
            return Long.parseLong(next());
        }

        double nd() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


import java.io.*;
import java.util.*;
import java.math.*;
import java.awt.Point;

public class Main {
	//static final long MOD = 998244353L;
	static final long INF = 1000000000000000007L;
	//static final long MOD = 1000000007L;
	//static final int INF = 1000000007;

	//static long[] factorial;

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter pw = new PrintWriter(System.out);
		int N = sc.ni();
		int[][][] ends = new int[N][N][2];
		char[][] grid = new char[N][N];
		int[][] cnt = new int[N][N];
		boolean[][] vis = new boolean[N][N];
		int[][] reg = new int[N][N];
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				int r = sc.ni()-1;
				int c = sc.ni()-1;
				ends[i][j][0] = r;
				ends[i][j][1] = c;
				if (r != -2 && c != -2) {
					grid[r][c] = 'X';
					cnt[r][c] += 1;
				}
			}
		}
		ArrayDeque<int[]> bfs = new ArrayDeque<int[]>();
		int[][] dirs = {{-1,0},{0,1},{0,-1},{1,0}};
		char[] move = {'D','L','R','U'};

		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				if (vis[i][j]) continue;
				if (grid[i][j] != 'X' && ends[i][j][0] != -2) continue;
				int[] type = ends[i][j];
				vis[i][j] = true;
				int size = 0;
				bfs.add(new int[]{i,j});
				while (!bfs.isEmpty()) {
					int[] point = bfs.poll();
					size++;
					for (int d = 0; d < 4; d++) {
						int[] dir = dirs[d];
						int newR = point[0]+dir[0];
						int newC = point[1]+dir[1];
						if (newR >= 0 && newR < N && newC >= 0 && newC < N && ends[newR][newC][0]==ends[i][j][0] && ends[newR][newC][1]==ends[i][j][1] && !vis[newR][newC]) {
							vis[newR][newC] = true;
							bfs.add(new int[]{newR,newC});
							grid[newR][newC] = move[d];
						}
					}
				}

				if (type[0]==-2&&type[1]==-2) {
					if (size == 1) {
						pw.println("INVALID");
						pw.close();
						return;
					} else {
						for (int d = 0; d < 4; d++) {
							int[] dir = dirs[d];
							int newR = i+dir[0];
							int newC = j+dir[1];
							if (newR >= 0 && newR < N && newC >= 0 && newC < N && ends[newR][newC][0]==ends[i][j][0] && ends[newR][newC][1]==ends[i][j][1]) {
								grid[i][j] = move[3-d];
								break;
							}
						}
					}
				} else {
					if (size < cnt[i][j]) {
						pw.println("INVALID");
						pw.close();
						return;
					}
				}
			}
		}
		pw.println("VALID");
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++)
				pw.print(grid[i][j]);
			pw.println();
		}
		pw.close();
	}

	public static long dist(long[] p1, long[] p2) {
		return (Math.abs(p2[0]-p1[0])+Math.abs(p2[1]-p1[1]));
	}

	//Find the GCD of two numbers
	public static long gcd(long a, long b) {
		if (a < b) return gcd(b,a);
		if (b == 0)
			return a;
		else
			return gcd(b,a%b);
	}

	//Fast exponentiation (x^y mod m)
	public static long power(long x, long y, long m) {
		if (y < 0) return 0L;
		long ans = 1;
		x %= m;
		while (y > 0) {
			if(y % 2 == 1)
				ans = (ans * x) % m;
			y /= 2;
			x = (x * x) % m;
		}
		return ans;
	}

	public static int[][] shuffle(int[][] array) {
		Random rgen = new Random();
		for (int i = 0; i < array.length; i++) {
		    int randomPosition = rgen.nextInt(array.length);
		    int[] temp = array[i];
		    array[i] = array[randomPosition];
		    array[randomPosition] = temp;
		}
		return array;
	}

    public static int[][] sort(int[][] array) {
    	//Sort an array (immune to quicksort TLE)

		Arrays.sort(array, new Comparator<int[]>() {
			  @Override
        	  public int compare(int[] a, int[] b) {
				  //return a[0]-b[0]; //ascending order
				  if (a[1] != b[1]) {
					  return (a[1]-b[1]);
				  } else {
					  return (a[0]-b[0]);
				  }
	          }
		});
		return array;
	}

    public static long[][] sort(long[][] array) {
    	//Sort an array (immune to quicksort TLE)
		Random rgen = new Random();
		for (int i = 0; i < array.length; i++) {
		    int randomPosition = rgen.nextInt(array.length);
		    long[] temp = array[i];
		    array[i] = array[randomPosition];
		    array[randomPosition] = temp;
		}
		Arrays.sort(array, new Comparator<long[]>() {
			  @Override
        	  public int compare(long[] a, long[] b) {
				  if (a[0] < b[0])
					  return -1;
				  else
					  return 1;
	          }
		});
		return array;
	}

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int ni() {
            return Integer.parseInt(next());
        }

        long nl() {
            return Long.parseLong(next());
        }

        double nd() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}