#include <bits/stdc++.h>
using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
const int N = 1e3 + 1;
int x[N][N], y[N][N], e[N][N], used[N][N];
int di[4] = {0, 0, -1, 1}, dj[4] = {1, -1, 0, 0}, n;
bool fl = 1;
void dfs(int xi, int yi) {
  used[xi][yi] = 1;
  bool f = 0;
  for (int i = 0; i < 4; i++) {
    int ni = xi + di[i], nj = yi + dj[i];
    if (ni < 0 || nj < 0 || ni == n || nj == n) continue;
    if (x[ni][nj] == -1) {
      e[xi][yi] = i;
      f = 1;
    }
    if (!used[ni][nj] && x[ni][nj] == -1) {
      dfs(ni, nj);
    }
  }
  if (!f) fl = 0;
}
void dfs2(int xi, int yi) {
  used[xi][yi] = 1;
  for (int i = 0; i < 4; i++) {
    int ni = xi + di[i], nj = yi + dj[i];
    if (ni < 0 || nj < 0 || ni == n || nj == n) continue;
    if (x[ni][nj] == x[xi][yi] && y[ni][nj] == y[xi][yi] && !used[ni][nj]) {
      if (i == 0) {
        e[ni][nj] = 1;
      }
      if (i == 1) {
        e[ni][nj] = 0;
      }
      if (i == 2) {
        e[ni][nj] = 3;
      }
      if (i == 3) {
        e[ni][nj] = 2;
      }
      dfs2(ni, nj);
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  queue<pair<int, int> > q;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> x[i][j] >> y[i][j];
      if (x[i][j] != -1) {
        x[i][j]--, y[i][j]--;
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (x[i][j] == -1 && !used[i][j]) {
        dfs(i, j);
      }
    }
  }
  if (!fl) {
    cout << "INVALID";
    return 0;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (x[i][j] == i && y[i][j] == j && !used[i][j]) {
        e[i][j] = 5;
        dfs2(i, j);
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (used[i][j] == 0) {
        cout << "INVALID";
        return 0;
      }
    }
  }
  cout << "VALID\n";
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (e[i][j] == 5) {
        cout << 'X';
      } else if (e[i][j] == 0) {
        cout << 'R';
      } else if (e[i][j] == 1)
        cout << 'L';
      else if (e[i][j] == 2)
        cout << 'U';
      else
        cout << 'D';
    }
    cout << endl;
  }
}
