#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 7;
pair<int, int> f[N][N];
pair<int, int> d[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}};
short ans[N][N];
void bfs(int i, int j, int p, pair<int, int> g) {
  if (p == -1)
    ans[i][j] = 5;
  else
    ans[i][j] = p + 1;
  for (int k = 0; k < (int)4; ++k)
    if (f[i + d[k].first][j + d[k].second] == g &&
        !ans[i + d[k].first][j + d[k].second])
      bfs(i + d[k].first, j + d[k].second, (k + 2) % 4, g);
}
void solve() {
  int n;
  cin >> n;
  for (int i = 1; i <= (int)n; ++i)
    for (int j = 1; j <= (int)n; ++j) cin >> f[i][j].first >> f[i][j].second;
  for (int i = 1; i <= (int)n; ++i)
    for (int j = 1; j <= (int)n; ++j) {
      if (f[i][j].first == -1 && !ans[i][j]) {
        bool ok = 0;
        for (int k = 0; k < (int)4; ++k)
          if (f[i + d[k].first][j + d[k].second].first == -1) {
            if (!ans[i + d[k].first][j + d[k].second])
              ans[i + d[k].first][j + d[k].second] = (k + 2) % 4 + 1;
            ans[i][j] = k + 1;
            ok = 1;
            break;
          }
        if (!ok) {
          cout << "INVALID";
          return;
        }
      } else if (f[i][j].first != -1) {
        if (!ans[f[i][j].first][f[i][j].second]) {
          if (f[f[i][j].first][f[i][j].second] != f[i][j]) {
            cout << "INVALID";
            return;
          }
          bfs(f[i][j].first, f[i][j].second, -1, f[i][j]);
        }
        if (!ans[i][j]) {
          cout << "INVALID";
          return;
        }
      }
    }
  cout << "VALID\n";
  for (int i = 1; i <= (int)n; ++i) {
    for (int j = 1; j <= (int)n; ++j) {
      if (ans[i][j] == 1) cout << "U";
      if (ans[i][j] == 2) cout << "R";
      if (ans[i][j] == 3) cout << "D";
      if (ans[i][j] == 4) cout << "L";
      if (ans[i][j] == 5) cout << "X";
    }
    cout << "\n";
  }
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
