#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline bool uax(T &x, T y) {
  return (y > x) ? x = y, true : false;
}
template <typename T>
inline bool uin(T &x, T y) {
  return (y < x) ? x = y, true : false;
}
string to_string(char c) { return "'" + string(1, c) + "'"; }
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char *s) { return to_string((string)s); }
template <typename A>
string to_string(A);
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ": " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool f = false;
  string r = "{";
  for (auto x : v) {
    if (f) r += ", ";
    r += to_string(x);
    f = true;
  }
  return r += "}";
}
template <typename A>
string to_string(vector<vector<A>> v) {
  string r;
  for (auto x : v) r += "\n" + to_string(x);
  return r;
}
int Nerr;
template <typename A>
string to_string(A *p) {
  return to_string(vector<A>(p, p + Nerr));
}
void err(istream_iterator<string>) { cerr << endl; }
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << to_string(a) << "; ";
  err(++it, args...);
}
template <typename T>
void kek(T ans) {
  cout << ans << endl;
  exit(0);
}
int const MOD = 1e9 + 7;
long long const INF = 1e18 + 42;
const int N = 1e3 + 42;
int x[N][N], y[N][N];
char ans[N][N];
int drx[] = {1, -1, 0, 0};
int dry[] = {0, 0, 1, -1};
string dch = "UDLR";
int n;
int ok(int i, int j) { return i >= 1 && i <= n && j >= 1 && j <= n; }
int32_t main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  cin >> n;
  map<pair<int, int>, int> b;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      ans[i][j] = '-';
      cin >> x[i][j] >> y[i][j];
      if (x[i][j] != -1) b[{x[i][j], y[i][j]}]++;
    }
  }
  for (const auto &[pr, pcnt] : b) {
    auto [xs, ys] = pr;
    if (x[xs][ys] != xs or y[xs][ys] != ys) {
      42;
      ;
      kek("INVALID");
    }
    ans[xs][ys] = 'X';
    queue<pair<int, int>> q;
    q.push(pr);
    int cnt = 0;
    while (!q.empty()) {
      ++cnt;
      auto [u, v] = q.front();
      q.pop();
      for (int d = 0; d < 4; ++d) {
        int dx = u + drx[d], dy = v + dry[d];
        if (ok(dx, dy) && ans[dx][dy] == '-' && x[dx][dy] == xs &&
            y[dx][dy] == ys) {
          ans[dx][dy] = dch[d];
          q.push({dx, dy});
        }
      }
    }
    if (cnt != pcnt) kek("INVALID");
  }
  for (int xs = 1; xs <= n; ++xs) {
    for (int ys = 1; ys <= n; ++ys) {
      if (ans[xs][ys] == '-') {
        assert(x[xs][ys] == -1);
        queue<pair<int, int>> q;
        q.push({xs, ys});
        int f = 0;
        while (!q.empty()) {
          auto [u, v] = q.front();
          q.pop();
          for (int d = 0; d < 4; ++d) {
            int dx = u + drx[d], dy = v + dry[d];
            if (ok(dx, dy) && ans[dx][dy] == '-' && x[dx][dy] == -1 &&
                y[dx][dy] == -1) {
              ans[dx][dy] = dch[d];
              if (!f) {
                f = 1;
                ans[xs][ys] = dch[d];
              }
              q.push({dx, dy});
            }
          }
        }
        if (!f) kek("INVALID");
        char &c = ans[xs][ys];
        if (c == 'U')
          c = 'D';
        else if (c == 'D')
          c = 'U';
        else if (c == 'L')
          c = 'R';
        else if (c == 'R')
          c = 'L';
      }
    }
  }
  cout << "VALID\n";
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      cout << ans[i][j];
    }
    cout << '\n';
  }
}
