#include <bits/stdc++.h>
using namespace std;
bool ok = 1, vis[1002][1002];
pair<int, int> a[1002][1002];
char ans[1002][1002];
int n;
void fill(int i, int j) {
  if (i < 1 || j < 1 || i > n || j > n || vis[i][j]) return;
  vis[i][j] = 1;
  if (a[i][j + 1] == a[i][j] && !vis[i][j + 1])
    ans[i][j + 1] = 'L', fill(i, j + 1);
  if (a[i][j - 1] == a[i][j] && !vis[i][j - 1])
    ans[i][j - 1] = 'R', fill(i, j - 1);
  if (a[i + 1][j] == a[i][j] && !vis[i + 1][j])
    ans[i + 1][j] = 'U', fill(i + 1, j);
  if (a[i - 1][j] == a[i][j] && !vis[i - 1][j])
    ans[i - 1][j] = 'D', fill(i - 1, j);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j) cin >> a[i][j].first >> a[i][j].second;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      if (!vis[i][j] && a[i][j] == make_pair(i, j)) ans[i][j] = 'X', fill(i, j);
      if (!vis[i][j] && a[i][j] == make_pair(-1, -1)) {
        if (a[i - 1][j] == a[i][j])
          ans[i][j] = 'U';
        else if (a[i + 1][j] == a[i][j])
          ans[i][j] = 'D';
        else if (a[i][j - 1] == a[i][j])
          ans[i][j] = 'L';
        else if (a[i][j + 1] == a[i][j])
          ans[i][j] = 'R';
        else
          ok = 0;
        fill(i, j);
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      if (!vis[i][j] || !ans[i][j]) {
        ok = 0;
        break;
      }
    }
  }
  if (!ok) {
    cout << "INVALID";
    return 0;
  }
  cout << "VALID\n";
  for (int i = 1; i <= n; ++i, cout << '\n')
    for (int j = 1; j <= n; ++j) cout << ans[i][j];
}
