#include <bits/stdc++.h>
using namespace std;
const long long MOD = 998244353;
const int SZ = 1e5 + 10;
void initialize() {}
void test_case() {
  int n;
  cin >> n;
  vector<string> ans(n + 1, string(n + 1, '*'));
  vector<vector<pair<int, int>>> arr(n + 1, vector<pair<int, int>>(n + 1));
  vector<pair<int, int>> q, qq;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      int x, y;
      cin >> x >> y;
      arr[i][j] = {x, y};
      if (x == i and y == j) {
        ans[i][j] = 'X';
        q.push_back({x, y});
      }
      if (x == -1 and y == -1) {
        qq.push_back({i, j});
      }
    }
  }
  while (q.size()) {
    pair<int, int> pr = q.back();
    int x = pr.first, y = pr.second;
    q.pop_back();
    if (x - 1 > 0 and ans[x - 1][y] == '*' and arr[x - 1][y] == arr[x][y]) {
      ans[x - 1][y] = 'D';
      q.push_back({x - 1, y});
    }
    if (y - 1 > 0 and ans[x][y - 1] == '*' and arr[x][y - 1] == arr[x][y]) {
      ans[x][y - 1] = 'R';
      q.push_back({x, y - 1});
    }
    if (x + 1 <= n and ans[x + 1][y] == '*' and arr[x + 1][y] == arr[x][y]) {
      ans[x + 1][y] = 'U';
      q.push_back({x + 1, y});
    }
    if (y + 1 <= n and ans[x][y + 1] == '*' and arr[x][y + 1] == arr[x][y]) {
      ans[x][y + 1] = 'L';
      q.push_back({x, y + 1});
    }
  }
  while (qq.size()) {
    int x = qq.back().first, y = qq.back().second, x1 = -1, y1 = -1;
    qq.pop_back();
    if (ans[x][y] != '*') continue;
    if (x - 1 > 0 and ans[x - 1][y] == '*' and
        arr[x - 1][y] == make_pair(-1, -1)) {
      ans[x - 1][y] = 'D';
      ans[x][y] = 'U';
      x1 = x - 1, y1 = y;
    } else if (y - 1 > 0 and ans[x][y - 1] == '*' and
               arr[x][y - 1] == make_pair(-1, -1)) {
      ans[x][y - 1] = 'R';
      ans[x][y] = 'L';
      x1 = x, y1 = y - 1;
    } else if (x + 1 <= n and ans[x + 1][y] == '*' and
               arr[x + 1][y] == make_pair(-1, -1)) {
      ans[x + 1][y] = 'U';
      ans[x][y] = 'D';
      x1 = x + 1, y1 = y;
    } else if (y + 1 <= n and ans[x][y + 1] == '*' and
               arr[x][y + 1] == make_pair(-1, -1)) {
      ans[x][y + 1] = 'L';
      ans[x][y] = 'R';
      x1 = x, y1 = y + 1;
    }
    if (x1 == -1) {
      cout << "INVALID\n";
      return;
    }
    for (auto p : {1, 0}) {
      q = {};
      if (p)
        q.push_back({x, y});
      else
        q.push_back({x1, y1});
      while (q.size()) {
        pair<int, int> pr = q.back();
        int x = pr.first, y = pr.second;
        q.pop_back();
        if (x - 1 > 0 and ans[x - 1][y] == '*' and
            arr[x - 1][y] == make_pair(-1, -1)) {
          ans[x - 1][y] = 'D';
          q.push_back({x - 1, y});
        }
        if (y - 1 > 0 and ans[x][y - 1] == '*' and
            arr[x][y - 1] == make_pair(-1, -1)) {
          ans[x][y - 1] = 'R';
          q.push_back({x, y - 1});
        }
        if (x + 1 <= n and ans[x + 1][y] == '*' and
            arr[x + 1][y] == make_pair(-1, -1)) {
          ans[x + 1][y] = 'U';
          q.push_back({x + 1, y});
        }
        if (y + 1 <= n and ans[x][y + 1] == '*' and
            arr[x][y + 1] == make_pair(-1, -1)) {
          ans[x][y + 1] = 'L';
          q.push_back({x, y + 1});
        }
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (ans[i][j] == '*') {
        if (n == 593) assert(false);
        cout << "INVALID\n";
        return;
      }
    }
  }
  cout << "VALID\n";
  for (int i = 1; i <= n; i++) {
    cout << ans[i].substr(1, n) << '\n';
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  srand(time(0));
  initialize();
  int t;
  t = 1;
  while (t--) {
    test_case();
  }
}
