#include <bits/stdc++.h>
using namespace std;
vector<vector<vector<int>>> v;
vector<int> d1, d2;
vector<vector<char>> ans;
vector<char> dir;
int n;
void dfs(int i, int j, int a, int b, vector<vector<int>> &vis, char ch) {
  ans[i][j] = ch;
  vis[i][j] = 1;
  for (int k = 0; k < 4; k++) {
    int x = i + d1[k];
    int y = j + d2[k];
    if (x < n && x >= 0 && y < n && y >= 0 && !vis[x][y] && v[x][y][0] == a &&
        v[x][y][1] == b)
      dfs(x, y, a, b, vis, dir[(k + 2) % 4]);
  }
}
void dfs2(int i, int j, vector<vector<int>> &vis) {
  vis[i][j] = 2;
  for (int k = 0; k < 4; k++) {
    int x = i + d1[k];
    int y = j + d2[k];
    if (x < n && x >= 0 && y < n && y >= 0 && vis[x][y] != 1 &&
        v[x][y][0] == -1) {
      if (!vis[x][y]) dfs2(x, y, vis);
      ans[i][j] = dir[k];
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) {
    cin >> n;
    v = vector<vector<vector<int>>>(n, vector<vector<int>>(n));
    ans = vector<vector<char>>(n, vector<char>(n, '.'));
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        int x, y;
        cin >> x >> y;
        x = max(-1, x - 1);
        y = max(-1, y - 1);
        v[i][j] = {x, y};
      }
    }
    d1 = {1, 0, -1, 0};
    d2 = {0, 1, 0, -1};
    dir = {'D', 'R', 'U', 'L'};
    vector<vector<int>> vis(n, vector<int>(n, 0));
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (!vis[i][j] && v[i][j][0] == -1)
          dfs2(i, j, vis);
        else if (!vis[i][j] && v[i][j][0] == i && v[i][j][1] == j)
          dfs(i, j, i, j, vis, 'X');
      }
    }
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (ans[i][j] == '.') {
          cout << "INVALID";
          return 0;
        }
      }
    }
    cout << "VALID" << endl;
    for (auto x : ans) {
      for (auto y : x) cout << y;
      cout << endl;
    }
  }
  return 0;
}
