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 std::queue;
using std::vector;
const int N = 100005;
namespace FLOW {
const int M = 2000005;
struct edge {
  int to, nxt, fl;
} e[M];
int n, S, T, head[N], dis[N], iter[N], top;
inline void init(void) {
  std::fill(head + 1, head + n + 1, 0);
  top = 1;
}
inline void adde(int x, int y, int fl) {
  e[++top] = edge{y, head[x], fl};
  head[x] = top;
}
inline void add(int x, int y, int fl) {
  adde(x, y, fl);
  adde(y, x, 0);
}
void bfs(void) {
  static queue<int> q;
  std::fill(dis + 1, dis + n + 1, -1);
  while (!q.empty()) q.pop();
  q.push(S);
  dis[S] = 0;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int i = head[u]; i; i = e[i].nxt)
      if (e[i].fl) {
        int v = e[i].to;
        if (dis[v] == -1) {
          dis[v] = dis[u] + 1;
          if (v == T) return;
          q.push(v);
        }
      }
  }
}
int dfs(int u, int fl) {
  if (u == T) return fl;
  int ret = 0;
  for (int &i = iter[u]; i; i = e[i].nxt)
    if (e[i].fl) {
      int v = e[i].to;
      if (dis[v] != dis[u] + 1) continue;
      int s = dfs(v, std::min(fl, e[i].fl));
      fl -= s, ret += s, e[i].fl -= s, e[i ^ 1].fl += s;
      if (!fl) break;
    }
  return ret;
}
int dinic(int nn, int s, int t) {
  n = nn, S = s, T = t;
  int ret = 0;
  while (1) {
    bfs();
    if (dis[t] == -1) break;
    std::copy(head, head + n + 1, iter);
    ret += dfs(s, 0x3f3f3f3f);
  }
  return ret;
}
}  // namespace FLOW
using FLOW::add;
using FLOW::dinic;
using FLOW::e;
using FLOW::head;
using FLOW::init;
using FLOW::top;
int T, n, m, s, t, rs, rt, nm, n1m, val[N], vis[N], cnt, rid[N], cr;
int ansval[N];
char ans[N], _Fc[5] = "LRUD";
int id[N];
inline int gid(int x, int y) { return (x - 1) * m + y; }
inline int L(int x) {
  if (m == 1 || x % m == 1) return 0;
  return x - 1;
}
inline int R(int x) {
  if (m == 1 || x % m == 0) return 0;
  return x + 1;
}
inline int U(int x) { return x <= m ? 0 : x - m; }
inline int D(int x) { return x > n1m ? 0 : x + m; }
int (*_F[4])(int) = {L, R, U, D};
int eid[N][4];
int dx[N];
bool cmp(int a, int b) { return val[a] < val[b]; }
inline int gcol(int x) { return ((x - 1) / m + 1 + (x - 1) % m + 1) & 1; }
inline void radd(int x, int y, int lfl, int rfl) {
  dx[x] += lfl, dx[y] -= lfl;
  if (rfl - lfl) add(x, y, rfl - lfl);
}
void dfs(int u) {
  int ok = 0;
  for (int i = 0; i < 4; ++i)
    if (val[_F[i](u)] < cr) {
      ok = 1;
      ans[u] = _Fc[i];
      ansval[u] = val[u] - val[_F[i](u)];
      break;
    }
  vis[u] = 1;
  rid[u] = ++cnt;
  if (gcol(u))
    radd(s, rid[u], ok ^ 1, 1);
  else
    radd(rid[u], t, ok ^ 1, 1);
  for (int i = 0; i < 4; ++i) {
    auto F = _F[i];
    if (val[F(u)] == cr) {
      if (vis[F(u)] && rid[F(u)] < rid[u]) continue;
      if (!vis[F(u)]) dfs(F(u));
      if (gcol(u))
        radd(rid[u], rid[F(u)], 0, 1);
      else
        radd(rid[F(u)], rid[u], 0, 1);
      eid[u][i] = eid[F(u)][i ^ 1] = top;
    }
  }
}
void rdfs(int u) {
  vis[u] = 2;
  for (int i = 0; i < 4; ++i)
    if (eid[u][i] && e[eid[u][i]].fl) {
      ans[u] = _Fc[i];
      ansval[u] = gcol(u) ? cr - 1 : 1;
      break;
    }
  for (int i = 0; i < 4; ++i) {
    auto F = _F[i];
    if (vis[F(u)] == 1 && val[F(u)] == cr) rdfs(F(u));
  }
}
int main() {
  scanf("%d", &T);
  while (T--) {
    scanf("%d%d", &n, &m);
    nm = n * m, n1m = (n - 1) * m;
    val[0] = 0x3f3f3f3f;
    for (int i = 1; i <= nm; ++i)
      scanf("%d", val + i), id[i] = i, std::fill(eid[i], eid[i] + 4, 0);
    id[nm + 1] = 0;
    std::sort(id + 1, id + nm + 1, cmp);
    std::fill(vis + 1, vis + nm + 1, 0);
    std::fill(rid + 1, rid + nm + 1, 0);
    std::fill(ans + 1, ans + nm + 1, 0);
    std::fill(ansval + 1, ansval + nm + 1, 0);
    for (int l = 1, r; l <= nm; l = r + 1) {
      r = l;
      while (val[id[r + 1]] == val[id[l]]) ++r;
      cr = val[id[l]];
      for (int i = l; i <= r; ++i) {
        int u = id[i];
        if (vis[u]) continue;
        s = 1, t = 2, rs = 3, rt = 4;
        std::fill(dx + 1, dx + cnt + 1, 0);
        cnt = 4;
        init();
        dfs(u);
        int sum = 0;
        for (int i = 1; i <= cnt; ++i) {
          if (dx[i] > 0) add(i, rt, dx[i]), sum += dx[i];
          if (dx[i] < 0) add(rs, i, -dx[i]);
        }
        radd(t, s, 0, 0x3f3f3f3f);
        int fl = dinic(cnt, rs, rt);
        if (fl != sum) goto FAIL;
        rdfs(u);
      }
    }
    puts("YES");
    for (int i = 1; i <= n; ++i, puts(""))
      for (int j = 1; j <= m; ++j) printf("%d ", ansval[gid(i, j)]);
    for (int i = 1; i <= n; ++i, puts(""))
      for (int j = 1; j <= m; ++j) printf("%c ", ans[gid(i, j)]);
    if (0) {
    FAIL:;
      puts("NO");
    }
  }
  return 0;
}