#include <bits/stdc++.h>
using namespace std;
const int maxn = 1010;
int n, num, kk;
int x[maxn][maxn], y[maxn][maxn];
int cnt[maxn][maxn], d[maxn][maxn];
int dx[4] = {0, 0, 1, -1};
int dy[4] = {1, -1, 0, 0};
void dfs(int cx, int cy, int tx, int ty, int dir) {
  kk++;
  d[cx][cy] = dir;
  for (int i = 0; i < 4; i++) {
    int nx = cx + dx[i];
    int ny = cy + dy[i];
    if (x[nx][ny] == tx && y[nx][ny] == ty && d[nx][ny] == -1) {
      dfs(nx, ny, tx, ty, i);
    }
  }
}
void find_path(int cx, int cy, int dir) {
  kk++;
  d[cx][cy] = dir;
  for (int i = 0; i < 4; i++) {
    int nx = cx + dx[i];
    int ny = cy + dy[i];
    if (d[nx][ny] == -1 && nx >= 1 && nx <= n && ny >= 1 && ny <= n) {
      find_path(nx, ny, i);
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      scanf("%d%d", &x[i][j], &y[i][j]);
      if (x[i][j] != -1 && y[i][j] != -1) {
        cnt[x[i][j]][y[i][j]]++;
      }
    }
  }
  bool jud = 1;
  memset(d, -1, sizeof(d));
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (cnt[i][j]) {
        if (!(x[i][j] == i && y[i][j] == j)) {
          jud = 0;
          break;
        }
        kk = 0;
        dfs(i, j, i, j, 4);
        if (kk != cnt[i][j]) {
          jud = 0;
          break;
        }
      }
    }
    if (!jud) break;
  }
  if (!jud) {
    printf("INVALID\n");
    return 0;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (d[i][j] == -1) {
        kk = 0;
        find_path(i, j, 4);
        if (kk == 1) {
          jud = 0;
          break;
        }
        int tmp;
        for (int k = 0; k < 4; k++) {
          int nx = i + dx[k];
          int ny = j + dy[k];
          if (nx >= 1 && nx <= n && ny >= 1 && ny <= n && d[nx][ny] == k) {
            tmp = k;
            break;
          }
        }
        for (int k = 0; k < 4; k++) {
          if (dx[tmp] == -dx[k] && dy[tmp] == -dy[k]) d[i][j] = k;
        }
      }
    }
    if (!jud) break;
  }
  if (!jud) {
    printf("INVALID\n");
    return 0;
  }
  printf("VALID\n");
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (d[i][j] == 4)
        printf("X");
      else {
        if (d[i][j] == 0) printf("L");
        if (d[i][j] == 1) printf("R");
        if (d[i][j] == 2) printf("U");
        if (d[i][j] == 3) printf("D");
      }
    }
    printf("\n");
  }
  return 0;
}
