#include <bits/stdc++.h>
using namespace std;
const long long N = 1111;
long long dp[N][N];
pair<long long, long long> a[N][N];
long long n;
void dfs(long long i, long long j) {
  if (a[i][j] == a[i + 1][j] && dp[i + 1][j] == -1) {
    dp[i + 1][j] = 1;
    dfs(i + 1, j);
  }
  if (a[i][j] == a[i][j + 1] && dp[i][j + 1] == -1) {
    dp[i][j + 1] = 3;
    dfs(i, j + 1);
  }
  if (a[i][j] == a[i - 1][j] && dp[i - 1][j] == -1) {
    dp[i - 1][j] = 2;
    dfs(i - 1, j);
  }
  if (a[i][j] == a[i][j - 1] && dp[i][j - 1] == -1) {
    dp[i][j - 1] = 4;
    dfs(i, j - 1);
  }
}
bool isInfy(long long i, long long j) {
  if (dp[i][j] != -1) return true;
  if (a[i + 1][j] == make_pair(-1ll, -1ll)) {
    dp[i][j] = 2;
    dp[i + 1][j] = 1;
    return true;
  } else if (a[i][j + 1] == make_pair(-1ll, -1ll)) {
    dp[i][j] = 4;
    dp[i][j + 1] = 3;
    return true;
  } else if (a[i][j - 1] == make_pair(-1ll, -1ll)) {
    dp[i][j] = 3;
    return true;
  } else if (a[i - 1][j] == make_pair(-1ll, -1ll)) {
    dp[i][j] = 1;
    return true;
  }
  return false;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= n; j++) cin >> a[i][j].first >> a[i][j].second;
  }
  memset(dp, -1, sizeof dp);
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= n; j++) {
      if (a[i][j] == make_pair(i, j)) {
        dfs(i, j);
        dp[i][j] = 5;
      } else if (a[i][j] == make_pair(-1ll, -1ll)) {
        if (!isInfy(i, j)) {
          cout << "INVALID" << '\n';
          return 0;
        }
      }
    }
  }
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= n; j++) {
      if (dp[i][j] == -1) {
        cout << "INVALID" << '\n';
        return 0;
      }
    }
  }
  cout << "VALID" << '\n';
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= n; j++) {
      char c = 'X';
      if (dp[i][j] == 1)
        c = 'U';
      else if (dp[i][j] == 2)
        c = 'D';
      else if (dp[i][j] == 3)
        c = 'L';
      else if (dp[i][j] == 4)
        c = 'R';
      cout << c;
    }
    cout << '\n';
  }
}
