#include <bits/stdc++.h>
using namespace std;
int n;
pair<int, int> arr[1005][1005];
bool vis[1005][1005];
char ans[1005][1005];
int _x[] = {-1, 0, 1, 0};
int _y[] = {0, -1, 0, 1};
string dir = "DRUL";
bool bfs(int st_x, int st_y) {
  queue<pair<int, int> > q;
  q.push(pair<int, int>{st_x, st_y});
  vis[st_x][st_y] = true;
  while (!q.empty()) {
    pair<int, int> now = q.front();
    q.pop();
    int x = now.first, y = now.second;
    for (int t = 0; t < 4; t++) {
      int nx = x + _x[t], ny = y + _y[t];
      if (nx < 0 || ny < 0 || nx >= n || ny >= n) continue;
      if (vis[nx][ny]) continue;
      if (arr[nx][ny].first != arr[st_x][st_y].first ||
          arr[nx][ny].second != arr[st_x][st_y].second)
        continue;
      ans[nx][ny] = dir[t];
      vis[nx][ny] = true;
      q.push(pair<int, int>{nx, ny});
    }
  }
  if (arr[st_x][st_y].first != -1)
    ans[st_x][st_y] = 'X';
  else {
    bool flag = false;
    for (int t = 0; t < 4; t++) {
      int nx = st_x + _x[t], ny = st_y + _y[t];
      if (nx < 0 || ny < 0 || nx >= n || ny >= n) continue;
      if (arr[nx][ny].first != arr[st_x][st_y].first ||
          arr[nx][ny].second != arr[st_x][st_y].second)
        continue;
      ans[st_x][st_y] = dir[(t + 2) % 4];
      flag = true;
      break;
    }
    if (!flag) return false;
  }
  return true;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  vector<pair<int, int> > st;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      cin >> arr[i][j].first >> arr[i][j].second;
      if (arr[i][j].first != -1) arr[i][j].first--, arr[i][j].second--;
    }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      if (vis[i][j]) continue;
      if (arr[i][j].first != -1 && vis[arr[i][j].first][arr[i][j].second]) {
        cout << "INVALID" << '\n';
        return 0;
      }
      int x = i, y = j;
      if (arr[i][j].first != -1) {
        x = arr[i][j].first, y = arr[i][j].second;
        if (x != arr[x][y].first || y != arr[x][y].second) {
          cout << "INVALID" << '\n';
          return 0;
        }
      }
      if (!bfs(x, y) || !vis[i][j]) {
        cout << "INVALID" << '\n';
        return 0;
      }
    }
  cout << "VALID" << '\n';
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) cout << ans[i][j];
    cout << '\n';
  }
  return 0;
}
