#include <bits/stdc++.h>
using namespace std;
int64_t pow3(int64_t a, int64_t b, int64_t m = 1000000007) {
  int64_t res = 1;
  while (b > 0) {
    if (b & 1) res = (res * a) % m;
    a = (a * a) % m;
    b >>= 1;
  }
  return res;
}
void solve() {
  int64_t n;
  cin >> n;
  pair<int64_t, int64_t> x[n + 2][n + 2];
  for (int64_t i = 0; i < n + 2; i++)
    for (int64_t j = 0; j < n + 2; j++) x[i][j] = make_pair(-2, -2);
  for (int64_t i = 1; i < n + 1; i++)
    for (int64_t j = 1; j < n + 1; j++) cin >> x[i][j].first >> x[i][j].second;
  bool vis[n + 1][n + 1];
  for (int64_t i = 1; i < n + 1; i++)
    for (int64_t j = 1; j < n + 1; j++) vis[i][j] = false;
  char ans[n + 1][n + 1];
  for (int64_t i = 0; i < n + 1; i++)
    for (int64_t j = 0; j < n + 1; j++) ans[i][j] = '.';
  for (int64_t i = 1; i < n + 1; i++)
    for (int64_t j = 1; j < n + 1; j++) {
      if (x[i][j].first == i && x[i][j].second == j && !vis[i][j]) {
        ans[i][j] = 'X';
        vis[i][j] = true;
        queue<pair<int64_t, int64_t> > bfs;
        bfs.push(make_pair(i, j));
        while (!bfs.empty()) {
          auto xx = bfs.front();
          int64_t i = xx.first, j = xx.second;
          bfs.pop();
          if (x[i - 1][j].first == x[i][j].first &&
              x[i - 1][j].second == x[i][j].second && !vis[i - 1][j]) {
            bfs.push(make_pair(i - 1, j));
            vis[i - 1][j] = true;
            ans[i - 1][j] = 'D';
          }
          if (x[i + 1][j].first == x[i][j].first &&
              x[i + 1][j].second == x[i][j].second && !vis[i + 1][j]) {
            bfs.push(make_pair(i + 1, j));
            vis[i + 1][j] = true;
            ans[i + 1][j] = 'U';
          }
          if (x[i][j - 1].first == x[i][j].first &&
              x[i][j - 1].second == x[i][j].second && !vis[i][j - 1]) {
            bfs.push(make_pair(i, j - 1));
            vis[i][j - 1] = true;
            ans[i][j - 1] = 'R';
          }
          if (x[i][j + 1].first == x[i][j].first &&
              x[i][j + 1].second == x[i][j].second && !vis[i][j + 1]) {
            bfs.push(make_pair(i, j + 1));
            vis[i][j + 1] = true;
            ans[i][j + 1] = 'L';
          }
        }
      } else if (x[i][j].first == -1 && !vis[i][j]) {
        if (x[i + 1][j].first == -1 && !vis[i + 1][j]) {
          ans[i][j] = 'D';
          ans[i + 1][j] = 'U';
          vis[i][j] = vis[i + 1][j] = true;
        } else if (x[i - 1][j].first == -1 && !vis[i - 1][j]) {
          ans[i][j] = 'U';
          ans[i - 1][j] = 'D';
          vis[i][j] = vis[i - 1][j] = true;
        } else if (x[i][j + 1].first == -1 && !vis[i][j + 1]) {
          ans[i][j] = 'R';
          ans[i][j + 1] = 'L';
          vis[i][j] = vis[i][j + 1] = true;
        } else if (x[i][j - 1].first == -1 && !vis[i][j - 1]) {
          ans[i][j] = 'L';
          ans[i][j - 1] = 'R';
          vis[i][j] = vis[i][j - 1] = true;
        } else if (x[i + 1][j].first == -1) {
          ans[i][j] = 'D';
          vis[i][j] = true;
        } else if (x[i - 1][j].first == -1) {
          ans[i][j] = 'U';
          vis[i][j] = true;
        } else if (x[i][j + 1].first == -1) {
          ans[i][j] = 'R';
          vis[i][j] = true;
        } else if (x[i][j - 1].first == -1) {
          ans[i][j] = 'L';
          vis[i][j] = true;
        }
      }
    }
  for (int64_t i = 1; i < n + 1; i++)
    for (int64_t j = 1; j < n + 1; j++)
      if (ans[i][j] == '.') {
        cout << "INVALID" << endl;
        return;
      }
  cout << "VALID" << endl;
  for (int64_t i = 1; i < n + 1; i++) {
    for (int64_t j = 1; j < n + 1; j++) cout << ans[i][j];
    cout << endl;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int q = 1;
  while (q--) {
    solve();
  }
  return 0;
}
