#include <bits/stdc++.h>
using namespace std;
bool vis[1001][1001];
pair<long long int, long long int> ar[1001][1001];
char c[1001][1001];
long long int n;
void dfs(pair<long long int, long long int> a,
         pair<long long int, long long int> b) {
  vis[a.first][a.second] = true;
  if (a.first > 1 && ar[a.first - 1][a.second] == b &&
      !vis[a.first - 1][a.second]) {
    c[a.first - 1][a.second] = 'D';
    dfs({a.first - 1, a.second}, b);
  }
  if (a.first < n && ar[a.first + 1][a.second] == b &&
      !vis[a.first + 1][a.second]) {
    c[a.first + 1][a.second] = 'U';
    dfs({a.first + 1, a.second}, b);
  }
  if (a.second > 1 && ar[a.first][a.second - 1] == b &&
      !vis[a.first][a.second - 1]) {
    c[a.first][a.second - 1] = 'R';
    dfs({a.first, a.second - 1}, b);
  }
  if (a.second < n && ar[a.first][a.second + 1] == b &&
      !vis[a.first][a.second + 1]) {
    c[a.first][a.second + 1] = 'L';
    dfs({a.first, a.second + 1}, b);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  queue<pair<long long int, long long int>> ae;
  memset(vis, false, sizeof(vis));
  for (long long int x = 1; x <= n; x++) {
    long long int a, b;
    for (long long int y = 1; y <= 2 * n; y += 2) {
      cin >> a >> b;
      long long int u = (y + 1) / 2;
      ar[x][u] = {a, b};
      if (a == x && b == u) {
        ae.push({x, u});
        c[x][u] = 'X';
        vis[x][u] = true;
      }
    }
  }
  bool k = true;
  while (!ae.empty()) {
    dfs(ae.front(), ae.front());
    ae.pop();
  }
  for (int x = 1; x <= n; x++)
    for (int y = 1; y <= n; y++) {
      if (!vis[x][y]) {
        if (ar[x][y] == make_pair(-1ll, -1ll)) {
          if (x > 1 && !vis[x - 1][y] &&
              ar[x - 1][y] == make_pair(-1ll, -1ll)) {
            c[x + 1][y] = 'D';
            c[x][y] = 'U';
            vis[x - 1][y] = vis[x][y] = true;
            dfs({x - 1, y}, {-1, -1});
          } else if (x < n && !vis[x + 1][y] &&
                     ar[x + 1][y] == make_pair(-1ll, -1ll)) {
            c[x + 1][y] = 'U';
            c[x][y] = 'D';
            vis[x + 1][y] = vis[x][y] = true;
            dfs({x + 1, y}, {-1, -1});
          } else if (y > 1 && !vis[x][y - 1] &&
                     ar[x][y - 1] == make_pair(-1ll, -1ll)) {
            c[x][y - 1] = 'R';
            c[x][y] = 'L';
            vis[x][y] = vis[x][y - 1] = true;
            dfs({x, y - 1}, {-1, -1});
          } else if (y < n && !vis[x][y + 1] &&
                     ar[x][y + 1] == make_pair(-1ll, -1ll)) {
            c[x][y + 1] = 'L';
            c[x][y] = 'R';
            vis[x][y] = vis[x][y + 1] = true;
            dfs({x, y + 1}, {-1, -1});
          } else
            k = false;
        } else
          k = false;
        dfs({x, y}, {-1, -1});
      }
    }
  if (k) {
    cout << "VALID\n";
    for (int x = 1; x <= n; x++) {
      for (int y = 1; y <= n; y++) cout << c[x][y];
      cout << "\n";
    }
  } else {
    cout << "INVALID\n";
  }
}
