#include <bits/stdc++.h>
using namespace std;
const int nax = 1111;
pair<int, int> g[nax][nax];
bool vis[nax][nax];
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
string dir = "DURL";
string rdir = "UDLR";
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;
  int n;
  cin >> n;
  vector<string> ans(n, string(n, '.'));
  queue<pair<int, int>> q;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> g[i][j].first >> g[i][j].second;
      if (g[i][j].first != -1) {
        g[i][j].first--;
        g[i][j].second--;
      }
      if (g[i][j].first == i && g[i][j].second == j) {
        q.push({i, j});
        vis[i][j] = 1;
        ans[i][j] = 'X';
      }
    }
  }
  while (q.size()) {
    pair<int, int> at = q.front();
    q.pop();
    for (int x = 0; x < 4; x++) {
      int nr = at.first + dx[x];
      int nc = at.second + dy[x];
      if (nr < 0 || nc < 0 || nr == n || nc == n) continue;
      if (vis[nr][nc]) continue;
      if (g[nr][nc] == g[at.first][at.second]) {
        vis[nr][nc] = 1;
        ans[nr][nc] = rdir[x];
        q.push({nr, nc});
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (g[i][j] != make_pair(-1, -1)) continue;
      for (int x = 0; x < 4; x++) {
        int nr = i + dx[x];
        int nc = j + dy[x];
        if (nr < 0 || nc < 0 || nr == n || nc == n) continue;
        if (g[nr][nc] == make_pair(-1, -1)) {
          ans[i][j] = dir[x];
          break;
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (ans[i][j] == '.') {
        cout << "INVALID\n";
        return 0;
      }
    }
  }
  cout << "VALID\n";
  for (int i = 0; i < n; i++) cout << ans[i] << '\n';
}
