#include <bits/stdc++.h>
using namespace std;
const long long INF = (long long)1 << 62;
const long long MOD = 1e9 + 7;
const int iINF = 1 << 30;
const double PI = 3.14159265359;
vector<vector<pair<int, int> > > target;
vector<vector<char> > ans;
vector<vector<bool> > vis;
int n;
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};
string answerer = "ULDR";
string answerer2 = "DRUL";
bool valid(int x, int y) { return (x >= 0 && x < n && y >= 0 && y < n); }
void bfs(int srcx, int srcy) {
  queue<pair<int, int> > q;
  if (target[srcx][srcy].first == srcx && target[srcx][srcy].second == srcy) {
    ans[srcx][srcy] = 'X';
    vis[srcx][srcy] = true;
    q.push({srcx, srcy});
  } else {
    return;
  }
  while (!q.empty()) {
    int ux = q.front().first;
    int uy = q.front().second;
    q.pop();
    for (int i = 0; i < 4; i++) {
      int vx = ux + dx[i];
      int vy = uy + dy[i];
      if (valid(vx, vy) && !vis[vx][vy] && target[vx][vy].first == srcx &&
          target[vx][vy].second == srcy) {
        vis[vx][vy] = true;
        q.push({vx, vy});
        ans[vx][vy] = answerer2[i];
      }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  target.resize(n, vector<pair<int, int> >(n));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> target[i][j].first >> target[i][j].second;
      if (target[i][j].first != -1) target[i][j].first--;
      if (target[i][j].second != -1) target[i][j].second--;
    }
  }
  ans.resize(n, vector<char>(n));
  vis.assign(n, vector<bool>(n, false));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (target[i][j].first != -1) {
        if (!vis[target[i][j].first][target[i][j].second])
          bfs(target[i][j].first, target[i][j].second);
        if (!vis[i][j]) {
          cout << "INVALID\n";
          return 0;
        }
      } else {
        int cnt = -1;
        for (int k = 0; k < 4; k++) {
          int x = i + dx[k];
          int y = j + dy[k];
          if (valid(x, y) && target[x][y].first == -1) {
            cnt = k;
            break;
          }
        }
        if (cnt == -1) {
          cout << "INVALID\n";
          return 0;
        } else {
          ans[i][j] = answerer[cnt];
        }
      }
    }
  }
  cout << "VALID\n";
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cout << ans[i][j];
    }
    cout << "\n";
  }
  return 0;
}
