#include <bits/stdc++.h>
using namespace std;
vector<vector<pair<int, int>>> grid;
vector<vector<char>> ans;
vector<vector<bool>> visit;
int dl[] = {-1, 1, 0, 0};
int dc[] = {0, 0, -1, 1};
string letra = "UDLR";
string letras = "DURL";
char verify(int u, int v, int n) {
  for (int i = 0; i < 4; i++) {
    int x = u + dl[i];
    int y = v + dc[i];
    if (x < 0 || x >= n || y < 0 || y >= n) continue;
    if (grid[x][y] == make_pair(-1, -1)) {
      return letra[i];
    }
  }
  return 'X';
}
void bfs(int u, int v, int fu, int fv, char let, int n) {
  if (visit[u][v]) return;
  ans[u][v] = let;
  visit[u][v] = true;
  for (int i = 0; i < 4; i++) {
    int x = u + dl[i];
    int y = v + dc[i];
    if (x < 0 || x >= n || y < 0 || y >= n) continue;
    if (grid[x][y] == make_pair(fu, fv)) bfs(x, y, fu, fv, letras[i], n);
  }
}
bool solve(int n) {
  queue<pair<int, int>> q;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (grid[i][j] == make_pair(-1, -1)) {
        char ret = verify(i, j, n);
        if (ret == 'X') return false;
        q.push({i, j});
      }
    }
  }
  while (!q.empty()) {
    pair<int, int> topo = q.front();
    q.pop();
    int u = topo.first;
    int v = topo.second;
    visit[u][v] = true;
    char ret = verify(u, v, n);
    ans[u][v] = ret;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (grid[i][j] == make_pair(i, j)) {
        bfs(i, j, i, j, 'X', n);
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (visit[i][j] == false) return false;
    }
  }
  return true;
}
int main() {
  int n;
  scanf("%d", &n);
  grid.resize(n);
  ans.resize(n);
  visit.resize(n);
  for (int i = 0; i < n; i++) {
    ans[i].resize(n);
    grid[i].resize(n);
    for (int j = 0; j < n; j++) {
      visit[i].push_back(false);
      int u, v;
      scanf("%d %d", &u, &v);
      if (u == -1 && v == -1) {
        grid[i][j] = make_pair(u, v);
      } else {
        u--;
        v--;
        grid[i][j] = make_pair(u, v);
      }
    }
  }
  bool ok = solve(n);
  if (ok == false) {
    printf("INVALID\n");
    return 0;
  }
  printf("VALID\n");
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      printf("%c", ans[i][j]);
    }
    printf("\n");
  }
}
