#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 10, mod = 1e9 + 7;
char c[N][N];
pair<int, int> go[N][N];
int n;
bool mark[N][N];
inline bool in(int x, int y) {
  if (x < 0 || y < 0 || x >= n || y >= n) return false;
  return true;
}
void g(int x, int y) {
  mark[x][y] = true;
  if (in(x - 1, y) && go[x][y] == go[x - 1][y] && !mark[x - 1][y]) {
    c[x - 1][y] = 'D';
    g(x - 1, y);
  }
  if (in(x + 1, y) && go[x][y] == go[x + 1][y] && !mark[x + 1][y]) {
    c[x + 1][y] = 'U';
    g(x + 1, y);
  }
  if (in(x, y - 1) && go[x][y] == go[x][y - 1] && !mark[x][y - 1]) {
    c[x][y - 1] = 'R';
    g(x, y - 1);
  }
  if (in(x, y + 1) && go[x][y] == go[x][y + 1] && !mark[x][y + 1]) {
    c[x][y + 1] = 'L';
    g(x, y + 1);
  }
}
void gg(int x, int y) {
  if (in(x - 1, y) && go[x][y] == go[x - 1][y]) {
    c[x][y] = 'U';
  }
  if (in(x + 1, y) && go[x][y] == go[x + 1][y]) {
    c[x][y] = 'D';
  }
  if (in(x, y - 1) && go[x][y] == go[x][y - 1]) {
    c[x][y] = 'L';
  }
  if (in(x, y + 1) && go[x][y] == go[x][y + 1]) {
    c[x][y] = 'R';
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  vector<pair<int, int> > st, handle;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      c[i][j] = '.';
      int x, y;
      cin >> x >> y;
      if (x != -1) {
        x--;
        y--;
      } else {
        handle.push_back({i, j});
      }
      go[i][j] = {x, y};
      if (i == x && j == y) {
        c[i][j] = 'X';
        st.push_back({i, j});
      }
    }
  for (auto x : st) g(x.first, x.second);
  for (auto x : handle) gg(x.first, x.second);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if (c[i][j] == '.') return cout << "INVALID", 0;
  cout << "VALID\n";
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) cout << c[i][j];
    cout << "\n";
  }
  return 0;
}
