#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e3 + 23;
pair<int, int> a[maxn][maxn];
int dx[] = {1, 0, -1, 0};
int dy[] = {0, -1, 0, 1};
char e[] = {'D', 'L', 'U', 'R'};
char ee[] = {'U', 'R', 'D', 'L'};
char s[maxn][maxn];
int n, m, T, p, k;
int id[maxn][maxn], vis[maxn][maxn];
void dfs(int first, int second, int b) {
  vis[first][second] = 1;
  if (id[first][second] == b) s[first][second] = 'X';
  for (int k = 0; k < 4; k++) {
    if (a[first][second] == a[first + dx[k]][second + dy[k]] &&
        vis[first + dx[k]][second + dy[k]] == 0) {
      s[first + dx[k]][second + dy[k]] = ee[k];
      dfs(first + dx[k], second + dy[k], b);
    }
  }
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) scanf("%d%d", &a[i][j].first, &a[i][j].second);
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) id[i][j] = (i - 1) * n + j;
  }
  bool flag = true;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (a[i][j].first == -1) {
        vis[i][j] = 1;
        bool t = false;
        for (int k = 0; k < 4; k++) {
          if (a[i + dx[k]][j + dy[k]].first == -1) {
            s[i][j] = e[k];
            t = true;
            break;
          }
        }
        flag &= t;
      }
    }
  }
  vector<pair<int, int> > t;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (a[i][j] == make_pair(i, j)) t.push_back(a[i][j]);
    }
  }
  sort(t.begin(), t.end());
  unique(t.begin(), t.end());
  for (pair<int, int> p : t) {
    dfs(p.first, p.second, id[p.first][p.second]);
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      flag &= vis[i][j] == 1;
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (a[i][j].first != -1) {
        int first = a[i][j].first, second = a[i][j].second;
        if (a[first][second] != a[i][j]) flag = false;
      }
    }
  }
  if (!flag)
    printf("INVALID");
  else {
    printf("VALID\n");
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) printf("%c", s[i][j]);
      puts("");
    }
  }
}
