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;
const int inf = 2147483647;
int n, m;
vector<int> a[100010];
int head[100010], v[400010 << 1], nxt[400010 << 1], w[400010 << 1], tot = 0,
                                                                    deg[100010];
int S, T, _S, _T;
int nx[4] = {-1, 1, 0, 0};
int ny[4] = {0, 0, -1, 1};
char opt[4] = {'U', 'D', 'L', 'R'};
inline void add_edge(int s, int e, int t) {
  tot++;
  v[tot] = e;
  w[tot] = t;
  nxt[tot] = head[s];
  head[s] = tot;
  tot++;
  v[tot] = s;
  w[tot] = 0;
  nxt[tot] = head[e];
  head[e] = tot;
}
int to[100010], val[100010];
int id(int i, int j) { return (i - 1) * m + j; }
void output(int t) {
  int i = (t + m - 1) / m, j = t % m;
  if (!j) j = m;
  int h1 = (to[t] + m - 1) / m, h2 = to[t] % m;
  if (!h2) h2 = m;
  for (int k = (0); k <= (3); ++k)
    if (i + nx[k] == h1 && j + ny[k] == h2) {
      putchar(opt[k]);
      break;
    }
  putchar(' ');
}
int cur[100010], edge[400010], len;
int Q[100010], hd, tl, d[100010];
bool Bfs() {
  for (int i = (0); i <= (tl - 1); ++i) d[Q[i]] = -1;
  d[S] = 0;
  hd = tl = 0;
  Q[tl++] = S;
  while (hd < tl) {
    int u = Q[hd];
    hd++;
    for (int i = head[u]; i; i = nxt[i])
      if (w[i] && d[v[i]] < 0) {
        d[v[i]] = d[u] + 1;
        Q[tl++] = v[i];
        if (v[i] == T) return true;
      }
  }
  return false;
}
int find(int u, int flow) {
  if (u == T || !flow) return flow;
  int res = 0, minv;
  for (int &i = head[u]; i; i = nxt[i])
    if (w[i] && d[v[i]] == d[u] + 1 && (minv = find(v[i], min(flow, w[i])))) {
      w[i] -= minv;
      if (i & 1)
        w[i + 1] += minv;
      else
        w[i - 1] += minv;
      res += minv;
      flow -= minv;
      if (!flow) break;
    }
  return res;
}
void init() {
  tot = 0;
  memset(head, 0, sizeof(int) * (T + 1));
  memset(deg, 0, sizeof(int) * (T + 1));
  len = 0;
  memset(to, 0, sizeof(int) * (n * m + 1));
}
inline void rd(int &x) {
  x = 0;
  char ch = getchar();
  int f = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  x *= f;
}
int main() {
  int Task;
  rd(Task);
  while (Task--) {
    rd(n);
    rd(m);
    for (int i = (1); i <= (n); ++i) {
      a[i].resize(m + 1);
      for (int j = (1); j <= (m); ++j) rd(a[i][j]);
    }
    init();
    if (n == 1 && m == 1) {
      puts("NO");
      continue;
    }
    _S = n * m + 1;
    _T = n * m + 2;
    for (int i = (1); i <= (n); ++i)
      for (int j = (1); j <= (m); ++j) {
        bool flag = true;
        for (int k = (0); k <= (3); ++k)
          if (i + nx[k] >= 1 && i + nx[k] <= n && j + ny[k] >= 1 &&
              j + ny[k] <= m) {
            if (a[i + nx[k]][j + ny[k]] < a[i][j]) flag = false;
            if (a[i + nx[k]][j + ny[k]] == a[i][j] && ((i + j) & 1)) {
              add_edge(id(i, j), id(i + nx[k], j + ny[k]), 1);
              edge[++len] = tot - 1;
            }
          }
        if (flag) {
          if ((i + j) & 1) {
            deg[_S]++;
            deg[id(i, j)]--;
          } else {
            deg[id(i, j)]++;
            deg[_T]--;
          }
        } else {
          if ((i + j) & 1)
            add_edge(_S, id(i, j), 1);
          else
            add_edge(id(i, j), _T, 1);
        }
      }
    add_edge(_T, _S, n * m);
    S = _T + 1;
    T = _T + 2;
    int sum = 0;
    for (int i = (1); i <= (_T); ++i)
      if (deg[i] > 0)
        add_edge(i, T, deg[i]), sum += deg[i];
      else if (deg[i] < 0)
        add_edge(S, i, -deg[i]);
    memset(d, -1, sizeof(int) * (T + 1));
    memcpy(cur, head, sizeof(int) * (T + 1));
    int ans = 0;
    while (Bfs()) {
      ans += find(S, inf);
      memcpy(head, cur, sizeof(int) * (T + 1));
    }
    if (ans < sum) {
      puts("NO");
      continue;
    } else {
      puts("YES");
      for (int i = (1); i <= (len); ++i)
        if (w[edge[i]] == 0) {
          int t = edge[i];
          to[v[t]] = v[t + 1];
          to[v[t + 1]] = v[t];
          int x = (v[t] + m - 1) / m, y = v[t] % m;
          if (!y) y = m;
          val[v[t]] = a[x][y] / 2;
          val[v[t + 1]] = (a[x][y] + 1) / 2;
        }
      for (int i = (1); i <= (n); ++i)
        for (int j = (1); j <= (m); ++j)
          if (!to[id(i, j)]) {
            int t = id(i, j);
            for (int k = (0); k <= (3); ++k)
              if (i + nx[k] >= 1 && i + nx[k] <= n && j + ny[k] >= 1 &&
                  j + ny[k] <= m && a[i + nx[k]][j + ny[k]] < a[i][j]) {
                to[t] = id(i + nx[k], j + ny[k]);
                val[t] = a[i][j] - a[i + nx[k]][j + ny[k]];
                break;
              }
          }
      for (int i = (1); i <= (n); ++i) {
        for (int j = (1); j <= (m); ++j) printf("%d ", val[id(i, j)]);
        puts("");
      }
      for (int i = (1); i <= (n); ++i) {
        for (int j = (1); j <= (m); ++j) output(id(i, j));
        puts("");
      }
    }
  }
  return 0;
}