#include <bits/stdc++.h>
using namespace std;
const long long int inf = (long long int)2e18;
const int mod = 1e9 + 7;
bool overflow(long long int a, long long int b) {
  if (a <= (inf + b - 1) / b) return false;
  return true;
}
int visited[1005][1005];
pair<int, int> a[1005][1005];
char s[1005][1005];
int n;
int xi[] = {-1, 1, 0, 0};
int yi[] = {0, 0, -1, 1};
char m[] = {'U', 'D', 'L', 'R'};
char rev[] = {'D', 'U', 'R', 'L'};
bool isvalid(int i, int j) { return (i >= 0 && j >= 0 && i < n && j < n); }
int dfs(int i, int j) {
  if (visited[i][j]) {
    return 1;
  }
  visited[i][j]++;
  for (int k = 0; k < 4; k++) {
    if (isvalid(i + xi[k], j + yi[k]) && a[i + xi[k]][j + yi[k]].first == -1) {
      s[i][j] = m[k];
      if (dfs(i + xi[k], j + yi[k])) return 1;
    }
  }
  visited[i][j] = 0;
  return 0;
}
void dfs2(int i, int j) {
  visited[i][j]++;
  for (int k = 0; k < 4; k++) {
    if (isvalid(i + xi[k], j + yi[k]) && !visited[i + xi[k]][j + yi[k]] &&
        a[i + xi[k]][j + yi[k]] == a[i][j]) {
      s[i + xi[k]][j + yi[k]] = rev[k];
      dfs2(i + xi[k], j + yi[k]);
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n;
  int i, j;
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      cin >> a[i][j].first >> a[i][j].second;
      if (a[i][j].first != -1) {
        a[i][j].first--, a[i][j].second--;
      }
      if (a[i][j].first == i && a[i][j].second == j) s[i][j] = 'X';
    }
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      if (!visited[i][j] && a[i][j].first == -1) {
        if (!dfs(i, j)) {
          cout << "INVALID"
               << "\n";
          return 0;
        }
      }
      if (a[i][j].first == i && a[i][j].second == j) {
        dfs2(i, j);
      }
    }
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      if (!visited[i][j]) {
        cout << "INVALID"
             << "\n";
        return 0;
      }
    }
  }
  cout << "VALID"
       << "\n";
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) cout << s[i][j];
    cout << "\n";
  }
}
