#include <bits/stdc++.h>
using namespace std;
struct xy {
  long long x, y;
} M[1005][1005];
long long A[1005][1005];
long long B[1005][1005];
struct str {
  long long i, j, x, y;
};
char R[1005][1005];
long long V[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
char RV[4] = {'U', 'L', 'D', 'R'};
long long n;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  queue<str> Q;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < n; j++) {
      R[i][j] = '-';
      cin >> M[i][j].x;
      cin >> M[i][j].y;
      M[i][j].x--;
      M[i][j].y--;
      if (i == M[i][j].x and j == M[i][j].y) {
        Q.push({i, j, i, j});
        R[i][j] = 'X';
        A[i][j] = 1;
      }
    }
  }
  while (!Q.empty()) {
    long long i = Q.front().i;
    long long j = Q.front().j;
    long long x = Q.front().x;
    long long y = Q.front().y;
    Q.pop();
    for (long long k = 0; k < 4; k++) {
      long long ni = i + V[k][0], nj = j + V[k][1];
      if (ni >= 0 and ni < n and nj >= 0 and nj < n and A[ni][nj] == 0) {
        if (M[ni][nj].x == x and M[ni][nj].y == y) {
          R[ni][nj] = RV[k];
          A[ni][nj] = 1;
          Q.push({ni, nj, x, y});
        }
      }
    }
  }
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < n; j++) {
      if (M[i][j].x == -2 and M[i][j].y == -2) {
        for (long long k = 0; k < 4; k++) {
          long long ni = i + V[k][0], nj = j + V[k][1];
          long long ok = 0;
          if (ni >= 0 and ni < n and nj >= 0 and nj < n) {
            if (M[ni][nj].x == -2 and M[ni][nj].y == -2) {
              if (A[ni][nj] == 0) {
                R[ni][nj] = RV[k];
                A[ni][nj] = 1;
              }
              A[i][j] = 1;
              R[i][j] = RV[(k + 2) % 4];
              break;
            }
          }
        }
      }
    }
  }
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < n; j++) {
      if (R[i][j] == '-') {
        cout << "INVALID\n";
        return 0;
      }
    }
  }
  cout << "VALID\n";
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < n; j++) {
      cout << R[i][j];
    }
    cout << "\n";
  }
}
