#include <bits/stdc++.h>
using namespace std;
int n, x[1500][1500], y[1500][1500], vis[1510][1500];
char ans[1500][1500];
struct node {
  int x, y;
};
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
vector<node> a;
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]);
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (x[i][j] != -1 && !vis[x[i][j]][y[i][j]]) {
        if (x[x[i][j]][y[i][j]] == -1 || x[x[i][j]][y[i][j]] != x[i][j] ||
            y[x[i][j]][y[i][j]] != y[i][j]) {
          printf("INVALID\n");
          return 0;
        }
        a.push_back(node{x[i][j], y[i][j]});
        ans[x[i][j]][y[i][j]] = 'X';
        vis[x[i][j]][y[i][j]] = 1;
      }
    }
  }
  queue<node> q;
  for (int j = 0; j < a.size(); j++) {
    q.push(a[j]);
    while (!q.empty()) {
      node now = q.front();
      q.pop();
      for (int i = 0; i < 4; i++) {
        int xx = now.x + dx[i];
        int yy = now.y + dy[i];
        if (xx <= 0 || yy <= 0 || xx > n || yy > n || x[xx][yy] != a[j].x ||
            y[xx][yy] != a[j].y)
          continue;
        if (!vis[xx][yy]) {
          vis[xx][yy] = 1;
          q.push(node{xx, yy});
          if (i == 0) ans[xx][yy] = 'L';
          if (i == 1) ans[xx][yy] = 'R';
          if (i == 2) ans[xx][yy] = 'U';
          if (i == 3) ans[xx][yy] = 'D';
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (x[i][j] != -1 && !vis[i][j]) {
        printf("INVALID\n");
        return 0;
      }
      if (x[i][j] == -1 && !vis[i][j]) {
        q.push(node{i, j});
        vis[i][j] = 1;
        int flag = 0;
        while (!q.empty()) {
          node now = q.front();
          q.pop();
          for (int k = 0; k < 4; k++) {
            int xx = now.x + dx[k];
            int yy = now.y + dy[k];
            if (xx <= 0 || yy <= 0 || xx > n || yy > n || x[xx][yy] != -1)
              continue;
            if (x[xx][yy] == -1 && vis[xx][yy]) {
              if (!flag) {
                if (k == 0) ans[i][j] = 'R';
                if (k == 1) ans[i][j] = 'L';
                if (k == 2) ans[i][j] = 'D';
                if (k == 3) ans[i][j] = 'U';
                flag = 1;
              }
            }
            if (!vis[xx][yy]) {
              vis[xx][yy] = 1;
              q.push(node{xx, yy});
              if (k == 0) ans[xx][yy] = 'L';
              if (k == 1) ans[xx][yy] = 'R';
              if (k == 2) ans[xx][yy] = 'U';
              if (k == 3) ans[xx][yy] = 'D';
              if (!flag) {
                if (k == 0) ans[i][j] = 'R';
                if (k == 1) ans[i][j] = 'L';
                if (k == 2) ans[i][j] = 'D';
                if (k == 3) ans[i][j] = 'U';
                flag = 1;
              }
            }
          }
          if (!flag) {
            printf("INVALID\n");
            return 0;
          }
        }
      }
    }
  }
  printf("VALID\n");
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      printf("%c", ans[i][j]);
    }
    cout << endl;
  }
}
