#include <bits/stdc++.h>
using namespace std;
const long long MX = 1e3 + 10;
long long n;
string dir = "UDLR";
long long dx[] = {-1, 1, 0, 0};
long long dy[] = {0, 0, -1, 1};
bool vis[MX][MX];
pair<long long, long long> cel[MX][MX];
char ans[MX][MX];
void bfs(long long x, long long y) {
  deque<pair<long long, long long> > q;
  q.push_back(make_pair(x, y));
  while (!q.empty()) {
    x = q.front().first;
    y = q.front().second;
    q.pop_front();
    for (long long i = 0; i < 4; i++) {
      long long u = x + dx[i];
      long long v = y + dy[i];
      if (0 <= u && u < n && 0 <= v && v < n && !vis[u][v] &&
          cel[u][v] == cel[x][y]) {
        vis[u][v] = true;
        ans[u][v] = dir[i ^ 1];
        q.push_back(make_pair(u, v));
      }
    }
  }
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cout.precision(10);
  cout << fixed;
  cin >> n;
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < n; j++) {
      cin >> cel[i][j].first >> cel[i][j].second;
      if (cel[i][j].first != -1) {
        cel[i][j].first--;
        cel[i][j].second--;
      }
    }
  }
  for (long long u = 0; u < n; u++) {
    for (long long v = 0; v < n; v++) {
      if (vis[u][v]) continue;
      if (cel[u][v] == make_pair(-1ll, -1ll)) continue;
      if (cel[u][v] == make_pair(u, v)) {
        vis[u][v] = true;
        ans[u][v] = 'X';
        bfs(u, v);
      }
    }
  }
  for (long long u = 0; u < n; u++) {
    for (long long v = 0; v < n; v++) {
      if (vis[u][v]) continue;
      if (cel[u][v] != make_pair(-1ll, -1ll)) continue;
      bool ok = false;
      for (long long i = 0; i < 4; i++) {
        long long x = dx[i] + u;
        long long y = dy[i] + v;
        if (0 <= x && x < n && 0 <= y && y < n && !vis[x][y] &&
            cel[x][y] == make_pair(-1ll, -1ll)) {
          vis[u][v] = true;
          ans[u][v] = dir[i];
          bfs(u, v);
          ok = true;
          break;
        }
      }
      if (!ok) {
        cout << "INVALID\n";
        return 0;
      }
    }
  }
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < n; j++) {
      if (!vis[i][j]) {
        cout << "INVALID\n";
        return 0;
      }
    }
  }
  cout << "VALID\n";
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < n; j++) {
      cout << ans[i][j];
    }
    cout << "\n";
  }
  return 0;
}
