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 N = 1e5 + 5, M = 2e6 + 5, inf = 1e9, tx[4] = {0, 0, -1, 1},
          ty[4] = {1, -1, 0, 0}, tc[4] = {'R', 'L', 'U', 'D'};
char buf[1 << 23], *p1 = buf, *p2 = buf;
int cur[N], fst[N], nxt[M], u[M], v[M], flow[M], w[M], tot = 1;
int cl, n, m, t, As;
int dis[N], que[N], h, tl, S, T;
struct aa {
  int x, y, vl;
  bool operator<(const aa &b) const { return vl < b.vl; }
} dt[N];
vector<int> vl[N], as[N], to[N], id[N];
int read() {
  int res = 0, fl = 0;
  char a =
      (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2)
           ? EOF
           : *p1++);
  while (a < '0' || a > '9')
    fl |= a == '-',
        a = (p1 == p2 &&
                     (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2)
                 ? EOF
                 : *p1++);
  while (a >= '0' && a <= '9')
    res = res * 10 + a - '0',
    a = (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2)
             ? EOF
             : *p1++);
  return fl ? -res : res;
}
char cal(int tx, int ty) {
  return ty ? ty < 0 ? 'L' : 'R' : tx < 0 ? 'U' : 'D';
}
void add(int lu, int lv, int lf, int lw = 0) {
  u[++tot] = lu, v[tot] = lv, flow[tot] = lf, w[tot] = lw, nxt[tot] = fst[lu],
  fst[lu] = tot;
  u[++tot] = lv, v[tot] = lu, flow[tot] = 0, w[tot] = -lw, nxt[tot] = fst[lv],
  fst[lv] = tot;
}
bool bfs() {
  for (int i = S + 1; i <= T; i++) dis[i] = inf;
  que[h = tl = 1] = S, dis[S] = 0;
  while (h <= tl)
    for (int x = que[h++], i = fst[x]; i; i = nxt[i])
      if (dis[v[i]] > dis[x] + 1 && flow[i])
        dis[v[i]] = dis[x] + 1, que[++tl] = v[i];
  return dis[T] < inf;
}
int dfs(int x, int lw) {
  if (x == T) return lw;
  int res = 0, zl;
  for (int &i = cur[x]; i; i = nxt[i])
    if (flow[i] && dis[v[i]] == dis[x] + 1 &&
        (zl = dfs(v[i], min(lw, flow[i])))) {
      res += zl, lw -= zl, flow[i ^ 1] += zl, flow[i] -= zl;
      if (!lw) return res;
    }
  return res;
}
int dinic() {
  int res = 0;
  while (bfs()) {
    for (int i = S; i <= T; i++) cur[i] = fst[i];
    res += dfs(S, inf);
  }
  return res;
}
void clear(vector<int> &x) {
  vector<int> y;
  swap(x, y);
}
queue<int> q;
int inq[N], pre[N], a[N];
bool spfa() {
  for (int i = S; i <= T; i++) dis[i] = inf;
  dis[S] = 0, a[S] = inf, q.push(S);
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    for (int i = fst[x]; i; i = nxt[i])
      if (dis[v[i]] > dis[x] + w[i] && flow[i])
        dis[v[i]] = dis[x] + w[i], a[v[i]] = min(a[x], flow[i]), pre[v[i]] = i,
        q.push(v[i]);
  }
  if (dis[T] >= 2) return 0;
  As += 2 * a[T] - dis[T];
  for (int i = T; i != S; i = u[pre[i]])
    flow[pre[i]] -= a[T], flow[pre[i] ^ 1] += a[T];
  return 1;
}
int main() {
  int i, j, li, lj;
  for (t = read(); t; t--) {
    int lp = 1;
    n = read(), m = read(), cl = 0;
    for (i = 1; i <= n; i++)
      for (vl[i].resize(m + 1), as[i].resize(m + 1), id[i].resize(m + 1),
           to[i].resize(m + 1), j = 1;
           j <= m; j++)
        dt[++cl] = aa{i, j, vl[i][j] = read()};
    sort(dt + 1, dt + cl + 1);
    for (i = 1; i <= cl && lp; i = j) {
      for (j = i; j <= cl && dt[j].vl == dt[i].vl; j++)
        id[dt[j].x][dt[j].y] = j - i + 1;
      S = 0, T = j - i + 3;
      int c[2] = {0, 0};
      for (li = 0; li < j - i; li++) {
        int fl = (dt[i + li].x + dt[i + li].y) & 1;
        if (c[fl]++, fl)
          add(S, li + 1, 1);
        else
          add(li + 1, T, 1);
        for (lj = 0; lj < 4; lj++) {
          int lx = dt[i + li].x + tx[lj], ly = dt[i + li].y + ty[lj];
          if (lx > 0 && lx <= n && ly > 0 && ly <= m) {
            if (vl[lx][ly] == dt[i + li].vl && fl) add(li + 1, id[lx][ly], 1);
            if (vl[lx][ly] < dt[i + li].vl)
              fl ? add(li + 1, j - i + 1, 1) : add(j - i + 2, li + 1, 1);
          }
        }
      }
      int rs = 2 * dinic(), pp, qq;
      add(S, j - i + 2, inf, 1), rs += dinic();
      add(j - i + 1, T, inf, 1), pp = flow[tot - 2], qq = flow[tot - 3],
                                 flow[tot - 2] = flow[tot - 3] = 0,
                                 rs += dinic();
      As = 0, flow[tot - 2] = pp, flow[tot - 3] = qq;
      if (rs < c[0] + c[1])
        while (spfa())
          ;
      if (rs + As < c[0] + c[1]) lp = 0;
      for (li = 1; li <= j - i; li++) {
        int fl = (dt[i + li - 1].x + dt[i + li - 1].y) & 1,
            nx = dt[i + li - 1].x, ny = dt[i + li - 1].y;
        for (lj = fst[li]; lj; lj = nxt[lj])
          if (v[lj] >= 1 && v[lj] <= j - i + 2 && flow[lj] == !fl)
            if (v[lj] <= j - i)
              as[nx][ny] = fl ? dt[i + li - 1].vl - 1 : 1,
              to[nx][ny] =
                  cal(dt[i + v[lj] - 1].x - nx, dt[i + v[lj] - 1].y - ny);
            else
              for (int ii = 0; ii < 4; ii++) {
                int lx = nx + tx[ii], ly = ny + ty[ii];
                if (lx > 0 && lx <= n && ly > 0 && ly <= m &&
                    vl[lx][ly] < vl[nx][ny]) {
                  as[nx][ny] = vl[nx][ny] - vl[lx][ly], to[nx][ny] = tc[ii];
                  break;
                }
              }
      }
      for (li = S; li <= T; li++) fst[li] = 0;
      tot = 1;
    }
    if (!lp) {
      cout << "NO\n";
      continue;
    }
    cout << "YES\n";
    for (i = 1; i <= n; i++, cout << '\n')
      for (j = 1; j <= m; j++) cout << as[i][j] << ' ';
    for (i = 1; i <= n; i++, cout << '\n')
      for (j = 1; j <= m; j++) cout << char(to[i][j]) << ' ';
    for (i = 1; i <= n; i++) clear(vl[i]), clear(as[i]);
  }
  return 0;
}