Problem: Another dull quarantine day was going by when BThero decided to start researching matrices of size n × m. The rows are numerated 1 through n from top to bottom, and the columns are numerated 1 through m from left to right. The cell in the i-th row and j-th column is denoted as (i, j).

For each cell (i, j) BThero had two values: 

  1. The cost of the cell, which is a single positive integer. 
  2. The direction of the cell, which is one of characters L, R, D, U. Those characters correspond to transitions to adjacent cells (i, j - 1), (i, j + 1), (i + 1, j) or (i - 1, j), respectively. No transition pointed outside of the matrix. 



Let us call a cell (i_2, j_2) reachable from (i_1, j_1), if, starting from (i_1, j_1) and repeatedly moving to the adjacent cell according to our current direction, we will, sooner or later, visit (i_2, j_2). 

BThero decided to create another matrix from the existing two. For a cell (i, j), let us denote S_{i, j} as a set of all reachable cells from it (including (i, j) itself). Then, the value at the cell (i, j) in the new matrix will be equal to the sum of costs of all cells in S_{i, j}. 

After quickly computing the new matrix, BThero immediately sent it to his friends. However, he did not save any of the initial matrices! Help him to restore any two valid matrices, which produce the current one.

Input

The first line of input file contains a single integer T (1 ≤ T ≤ 100) denoting the number of test cases. The description of T test cases follows.

First line of a test case contains two integers n and m (1 ≤ n ⋅ m ≤ 10^5).

Each of the following n lines contain exactly m integers — the elements of the produced matrix. Each element belongs to the segment [2, 10^9].

It is guaranteed that ∑{(n ⋅ m)} over all test cases does not exceed 10^5.

Output

For each test case, if an answer does not exist, print a single word NO. Otherwise, print YES and both matrices in the same format as in the input.

  * The first matrix should be the cost matrix and the second matrix should be the direction matrix. 
  * All integers in the cost matrix should be positive. 
  * All characters in the direction matrix should be valid. No direction should point outside of the matrix. 

Example

Input


2
3 4
7 6 7 8
5 5 4 4
5 7 4 4
1 1
5


Output


YES
1 1 1 1
2 1 1 1
3 2 1 1
R D L L
D R D L
U L R U
NO

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;
string dirs = "LRUD";
map<char, int> ma = {{'L', 0}, {'R', 1}, {'U', 2}, {'D', 3}};
int dx[4] = {0, 0, -1, 1};
int dy[4] = {-1, 1, 0, 0};
int n, m;
bool ins(int x, int y) { return 0 <= x && x < n && 0 <= y && y < m; }
const int INF = 1e9;
struct edge {
  int v, flow, cap;
};
struct dinic {
  vector<edge> e;
  vector<vector<int>> g;
  vector<int> lvl, p;
  int n;
  dinic(int n) : n(n) {
    g.resize(n);
    lvl.resize(n);
    p.resize(n);
  }
  void add_edge(int u, int v, int w) {
    int k = ((int)(e).size());
    e.push_back({v, 0, w});
    e.push_back({u, w, w});
    g[u].push_back(k);
    g[v].push_back(k + 1);
  }
  int dfs(int x, int t, int amt) {
    if (x == t) return amt;
    for (int &idx = p[x]; idx < ((int)(g[x]).size()); idx++) {
      int i = g[x][idx];
      if (e[i].flow < e[i].cap && lvl[x] + 1 == lvl[e[i].v]) {
        int val = dfs(e[i].v, t, min(amt, e[i].cap - e[i].flow));
        if (val > 0) {
          e[i].flow += val;
          e[i ^ 1].flow -= val;
          return val;
        }
      }
    }
    return 0;
  }
  bool bfs(int s, int t) {
    fill((lvl).begin(), (lvl).end(), -1);
    lvl[s] = 0;
    queue<int> Q;
    Q.push(s);
    while (!Q.empty()) {
      int x = Q.front();
      Q.pop();
      for (int i : g[x]) {
        if (lvl[e[i].v] == -1 && e[i].flow < e[i].cap) {
          lvl[e[i].v] = lvl[x] + 1;
          Q.push(e[i].v);
        }
      }
    }
    return lvl[t] != -1;
  }
  int flow(int s, int t) {
    int ans = 0;
    while (bfs(s, t)) {
      fill((p).begin(), (p).end(), 0);
      int val = 0;
      while ((val = dfs(s, t, INF)) > 0) {
        ans += val;
      }
    }
    return ans;
  }
};
void solve() {
  cin >> n >> m;
  vector<vector<int>> a(n);
  vector<string> dir(n, string(m, '?'));
  for (int i = (0); i < (n); i++) {
    a[i].assign(m, 0);
    for (int j = (0); j < (m); j++) {
      cin >> a[i][j];
    }
  }
  for (int i = (0); i < (n); i++) {
    for (int j = (0); j < (m); j++) {
      for (int d = (0); d < (4); d++) {
        int x = i + dx[d];
        int y = j + dy[d];
        if (ins(x, y) && a[i][j] > a[x][y]) {
          dir[i][j] = dirs[d];
        }
      }
    }
  }
  int s = n * m, t = n * m + 1;
  int snew = n * m + 2, tnew = n * m + 3;
  dinic F(n * m + 4);
  int w1 = 0, w2 = 0;
  for (int i = (0); i < (n); i++) {
    for (int j = (0); j < (m); j++) {
      if ((i + j) % 2 == 0) {
        if (dir[i][j] == '?') {
          w1++;
          F.add_edge(snew, i * m + j, 1);
        } else {
          F.add_edge(s, i * m + j, 1);
        }
        for (int d = (0); d < (4); d++) {
          int x = i + dx[d];
          int y = j + dy[d];
          if (ins(x, y) && a[x][y] == a[i][j]) {
            F.add_edge(i * m + j, x * m + y, 1);
          }
        }
      } else {
        if (dir[i][j] == '?') {
          w2++;
          F.add_edge(i * m + j, tnew, 1);
        } else {
          F.add_edge(i * m + j, t, 1);
        }
      }
    }
  }
  F.add_edge(t, s, INF);
  F.add_edge(snew, t, w2);
  F.add_edge(s, tnew, w1);
  F.flow(snew, tnew);
  for (int i = (0); i < (n); i++) {
    for (int j = (0); j < (m); j++) {
      if ((i + j) % 2 == 0) {
        for (int idx : F.g[i * m + j]) {
          int pos = F.e[idx].v;
          if (F.e[idx].flow == F.e[idx].cap && pos < n * m) {
            int x = pos / m, y = pos % m;
            for (int d = (0); d < (4); d++) {
              if (x == i + dx[d] && y == j + dy[d]) {
                dir[i][j] = dirs[d];
                dir[x][y] = dirs[d ^ 1];
              }
            }
          }
        }
      }
    }
  }
  for (int i = (0); i < (n); i++)
    for (int j = (0); j < (m); j++) {
      if (dir[i][j] == '?') {
        cout << "NO\n";
        return;
      }
    }
  cout << "YES\n";
  for (int i = (0); i < (n); i++) {
    for (int j = (0); j < (m); j++) {
      int d = ma[dir[i][j]];
      int x = i + dx[d];
      int y = j + dy[d];
      if (a[i][j] == a[x][y]) {
        cout << ((i + j) % 2 == 0 ? a[i][j] - 1 : 1) << ' ';
      } else {
        cout << a[i][j] - a[x][y] << ' ';
      }
    }
    cout << '\n';
  }
  for (int i = (0); i < (n); i++) {
    for (int j = (0); j < (m); j++) {
      cout << dir[i][j] << ' ';
    }
    cout << '\n';
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int te;
  cin >> te;
  while (te--) {
    solve();
  }
}