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 maxn = 100010, mod = 998244353,
          d[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
const char str[] = "RLDU";
inline int read() {
  int x = 0, f = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') f |= ch == '-', ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return f ? -x : x;
}
int n, m, tl, atx[maxn], aty[maxn];
vector<vector<int> > a, id, ans;
struct node {
  int x, y, v;
  bool operator<(const node &nd) const { return v < nd.v; }
} tmp[maxn];
const int MAXN = 111111, MAXM = 1111111;
namespace mf {
int s, t, tot, el = 1, head[MAXN], cur[MAXN], to[MAXM], nxt[MAXM], flow[MAXM],
               q[MAXN], h, r, dis[MAXN];
inline void add(int u, int v, int w) {
  to[++el] = v;
  nxt[el] = head[u];
  head[u] = el;
  flow[el] = w;
  to[++el] = u;
  nxt[el] = head[v];
  head[v] = el;
  flow[el] = 0;
}
bool bfs() {
  for (int i = (1); i <= (tot); i++) dis[i] = -1, cur[i] = head[i];
  dis[s] = 0;
  q[h = r = 1] = s;
  while (h <= r) {
    int u = q[h++];
    for (int i = head[u]; i; i = nxt[i]) {
      int v = to[i];
      if (dis[v] == -1 && flow[i]) {
        dis[v] = dis[u] + 1;
        q[++r] = v;
      }
    }
  }
  return ~dis[t];
}
int dfs(int u, int minres) {
  if (u == t || !minres) return minres;
  int f, rtf = 0;
  for (int &i = cur[u]; i; i = nxt[i]) {
    int v = to[i];
    if (dis[v] == dis[u] + 1 && (f = dfs(v, min(flow[i], minres)))) {
      flow[i] -= f;
      flow[i ^ 1] += f;
      rtf += f;
      minres -= f;
      if (!minres) break;
    }
  }
  return rtf;
}
int dinic() {
  int mxf = 0;
  while (bfs()) mxf += dfs(s, 1e9);
  return mxf;
}
void clear() {
  for (int i = (1); i <= (tot); i++) head[i] = cur[i] = 0;
  for (int i = (1); i <= (el); i++) to[i] = nxt[i] = flow[i] = 0;
  s = t = tot = 0;
  el = 1;
}
}  // namespace mf
namespace cmf1 {
int tot, deg[MAXN], s, t, S, T, mflow;
inline void add(int u, int v, int l, int r) {
  mf::add(u, v, r - l);
  deg[v] += l;
  deg[u] -= l;
  mflow += l;
}
int work() {
  mf::add(t, s, 1e9);
  tot += 2;
  S = tot - 1;
  T = tot;
  int sum = 0;
  for (int i = (1); i <= (tot - 2); i++) {
    if (deg[i] > 0)
      mf::add(S, i, deg[i]), sum += deg[i];
    else
      mf::add(i, T, -deg[i]);
  }
  mf::s = S;
  mf::t = T;
  mf::tot = tot;
  int p = mf::dinic();
  if (p != sum)
    return -1;
  else
    return mflow + sum;
}
void clear() {
  for (int i = (1); i <= (tot); i++) deg[i] = 0;
  S = T = tot = mflow = 0;
  mf::clear();
}
}  // namespace cmf1
void clear() {
  cmf1::clear();
  tl = 0;
  a.clear();
  id.clear();
  ans.clear();
}
void solve() {
  n = read();
  m = read();
  for (int i = (0); i <= (n - 1); i++) {
    a.push_back(vector<int>());
    id.push_back(vector<int>());
    ans.push_back(vector<int>());
    for (int j = (0); j <= (m - 1); j++) {
      a[i].push_back(read());
      tmp[++tl] = (node){i, j, a[i][j]};
      id[i].push_back(0);
      ans[i].push_back(0);
    }
  }
  sort(tmp + 1, tmp + tl + 1);
  bool ok = true;
  for (int i = (1); i <= (tl); i++) {
    int j = i;
    while (j < tl && tmp[i].v == tmp[j + 1].v) j++;
    int S = j - i + 2, T = S + 1;
    cmf1::s = S;
    cmf1::tot = cmf1::t = T;
    for (int k = (i); k <= (j); k++) {
      int x = tmp[k].x, y = tmp[k].y;
      id[x][y] = k - i + 1;
      atx[id[x][y]] = x, aty[id[x][y]] = y;
      bool flag = true;
      for (int l = (0); l <= (3); l++) {
        int tx = x + d[l][0], ty = y + d[l][1];
        if (tx < 0 || tx >= n || ty < 0 || ty >= m) continue;
        if (a[tx][ty] < a[x][y])
          flag = false, ans[x][y] = l;
        else if (a[tx][ty] == a[x][y] && id[tx][ty]) {
          if ((x + y) & 1)
            cmf1::add(id[x][y], id[tx][ty], 0, 1);
          else
            cmf1::add(id[tx][ty], id[x][y], 0, 1);
        }
      }
      if ((x + y) & 1)
        cmf1::add(S, id[x][y], flag, 1);
      else
        cmf1::add(id[x][y], T, flag, 1);
    }
    if (cmf1::work() == -1) {
      puts("NO");
      ok = false;
      break;
    }
    for (int k = (i); k <= (j); k++) {
      int x = tmp[k].x, y = tmp[k].y;
      if (!((x + y) & 1)) continue;
      int u = id[x][y];
      for (int l = mf::head[u]; l; l = mf::nxt[l]) {
        int v = mf::to[l];
        if (v < S && mf::flow[l ^ 1]) {
          int tx = atx[v], ty = aty[v];
          if (tx != x)
            ans[x][y] = x + 1 == tx ? 2 : 3;
          else
            ans[x][y] = y + 1 == ty ? 0 : 1;
          ans[tx][ty] = ans[x][y] ^ 1;
          break;
        }
      }
    }
    cmf1::clear();
    i = j;
  }
  if (ok) {
    puts("YES");
    for (int i = (0); i <= (n - 1); i++) {
      for (int j = (0); j <= (m - 1); j++) {
        int x = i + d[ans[i][j]][0], y = j + d[ans[i][j]][1];
        if (a[i][j] == a[x][y])
          printf("%d ", (a[i][j] + ((i + j) & 1)) / 2);
        else
          printf("%d ", a[i][j] - a[x][y]);
      }
      puts("");
    }
    for (int i = (0); i <= (n - 1); i++) {
      for (int j = (0); j <= (m - 1); j++) printf("%c ", str[ans[i][j]]);
      puts("");
    }
  }
  clear();
}
int main() {
  int T = read();
  while (T--) solve();
}