#include <bits/stdc++.h>
using namespace std;
bool isvalid(int i, int j, int n) {
  if (i < 0 || i >= n) return false;
  if (j < 0 || j >= n) return false;
  return true;
}
int fun(vector<vector<pair<int, int>>> &vec, vector<vector<int>> &visited,
        int a, int b, vector<vector<char>> &ans) {
  int row[] = {0, -1, 0, 1};
  int col[] = {1, 0, -1, 0};
  int temp = -1;
  int flag = 0;
  visited[a][b] = 1;
  for (int i = 0; i < 4; ++i) {
    if (isvalid(a + row[i], b + col[i], vec.size())) {
      if (vec[a + row[i]][b + col[i]] == make_pair(-1, -1)) {
        temp = i;
        if (!visited[a + row[i]][b + col[i]]) {
          flag = 1;
          visited[a + row[i]][b + col[i]] = 1;
          if (i == 0) {
            ans[a][b] = 'R';
            ans[a + row[i]][b + col[i]] = 'L';
          } else if (i == 1) {
            ans[a][b] = 'U';
            ans[a + row[i]][b + col[i]] = 'D';
          } else if (i == 2) {
            ans[a][b] = 'L';
            ans[a + row[i]][b + col[i]] = 'R';
          } else {
            ans[a][b] = 'D';
            ans[a + row[i]][b + col[i]] = 'U';
          }
          visited[a + row[i]][b + col[i]] = 1;
          return 0;
        }
      }
    }
  }
  if (flag == 0) {
    if (temp == -1)
      return 1;
    else {
      int i = temp;
      if (i == 0) {
        ans[a][b] = 'R';
      } else if (i == 1) {
        ans[a][b] = 'U';
      } else if (i == 2) {
        ans[a][b] = 'L';
      } else {
        ans[a][b] = 'D';
      }
      return 0;
    }
  }
}
void bfs(vector<vector<pair<int, int>>> &vec, vector<vector<int>> &visited,
         int a, int b, vector<vector<char>> &ans) {
  queue<pair<int, int>> q;
  q.push(make_pair(a, b));
  visited[a][b] = 1;
  ans[a][b] = 'X';
  int row[] = {0, -1, 0, 1};
  int col[] = {1, 0, -1, 0};
  while (!q.empty()) {
    pair<int, int> p = q.front();
    q.pop();
    for (int i = 0; i < 4; ++i) {
      int p1 = p.first + row[i];
      int p2 = p.second + col[i];
      if (isvalid(p1, p2, vec.size()))
        if (vec[p1][p2] == vec[a][b]) {
          if (!visited[p1][p2]) {
            visited[p1][p2] = 1;
            if (i == 0)
              ans[p1][p2] = 'L';
            else if (i == 1)
              ans[p1][p2] = 'D';
            else if (i == 2)
              ans[p1][p2] = 'R';
            else
              ans[p1][p2] = 'U';
            q.push(make_pair(p1, p2));
          }
        }
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  vector<vector<pair<int, int>>> vec(n, vector<pair<int, int>>(n));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      int a, b;
      cin >> a >> b;
      if (a == -1)
        vec[i][j] = make_pair(a, b);
      else
        vec[i][j] = make_pair(a - 1, b - 1);
    }
  }
  vector<vector<int>> visited(n, vector<int>(n, 0));
  vector<vector<char>> ans(n, vector<char>(n, 'O'));
  int flag = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (!visited[i][j] && vec[i][j] == make_pair(i, j)) {
        bfs(vec, visited, i, j, ans);
      } else if (!visited[i][j] && vec[i][j] == make_pair(-1, -1)) {
        flag = fun(vec, visited, i, j, ans);
      }
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (ans[i][j] == 'O') {
        flag = 1;
      }
    }
  }
  if (flag == 1)
    cout << "INVALID"
         << "\n";
  else {
    cout << "VALID"
         << "\n";
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        cout << ans[i][j];
      }
      cout << "\n";
    }
  }
}
