#include <bits/stdc++.h>
using namespace std;
bool RELAXED = false;
template <int, typename T>
struct MINMAX {
  T val;
  MINMAX(T val) : val(val) {}
};
template <typename T>
MINMAX<1, T> MAX(T val) {
  return MINMAX<1, T>(val);
};
template <typename T>
MINMAX<2, T> MIN(T val) {
  return MINMAX<2, T>(val);
};
template <typename T, typename U>
inline T& operator|=(T& lhs, MINMAX<1, U> rhs) {
  return lhs = (rhs.val > lhs ? (RELAXED = true, rhs.val)
                              : (RELAXED = false, lhs));
}
template <typename T, typename U>
inline T& operator|=(T& lhs, MINMAX<2, U> rhs) {
  return lhs = (rhs.val < lhs ? (RELAXED = true, rhs.val)
                              : (RELAXED = false, lhs));
}
template <typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
  in >> p.first >> p.second;
  return in;
}
template <typename T>
inline vector<T> READ(int n) {
  vector<T> vec(n);
  for (int i = 0; i < int(n); i++) cin >> vec[i];
  return vec;
}
template <typename T>
using min_heap = priority_queue<T, vector<T>, greater<T> >;
pair<int, int> target[1005][1005];
char grid[1005][1005];
int N;
int dx[] = {0, 0, -1, 1};
int dy[] = {-1, 1, 0, 0};
char denot[] = {'L', 'R', 'U', 'D'};
char inv[] = {'R', 'L', 'D', 'U'};
void dfs(pair<int, int> targ, int x, int y, char fromD) {
  if (x < 0 || y < 0 || x >= N || y >= N) return;
  if (target[x][y] != targ) return;
  if (grid[x][y] != '?') return;
  grid[x][y] = fromD;
  for (int d = 0; d < int(4); d++) {
    dfs(targ, x + dx[d], y + dy[d], inv[d]);
  }
}
void dfs2(int x, int y) {
  for (int d = 0; d < int(4); d++) {
    int xx = x + dx[d];
    int yy = y + dy[d];
    if (xx < 0 || yy < 0 || xx >= N || yy >= N) continue;
    if (target[xx][yy] == pair<int, int>(-1, -1)) grid[x][y] = denot[d];
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int n;
  cin >> n;
  N = n;
  for (int i = 0; i < int(n); i++) {
    for (int j = 0; j < int(n); j++) {
      int x, y;
      cin >> x >> y;
      if (x > 0) x--;
      if (y > 0) y--;
      target[i][j] = {x, y};
      grid[i][j] = '?';
    }
  }
  for (int i = 0; i < int(n); i++) {
    for (int j = 0; j < int(n); j++) {
      if (target[i][j] == pair<int, int>(i, j)) {
        dfs(pair<int, int>(i, j), i, j, 'X');
      }
    }
  }
  for (int i = 0; i < int(n); i++) {
    for (int j = 0; j < int(n); j++) {
      if (target[i][j] == pair<int, int>(-1, -1)) dfs2(i, j);
    }
  }
  for (int i = 0; i < int(n); i++)
    for (int j = 0; j < int(n); j++)
      if (grid[i][j] == '?') {
        cerr << "EXIT #" << 109 << endl;
        cout << "INVALID" << endl;
        exit(0);
      };
  cout << "VALID" << endl;
  for (int i = 0; i < int(n); i++) {
    for (int j = 0; j < int(n); j++) {
      cout << grid[i][j];
    }
    cout << endl;
  }
}
