#include <bits/stdc++.h>
using namespace std;
template <class T, class T2>
inline bool chkmax(T &x, const T2 &y) {
  return x < y ? x = y, 1 : 0;
}
template <class T, class T2>
inline bool chkmin(T &x, const T2 &y) {
  return x > y ? x = y, 1 : 0;
}
const long long mod = 1e9 + 7;
const int MAX_N = 1e3 + 10;
pair<int, int> tab[MAX_N][MAX_N];
char ans[MAX_N][MAX_N];
bool used[MAX_N][MAX_N];
void bfs(int i, int j) {
  queue<pair<int, int> > q;
  q.push({i, j});
  used[i][j] = true;
  while (!q.empty()) {
    auto curr = q.front();
    q.pop();
    i = curr.first;
    j = curr.second;
    if (tab[i][j + 1] == tab[i][j] && !used[i][j + 1]) {
      used[i][j + 1] = true;
      q.push({i, j + 1});
      ans[i][j + 1] = 'L';
    }
    if (tab[i][j - 1] == tab[i][j] && !used[i][j - 1]) {
      used[i][j - 1] = true;
      q.push({i, j - 1});
      ans[i][j - 1] = 'R';
    }
    if (tab[i + 1][j] == tab[i][j] && !used[i + 1][j]) {
      used[i + 1][j] = true;
      q.push({i + 1, j});
      ans[i + 1][j] = 'U';
    }
    if (tab[i - 1][j] == tab[i][j] && !used[i - 1][j]) {
      used[i - 1][j] = true;
      q.push({i - 1, j});
      ans[i - 1][j] = 'D';
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      cin >> tab[i][j].first >> tab[i][j].second;
    }
  }
  for (int i = 0; i < MAX_N; i++) {
    for (int j = 0; j < MAX_N; j++) {
      ans[i][j] = '!';
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (used[i][j]) {
        continue;
      } else if (tab[i][j].first == -1) {
        if (tab[i][j + 1] == tab[i][j]) {
          ans[i][j] = 'R';
        } else if (tab[i][j - 1] == tab[i][j]) {
          ans[i][j] = 'L';
        } else if (tab[i + 1][j] == tab[i][j]) {
          ans[i][j] = 'D';
        } else if (tab[i - 1][j] == tab[i][j]) {
          ans[i][j] = 'U';
        }
        bfs(i, j);
      } else if (tab[i][j].first == i && tab[i][j].second == j) {
        ans[i][j] = 'X';
        bfs(i, j);
      }
    }
  }
  bool flag = true;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (ans[i][j] == '!') {
        flag = false;
      }
    }
  }
  if (!flag) {
    cout << "INVALID"
         << "\n";
  } else {
    cout << "VALID"
         << "\n";
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        cout << ans[i][j];
      }
      cout << "\n";
    }
  }
  return 0;
}
