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>
int _t, n, m, map[100001], head[100010], nxt[1000001], b[1000001], v[1000001],
    k, S, T, SS, TT;
int dis[100010], p[100010], q[100010], h, t;
int ans[100001], val[100001];
void push(int s, int t, int val) {
  nxt[++k] = head[s];
  head[s] = k;
  b[k] = t;
  v[k] = val;
}
void link(int s, int t, int val) {
  push(s, t, val);
  push(t, s, 0);
}
int hash(int i, int j) { return (i - 1) * m + j; }
bool bfs() {
  memset(dis, 0, sizeof dis);
  h = t = 0;
  q[++t] = SS;
  dis[SS] = 1;
  while (h < t) {
    ++h;
    for (int i = head[q[h]]; i; i = nxt[i])
      if (v[i] && !dis[b[i]]) {
        dis[b[i]] = dis[q[h]] + 1;
        q[++t] = b[i];
        if (b[i] == TT) return 1;
      }
  }
  return 0;
}
int dfs(int x, int flow) {
  if (!flow || x == TT) return flow;
  int used = 0;
  for (int i = p[x]; i; i = nxt[i])
    if (v[i] && dis[b[i]] == dis[x] + 1) {
      int w = dfs(b[i], std::min(flow - used, v[i]));
      v[i] -= w;
      v[i ^ 1] += w;
      if (w) p[x] = i;
      used += w;
      if (used == flow) return used;
    }
  if (!used) dis[x] = 0;
  return used;
}
int main() {
  scanf("%d", &_t);
  for (int fd = 1; fd <= _t; fd++) {
    k = 1;
    memset(head, 0, sizeof head);
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++) scanf("%d", &map[hash(i, j)]);
    T = n * m + 1;
    int fS = 0, fT = 0;
    SS = T + 1;
    TT = T + 2;
    bool Ans = 1;
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++) {
        bool cando = 0;
        cando |= (i > 1 && map[hash(i - 1, j)] < map[hash(i, j)]);
        cando |= (j > 1 && map[hash(i, j - 1)] < map[hash(i, j)]);
        cando |= (i < n && map[hash(i + 1, j)] < map[hash(i, j)]);
        cando |= (j < m && map[hash(i, j + 1)] < map[hash(i, j)]);
        if (!cando && map[hash(i, j)] == 1) Ans = 0;
        if ((i + j) & 1) {
          if (cando)
            link(S, hash(i, j), 1);
          else
            link(SS, hash(i, j), 1), ++fS;
          if (i > 1 && map[hash(i - 1, j)] == map[hash(i, j)])
            link(hash(i, j), hash(i - 1, j), 1);
          if (j > 1 && map[hash(i, j - 1)] == map[hash(i, j)])
            link(hash(i, j), hash(i, j - 1), 1);
          if (i < n && map[hash(i + 1, j)] == map[hash(i, j)])
            link(hash(i, j), hash(i + 1, j), 1);
          if (j < m && map[hash(i, j + 1)] == map[hash(i, j)])
            link(hash(i, j), hash(i, j + 1), 1);
        } else {
          if (cando)
            link(hash(i, j), T, 1);
          else
            link(hash(i, j), TT, 1), ++fT;
        }
      }
    link(S, TT, fS);
    link(SS, T, fT);
    link(T, S, 0x7f7f7f7f);
    while (bfs()) {
      memcpy(p, head, sizeof p);
      dfs(SS, 0x7f7f7f7f);
    }
    memset(ans, -1, sizeof ans);
    for (int i = 2; i <= k; i += 2) {
      if (!v[i]) {
        int s = b[i], t = b[i ^ 1];
        if (s >= 1 && s <= n * m && t >= 1 && t <= n * m) {
          int x1 = (s - 1) / m + 1, y1 = (s - 1) % m + 1, x2 = (t - 1) / m + 1,
              y2 = (t - 1) % m + 1;
          if (x1 == x2)
            ans[s] = (y1 < y2), ans[t] = (y1 > y2);
          else
            ans[s] = (x1 < x2) + 2, ans[t] = (x1 > x2) + 2;
          val[s] = 1, val[t] = map[t] - 1;
        }
      }
    }
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++)
        if (!~ans[hash(i, j)]) {
          bool cando = 0;
          cando |= (i > 1 && map[hash(i - 1, j)] < map[hash(i, j)]);
          cando |= (j > 1 && map[hash(i, j - 1)] < map[hash(i, j)]);
          cando |= (i < n && map[hash(i + 1, j)] < map[hash(i, j)]);
          cando |= (j < m && map[hash(i, j + 1)] < map[hash(i, j)]);
          if (!cando) Ans = 0;
        }
    if (!Ans)
      puts("NO");
    else {
      puts("YES");
      for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++) {
          char ch = '0';
          switch (ans[hash(i, j)]) {
            case 0: {
              ch = 'L';
              break;
            }
            case 1: {
              ch = 'R';
              break;
            }
            case 2: {
              ch = 'U';
              break;
            }
            case 3: {
              ch = 'D';
              break;
            }
            case -1: {
              ch = '0';
              break;
            }
          }
          if (ch == '0') {
            if (i > 1 && map[hash(i - 1, j)] < map[hash(i, j)])
              ch = 'U', val[hash(i, j)] = map[hash(i, j)] - map[hash(i - 1, j)];
            if (j > 1 && map[hash(i, j - 1)] < map[hash(i, j)])
              ch = 'L', val[hash(i, j)] = map[hash(i, j)] - map[hash(i, j - 1)];
            if (i < n && map[hash(i + 1, j)] < map[hash(i, j)])
              ch = 'D', val[hash(i, j)] = map[hash(i, j)] - map[hash(i + 1, j)];
            if (j < m && map[hash(i, j + 1)] < map[hash(i, j)])
              ch = 'R', val[hash(i, j)] = map[hash(i, j)] - map[hash(i, j + 1)];
          }
          ans[hash(i, j)] = ch;
        }
      for (int i = 1; i <= n; i++, putchar('\n'))
        for (int j = 1; j <= m; j++) printf("%d ", val[hash(i, j)]);
      for (int i = 1; i <= n; i++, putchar('\n'))
        for (int j = 1; j <= m; j++) putchar(ans[hash(i, j)]), putchar(' ');
    }
  }
}