#include <bits/stdc++.h>
using namespace std;
int lim = 3e16 + 5;
const int mod = 1e9 + 7;
int n, m, t, k;
int Power(int a, int b) {
  if (a == 0) return 0;
  if (b == 0) return 1;
  int ans = Power((a * a) % mod, b / 2);
  if (b & 1) return (a * ans) % mod;
  return ans % mod;
}
int Inv(int a) { return Power(a, mod - 2); }
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n;
  map<pair<int, int>, char> mp, mp1;
  mp[{1, 0}] = 'U';
  mp[{-1, 0}] = 'D';
  mp[{0, 1}] = 'L';
  mp[{0, -1}] = 'R';
  mp1[{1, 0}] = 'D';
  mp1[{-1, 0}] = 'U';
  mp1[{0, 1}] = 'R';
  mp1[{0, -1}] = 'L';
  vector<vector<pair<int, int>>> v(n, vector<pair<int, int>>(n));
  vector<vector<bool>> vis(n, vector<bool>(n, 0));
  vector<vector<char>> ans(n, vector<char>(n, 'u'));
  stack<pair<int, int>> Q;
  vector<pair<int, int>> a;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> v[i][j].first >> v[i][j].second;
      if (v[i][j].first != -1) {
        v[i][j].first--;
        v[i][j].second--;
        ans[v[i][j].first][v[i][j].second] = 'X';
        if (v[i][j].first == i && v[i][j].second == j)
          Q.push({v[i][j].first, v[i][j].second});
        a.push_back({v[i][j].first, v[i][j].second});
      }
    }
  }
  bool flag = 1;
  for (int i = 0; i < a.size(); i++) {
    if (v[a[i].first][a[i].second].first != a[i].first ||
        v[a[i].first][a[i].second].second != a[i].second) {
      flag = 0;
      break;
    }
  }
  while (!Q.empty() && flag) {
    auto it = Q.top();
    Q.pop();
    int x = it.first;
    int y = it.second;
    vis[x][y] = 1;
    for (int i = 0; i < 4; i++) {
      int X = dx[i] + x;
      int Y = dy[i] + y;
      if (X >= 0 && X < n && Y >= 0 && Y < n &&
          v[X][Y].first == v[x][y].first && v[X][Y].second == v[x][y].second &&
          vis[X][Y] == 0) {
        ans[X][Y] = mp[{dx[i], dy[i]}];
        Q.push({X, Y});
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (v[i][j].first == -1 && v[i][j].second == -1) {
        for (int k = 0; k < 4; k++) {
          int X = i + dx[k];
          int Y = j + dy[k];
          if (X >= 0 && X < n && Y >= 0 && Y < n && v[X][Y].first == -1 &&
              v[X][Y].second == -1) {
            ans[i][j] = mp1[{dx[k], dy[k]}];
            break;
          }
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (ans[i][j] == 'u') flag = 0;
    }
  }
  if (flag) {
    cout << "VALID\n";
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) cout << ans[i][j];
      cout << endl;
    }
  } else {
    cout << "INVALID\n";
  }
  return 0;
}
