#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:268435456")
using namespace std;
template <typename T1, typename T2>
istream& operator>>(istream& in, pair<T1, T2>& p) {
  in >> p.first >> p.second;
  return in;
}
template <typename T1, typename T2>
ostream& operator<<(ostream& out, pair<T1, T2>& p) {
  out << p.first << " " << p.second;
  return out;
}
template <typename T>
istream& operator>>(istream& in, vector<T>& v) {
  for (int i = 0; i < int(v.size()); ++i) {
    in >> v[i];
  }
  return in;
}
template <typename T>
ostream& operator<<(ostream& out, vector<T>& v) {
  for (int i = 0; i < int(v.size()); ++i) {
    out << v[i] << ' ';
  }
  return out;
}
vector<vector<pair<int, int>>> ens;
int n;
bool is_inf() {
  bool f = true;
  for (int i = 0; i < int(ens.size()); ++i) {
    for (int j = 0; j < int(ens.size()); ++j) {
      if (ens[i][j] != pair<int, int>(-1, -1)) {
        f = false;
        ens[i][j].first--;
        ens[i][j].second--;
      }
    }
  }
  return f;
}
void print_inf() {
  cout << "VALID" << endl;
  for (int i = 0; i < int(n - 1); ++i) cout << 'R';
  cout << "D\n";
  for (int i = 0; i < int(n - 2); ++i) {
    cout << 'U';
    for (int i = 0; i < int(n - 2); ++i) cout << 'R';
    cout << "D\n";
  }
  cout << 'U';
  for (int i = 0; i < int(n - 1); ++i) cout << 'L';
  cout << endl;
}
void fail() {
  cout << "INVALID" << endl;
  exit(0);
}
vector<vector<char>> arr;
vector<int> dx = {0, 1, 0, -1};
vector<int> dy = {1, 0, -1, 0};
vector<char> laters = {'L', 'U', 'R', 'D'};
vector<char> laters1 = {'R', 'D', 'L', 'U'};
bool cg(int x, int y) { return x >= 0 && y >= 0 && x < n && y < n; }
void dfs(int x, int y, pair<int, int> e, char b) {
  if (arr[x][y] != '.') return;
  arr[x][y] = b;
  for (int i = 0; i < int(4); ++i) {
    int nx = x + dx[i];
    int ny = y + dy[i];
    if (cg(nx, ny) && ens[nx][ny] == e) dfs(nx, ny, e, laters[i]);
  }
}
void find_blocks() {
  for (int i = 0; i < int(n); ++i) {
    for (int j = 0; j < int(n); ++j) {
      if (i == ens[i][j].first && j == ens[i][j].second) {
        dfs(i, j, ens[i][j], 'X');
      }
    }
  }
}
int can_fill(int x, int y) {
  for (int i = 0; i < int(4); ++i) {
    int nx = x + dx[i];
    int ny = y + dy[i];
    if (cg(nx, ny) && ens[nx][ny] == pair<int, int>(-1, -1)) return i + 1;
  }
  return 0;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n;
  ens.assign(n, vector<pair<int, int>>(n));
  cin >> ens;
  arr.assign(n, vector<char>(n, '.'));
  cin >> ens;
  if (is_inf() && n == 1) fail();
  find_blocks();
  for (int i = 0; i < int(n); ++i) {
    for (int j = 0; j < int(n); ++j) {
      if (arr[i][j] != '.') continue;
      if (ens[i][j] != pair<int, int>(-1, -1)) fail();
      int a = can_fill(i, j);
      if (a) {
        dfs(i, j, ens[i][j], laters1[a - 1]);
      } else
        fail();
    }
  }
  cout << "VALID" << endl;
  for (int i = 0; i < int(n); ++i) {
    for (int j = 0; j < int(n); ++j) cout << arr[i][j];
    cout << endl;
  }
  return 0;
}
