#include <bits/stdc++.h>
using namespace std;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1, -1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
string dir_come = "LRUD";
string dir_go = "RLDU";
const double pi = acos(-1.0);
const double eps = 1e-6;
const int mod = (int)1e9 + 7;
const int maxn = 1005;
const int logn = 20;
pair<int, int> to[maxn][maxn];
int n;
char g[maxn][maxn];
bool vis[maxn][maxn];
bool done[maxn][maxn];
void dfs(int r, int c, pair<int, int> p) {
  for (int i = 0; i < (4); i++) {
    int nr = r + dx4[i];
    int nc = c + dy4[i];
    if (nr > n || nc > n || nr < 0 || nc > n) continue;
    if (vis[nr][nc]) continue;
    if (to[nr][nc] != p) continue;
    vis[nr][nc] = 1;
    g[nr][nc] = dir_come[i];
    dfs(nr, nc, p);
  }
}
void filup(int r, int c) {
  bool ok = 0;
  for (int i = 0; i < (4); i++) {
    int nr = r + dx4[i];
    int nc = c + dy4[i];
    if (nr > n || nc > n || nr < 0 || nc > n) continue;
    if (to[nr][nc].first != -1) continue;
    g[r][c] = dir_go[i];
    done[r][c] = 1;
    if (!done[nr][nc]) filup(nr, nc);
    ok = 1;
  }
  if (!ok) {
    cout << "INVALID\n";
    exit(0);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  for (int i = 1; i <= (n); i++) {
    for (int j = 1; j <= (n); j++) {
      g[i][j] = '.';
    }
  }
  vector<pair<int, int> > des;
  for (int i = 1; i <= (n); i++) {
    for (int j = 1; j <= (n); j++) {
      cin >> to[i][j].first >> to[i][j].second;
      if (to[i][j].first == i && to[i][j].second == j) {
        g[i][j] = 'X';
        des.push_back(make_pair(i, j));
      }
    }
  }
  for (pair<int, int> p : des) {
    for (int i = 0; i < (4); i++) {
      vis[p.first][p.second] = 1;
      dfs(p.first, p.second, p);
    }
  }
  for (int i = 1; i <= (n); i++) {
    for (int j = 1; j <= (n); j++)
      if (to[i][j].first == -1) {
        filup(i, j);
      }
  }
  for (int i = 1; i <= (n); i++) {
    for (int j = 1; j <= (n); j++) {
      if (g[i][j] == '.') {
        cout << "INVALID\n";
        return 0;
      }
    }
  }
  cout << "VALID\n";
  for (int i = 1; i <= (n); i++) {
    for (int j = 1; j <= (n); j++) {
      cout << g[i][j];
    }
    cout << "\n";
  }
  return 0;
}
