#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
const int N = 1e3 + 10;
pair<int, int> ma[N][N];
char ans[N][N];
char s[5] = "ULDR";
int vis[N][N], dir[4][2] = {1, 0, 0, 1, -1, 0, 0, -1};
int fll = 1, n;
void bfs(pair<int, int> p) {
  queue<pair<int, int> > que;
  que.push(p);
  ans[p.first][p.second] = 'X';
  vis[p.first][p.second] = 1;
  while (que.size()) {
    pair<int, int> np = que.front();
    que.pop();
    for (int i = 0; i < 4; i++) {
      int x = np.first + dir[i][0];
      int y = np.second + dir[i][1];
      if (x < 1 || x > n || y < 1 || y > n) continue;
      if (vis[x][y]) continue;
      if (ma[x][y] != p) continue;
      vis[x][y] = 1;
      ans[x][y] = s[i];
      que.push(pair<int, int>(x, y));
    }
  }
}
void bfs1(pair<int, int> p) {
  queue<pair<int, int> > que;
  que.push(p);
  vis[p.first][p.second] = 1;
  int f = 0;
  while (que.size()) {
    pair<int, int> np = que.front();
    que.pop();
    for (int i = 0; i < 4; i++) {
      int x = np.first + dir[i][0];
      int y = np.second + dir[i][1];
      if (x < 1 || x > n || y < 1 || y > n) continue;
      if (vis[x][y]) continue;
      if (ma[x][y] != pair<int, int>(-1, -1)) continue;
      if (!f) {
        f = 1;
        ans[p.first][p.second] = s[(i + 2) % 4];
      }
      vis[x][y] = 1;
      ans[x][y] = s[i];
      que.push(pair<int, int>(x, y));
    }
  }
  fll &= f;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= (n); ++i)
    for (int j = 1; j <= (n); ++j)
      scanf("%d %d", &ma[i][j].first, &ma[i][j].second);
  for (int i = 1; i <= (n); ++i)
    for (int j = 1; j <= (n); ++j)
      if (!vis[i][j] && ma[i][j] == pair<int, int>(i, j))
        bfs(pair<int, int>(i, j));
  for (int i = 1; i <= (n); ++i)
    for (int j = 1; j <= (n); ++j)
      if (!vis[i][j] && ma[i][j] == pair<int, int>(-1, -1))
        bfs1(pair<int, int>(i, j));
  for (int i = 1; i <= (n); ++i)
    for (int j = 1; j <= (n); ++j)
      if (!vis[i][j]) fll = 0;
  if (!fll)
    puts("INVALID");
  else {
    puts("VALID");
    for (int i = 1; i <= (n); ++i) {
      for (int j = 1; j <= (n); ++j) printf("%c", ans[i][j]);
      puts("");
    }
  }
  return 0;
}
