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;
struct Edge {
  int t, f, next;
  Edge() {}
  Edge(int a, int b, int c) : t(a), f(b), next(c) {}
};
Edge e[5000000];
int head[100010], vs, vt, tot;
inline void addEdge(int x, int y, int z) {
  e[++tot] = Edge(y, z, head[x]);
  head[x] = tot;
  e[++tot] = Edge(x, 0, head[y]);
  head[y] = tot;
}
namespace Flow {
int d[100010], cur[100010];
queue<int> q;
bool bfs() {
  while (!q.empty()) q.pop();
  for (int i = vs; i <= vt; i++) d[i] = -1;
  d[vs] = 0;
  cur[vs] = head[vs];
  q.push(vs);
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    for (int i = head[x]; i != -1; i = e[i].next)
      if (e[i].f && d[e[i].t] == -1) {
        int u = e[i].t;
        d[u] = d[x] + 1;
        cur[u] = head[u];
        if (u == vt) return 1;
        q.push(u);
      }
  }
  return 0;
}
int dfs(int x, int a) {
  if (x == vt || !a) return a;
  int ans = 0;
  for (int &i = cur[x]; i != -1; i = e[i].next)
    if (e[i].f && d[e[i].t] == d[x] + 1) {
      int u = e[i].t;
      int f = dfs(u, min(a, e[i].f));
      if (f) {
        e[i].f -= f;
        e[i ^ 1].f += f;
        ans += f;
        a -= f;
        if (!a) break;
      }
    }
  return ans;
}
int maxflow() {
  int ans = 0;
  while (bfs()) ans += dfs(vs, 0x3f3f3f3f);
  return ans;
}
}  // namespace Flow
int *num[100005], *id[100005], *ans1[100005];
char *ans2[100005];
pair<int, int> a[100005];
bool solve(int n, int m, int k, int val) {
  vs = 0;
  vt = k + 3;
  tot = -1;
  for (int i = vs; i <= vt; i++) head[i] = -1;
  int sz1 = 0, sz2 = 0;
  for (int i = 1; i <= k; i++) id[a[i].first][a[i].second] = i;
  for (int i = 1; i <= k; i++) {
    int x = a[i].first, y = a[i].second;
    if (!((x ^ y) & 1)) {
      sz1++;
      addEdge(vs, i, 1);
      bool v = 0;
      if (x > 1) {
        if (num[x - 1][y] < val)
          v = 1;
        else if (num[x - 1][y] == val)
          addEdge(id[x][y], id[x - 1][y], 1);
      }
      if (x < n) {
        if (num[x + 1][y] < val)
          v = 1;
        else if (num[x + 1][y] == val)
          addEdge(id[x][y], id[x + 1][y], 1);
      }
      if (y > 1) {
        if (num[x][y - 1] < val)
          v = 1;
        else if (num[x][y - 1] == val)
          addEdge(id[x][y], id[x][y - 1], 1);
      }
      if (y < m) {
        if (num[x][y + 1] < val)
          v = 1;
        else if (num[x][y + 1] == val)
          addEdge(id[x][y], id[x][y + 1], 1);
      }
      if (v) addEdge(i, k + 2, 1);
    } else {
      sz2++;
      addEdge(i, vt, 1);
      bool v = 0;
      if (x > 1 && num[x - 1][y] < val) v = 1;
      if (x < n && num[x + 1][y] < val) v = 1;
      if (y > 1 && num[x][y - 1] < val) v = 1;
      if (y < m && num[x][y + 1] < val) v = 1;
      if (v) addEdge(k + 1, i, 1);
    }
  }
  addEdge(k + 2, k + 1, 0x3f3f3f3f);
  addEdge(k + 1, vt, sz1);
  addEdge(vs, k + 2, sz2);
  if (Flow::maxflow() < sz1 + sz2) return 0;
  for (int i = 1; i <= k; i++) {
    int x = a[i].first, y = a[i].second;
    if (!((x ^ y) & 1)) {
      for (int j = head[i]; j != -1; j = e[j].next)
        if (e[j].t == k + 2 && !e[j].f) {
          if (x > 1 && num[x - 1][y] < val) {
            ans1[x][y] = val - num[x - 1][y];
            ans2[x][y] = 'U';
          } else if (x < n && num[x + 1][y] < val) {
            ans1[x][y] = val - num[x + 1][y];
            ans2[x][y] = 'D';
          } else if (y > 1 && num[x][y - 1] < val) {
            ans1[x][y] = val - num[x][y - 1];
            ans2[x][y] = 'L';
          } else if (y < m && num[x][y + 1] < val) {
            ans1[x][y] = val - num[x][y + 1];
            ans2[x][y] = 'R';
          }
        } else if (e[j].t >= 1 && e[j].t <= k && !e[j].f) {
          int u = a[e[j].t].first, v = a[e[j].t].second;
          ans1[x][y] = 1;
          ans1[u][v] = val - 1;
          if (u == x - 1) {
            ans2[x][y] = 'U';
            ans2[u][v] = 'D';
          } else if (u == x + 1) {
            ans2[x][y] = 'D';
            ans2[u][v] = 'U';
          } else if (v == y - 1) {
            ans2[x][y] = 'L';
            ans2[u][v] = 'R';
          } else if (v == y + 1) {
            ans2[x][y] = 'R';
            ans2[u][v] = 'L';
          }
        }
    } else {
      for (int j = head[i]; j != -1; j = e[j].next)
        if (e[j].t == k + 1 && e[j].f) {
          if (x > 1 && num[x - 1][y] < val) {
            ans1[x][y] = val - num[x - 1][y];
            ans2[x][y] = 'U';
          } else if (x < n && num[x + 1][y] < val) {
            ans1[x][y] = val - num[x + 1][y];
            ans2[x][y] = 'D';
          } else if (y > 1 && num[x][y - 1] < val) {
            ans1[x][y] = val - num[x][y - 1];
            ans2[x][y] = 'L';
          } else if (y < m && num[x][y + 1] < val) {
            ans1[x][y] = val - num[x][y + 1];
            ans2[x][y] = 'R';
          }
        }
    }
  }
  return 1;
}
bool cmp(pair<int, int> x, pair<int, int> y) {
  return num[x.first][x.second] < num[y.first][y.second];
}
pair<int, int> b[100005];
int main() {
  int cases;
  scanf("%d", &cases);
  for (; cases; cases--) {
    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 0; i <= n + 1; i++) {
      num[i] = new int[m + 2];
      id[i] = new int[m + 2];
      ans1[i] = new int[m + 2];
      ans2[i] = new char[m + 2];
      memset(num[i], 0, sizeof(int) * (m + 2));
      memset(id[i], 0, sizeof(int) * (m + 2));
      memset(ans1[i], 0, sizeof(int) * (m + 2));
      memset(ans2[i], 0, sizeof(char) * (m + 2));
    }
    int sz = 0;
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++) {
        scanf("%d", &num[i][j]);
        b[++sz] = pair<int, int>(i, j);
      }
    sort(b + 1, b + sz + 1, cmp);
    bool v = 1;
    for (int i = 1, j = 1; i <= sz; i = j + 1) {
      while (j < sz && num[b[i].first][b[i].second] ==
                           num[b[j + 1].first][b[j + 1].second])
        j++;
      int sz2 = 0;
      for (int k = i; k <= j; k++) a[++sz2] = b[k];
      if (!solve(n, m, sz2, num[b[i].first][b[i].second])) {
        v = 0;
        break;
      }
    }
    if (!v)
      puts("NO");
    else {
      puts("YES");
      for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) printf("%d ", ans1[i][j]);
        printf("\n");
      }
      for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) printf("%c ", ans2[i][j]);
        printf("\n");
      }
    }
  }
  return 0;
}