#include <bits/stdc++.h>
using namespace std;
vector<int> dx, dy;
int n, x[1005][1005], y[1005][1005], inQ[1005][1005];
char board[1005][1005];
int Fx[4] = {1, 0, -1, 0};
int Fy[4] = {0, 1, 0, -1};
string Fc = "ULDR";
bool totbfs(int sx, int sy, int tx, int ty) {
  vector<int> Qx, Qy;
  Qx.push_back(sx);
  Qy.push_back(sy);
  inQ[sx][sy] = 1;
  while (!Qx.empty()) {
    int xx = Qx.front();
    int yy = Qy.front();
    Qx.erase(Qx.begin());
    Qy.erase(Qy.begin());
    for (int i = 0; i < 4; i++) {
      int nx = xx + Fx[i];
      int ny = yy + Fy[i];
      if (1 <= nx && nx <= n && 1 <= ny && ny <= n && x[nx][ny] == tx &&
          y[nx][ny] == ty && !inQ[nx][ny]) {
        if (board[nx][ny] != '\0') return false;
        board[nx][ny] = Fc[i];
        if (!inQ[nx][ny]) {
          Qx.push_back(nx);
          Qy.push_back(ny);
          inQ[nx][ny] = 1;
        }
      }
    }
  }
  return true;
}
bool bfs(int sx, int sy) { return totbfs(sx, sy, sx, sy); }
bool cycle() {
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (x[i][j] == -1 && y[i][j] == -1 && !inQ[i][j]) {
        if (board[i][j] != '\0') return false;
        int d, nx, ny;
        for (d = 0; d < 4; d++) {
          nx = i + Fx[d];
          ny = j + Fy[d];
          if (1 <= nx && nx <= n && 1 <= ny && ny <= n && x[nx][ny] == -1 &&
              y[nx][ny] == -1 && !inQ[nx][ny]) {
            if (board[i][j] != '\0') return false;
            break;
          }
        }
        if (d == 4) return false;
        board[nx][ny] = Fc[d];
        board[i][j] = Fc[(d + 2) % 4];
        inQ[nx][ny] = inQ[i][j] = 1;
        if (totbfs(i, j, -1, -1) == false) return false;
        if (totbfs(nx, ny, -1, -1) == false) return false;
      }
    }
  }
  return true;
}
bool solve() {
  for (int i = 0; i <= n + 1; i++)
    for (int j = 0; j <= n + 1; j++) {
      board[i][j] = '\0';
      inQ[i][j] = 0;
    }
  for (int k = 0; k < dx.size(); k++) {
    board[dx[k]][dy[k]] = 'X';
    inQ[dx[k]][dy[k]] = 1;
  }
  for (int k = 0; k < dx.size(); k++)
    if (bfs(dx[k], dy[k]) == false) return false;
  if (cycle() == false) return false;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      if (board[i][j] == '\0') return false;
  return true;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      scanf("%d%d", &x[i][j], &y[i][j]);
      if (i == x[i][j] && j == y[i][j]) {
        dx.push_back(i);
        dy.push_back(j);
      }
    }
  }
  if (solve()) {
    printf("VALID\n");
    for (int i = 1; i <= n; i++) {
      printf("%s\n", board[i] + 1);
    }
  } else {
    printf("INVALID\n");
  }
}
