#include <bits/stdc++.h>
using namespace std;
const int N = 1010, M = 4;
const pair<int, int> BAD = pair<int, int>(-1, -1);
int n, delta_x[] = {0, 0, 1, -1}, delta_y[] = {1, -1, 0, 0};
char go[] = {'R', 'L', 'D', 'U'}, come[] = {'L', 'R', 'U', 'D'};
char c[N][N];
bool mark[N][N];
pair<int, int> p[N][N];
queue<pair<int, int> > q;
void NO() {
  cout << "INVALID\n";
  exit(0);
}
bool is_val(int x, int y) { return 0 <= min(x, y) && max(x, y) < n; }
void bfs(pair<int, int> me) {
  for (int i = 0; i < M; i++) {
    int x = me.first + delta_x[i], y = me.second + delta_y[i];
    if (is_val(x, y) && p[x][y] == p[me.first][me.second] &&
        mark[x][y] == false) {
      mark[x][y] = true;
      c[x][y] = come[i];
      q.push(pair<int, int>(x, y));
    }
  }
}
void input() {
  cin >> n;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      cin >> p[i][j].first >> p[i][j].second;
      if (p[i][j] != BAD) {
        p[i][j].first--;
        p[i][j].second--;
      }
    }
}
void solve() {
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if (p[i][j] == pair<int, int>(i, j)) {
        mark[i][j] = true;
        c[i][j] = 'X';
        q.push(pair<int, int>(i, j));
      }
  while (q.size()) {
    bfs(q.front());
    q.pop();
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if (p[i][j] == BAD) {
        for (int type = 0; type < M; type++) {
          int x = i + delta_x[type], y = j + delta_y[type];
          if (is_val(x, y) && p[x][y] == p[i][j]) {
            c[i][j] = go[type];
            break;
          }
          if (type == (M - 1)) NO();
        }
      } else if (mark[i][j] == false)
        NO();
}
void output() {
  cout << "VALID\n";
  for (int i = 0; i < n; i++, cout << '\n')
    for (int j = 0; j < n; j++) cout << c[i][j];
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  input();
  solve();
  output();
}
