#include <bits/stdc++.h>
using namespace std;
int n;
int x, y, tot;
int as[1005][1005];
char ans[1005][1005];
int mp[1005][1005];
struct {
  int x, y;
} a[1000005];
int dir[4][2] = {1, 0, -1, 0, 0, 1, 0, -1};
char s[10] = "UDLR";
void bfs(int x, int y, int nm) {
  as[x][y] = -2;
  for (int i = 0; i < 4; i++) {
    int dx = x + dir[i][0], dy = y + dir[i][1];
    if (as[dx][dy] == nm) {
      ans[dx][dy] = s[i];
      bfs(dx, dy, nm);
    }
  }
}
int main() {
  bool f = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      scanf("%d%d", &x, &y);
      if (x == -1) {
        as[i][j] = -1;
      } else {
        if (mp[x][y]) {
          if (as[i][j]) {
            if (as[i][j] != mp[x][y]) f = 1;
          }
          as[i][j] = mp[x][y];
        } else {
          mp[x][y] = ++tot;
          a[tot].x = x, a[tot].y = y;
          if (as[i][j]) {
            if (as[i][j] != tot) f = 1;
          }
          as[i][j] = mp[x][y];
        }
      }
    }
  }
  for (int i = 1; i <= tot; i++) {
    if (as[a[i].x][a[i].y] != i) {
      f = 1;
      break;
    }
    ans[a[i].x][a[i].y] = 'X';
    bfs(a[i].x, a[i].y, i);
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (as[i][j] == -1) {
        if (as[i + 1][j] == -1) {
          ans[i][j] = 'D';
          as[i][j] = -2;
          bfs(i, j, -1);
        } else if (as[i][j + 1] == -1) {
          ans[i][j] = 'R';
          as[i][j] = -2;
          bfs(i, j, -1);
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (as[i][j] != -2) {
        f = 1;
        break;
      }
    }
    if (f) break;
  }
  if (f)
    puts("INVALID");
  else {
    puts("VALID");
    for (int i = 1; i <= n; i++) {
      printf("%s\n", ans[i] + 1);
    }
  }
}
