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;
int n, m, sum;
namespace MaxFlow {
const int MV = 100200;
const int ME = 2000400;
const int INF = 1e9;
int dis[MV];
int st[MV], en[ME << 1], nxt[ME << 1], flow[ME << 1], ce;
int start[MV];
int TS, TT;
void init() {
  memset(st, 0, sizeof st);
  ce = 1;
  sum = 0;
}
void addE(int s, int e, int f) {
  if (s == TS) sum += f;
  if (!f) return;
  ++ce;
  nxt[ce] = st[s];
  st[s] = ce;
  en[ce] = e;
  flow[ce] = f;
  ++ce;
  nxt[ce] = st[e];
  st[e] = ce;
  en[ce] = s;
  flow[ce] = 0;
}
void addLRE(int s, int e, int l, int r) {
  addE(TS, e, l);
  addE(s, TT, l);
  addE(s, e, r - l);
}
int que[MV];
int bfs(int N, int S, int E) {
  for (int i = 1; i <= N; i++) dis[i] = -1;
  dis[S] = 0;
  int *fr = que, *re = que;
  *fr++ = S;
  while (fr != re) {
    int t = *re++;
    for (int i = st[t]; i; i = nxt[i])
      if (flow[i] > 0 && dis[en[i]] == -1) {
        dis[en[i]] = dis[t] + 1;
        *fr++ = en[i];
      }
  }
  return dis[E] != -1;
}
int dfs(int x, int E, int f) {
  if (x == E) return f;
  for (int &i = start[x], t; i; i = nxt[i])
    if (flow[i] > 0 && dis[en[i]] == dis[x] + 1 &&
        (t = dfs(en[i], E, min(f, flow[i]))) > 0) {
      flow[i] -= t;
      flow[i ^ 1] += t;
      return t;
    }
  return 0;
}
int Get(int N, int S, int E) {
  int res = 0;
  while (bfs(N, S, E)) {
    for (int i = 1; i <= N; i++) start[i] = st[i];
    while (1) {
      int t = dfs(S, E, INF);
      if (t == 0) break;
      res += t;
    }
  }
  return res;
}
vector<pair<int, int>> trace() {
  int i, j;
  vector<pair<int, int>> V;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      if ((i + j) % 2) continue;
      int x = (i - 1) * m + j;
      for (int y = st[x]; y; y = nxt[y]) {
        if (flow[y] == 0 && en[y] <= n * m) {
          V.push_back({x, en[y]});
        }
      }
    }
  }
  return V;
}
}  // namespace MaxFlow
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}, cnt;
vector<vector<int>> w, Num, Res, Ans, chk;
bool Valid(int x, int y) { return 1 <= x && x <= n && 1 <= y && y <= m; }
void DFS(int x, int y) {
  int i;
  Num[x][y] = cnt;
  for (i = 0; i < 4; i++) {
    int tx = x + dx[i], ty = y + dy[i];
    if (Valid(tx, ty) && Num[tx][ty] == 0 && w[x][y] == w[tx][ty]) {
      DFS(tx, ty);
    }
  }
}
int ord(int x, int y) { return (x - 1) * m + y; }
pair<int, int> reord(int a) {
  a--;
  return pair<int, int>(a / m + 1, a % m + 1);
}
void Solve() {
  int i, j;
  scanf("%d%d", &n, &m);
  w.resize(n + 1);
  for (i = 0; i <= n; i++) {
    w[i].resize(m + 1);
  }
  for (i = 0; i <= n; i++)
    for (j = 0; j <= m; j++) w[i][j] = 0;
  Num = w;
  Res = w;
  Ans = w;
  chk = w;
  int ckk = 0;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      scanf("%d", &w[i][j]);
      if (w[i][j] == 1) ckk = 1;
    }
  }
  if (ckk) {
    puts("NO");
    return;
  }
  cnt = 0;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      if (!Num[i][j]) {
        cnt++;
        DFS(i, j);
      }
    }
  }
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      for (int k = 0; k < 4; k++) {
        int x = i + dx[k], y = j + dy[k];
        if (Valid(x, y) && w[i][j] > w[x][y]) {
          chk[i][j] = 1;
          Res[i][j] = k;
          Ans[i][j] = w[i][j] - w[x][y];
        }
      }
    }
  }
  MaxFlow::init();
  MaxFlow::TS = n * m + 3, MaxFlow::TT = n * m + 4;
  int source = n * m + 1, sink = n * m + 2, ss = 0;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      int low = 0;
      if (!chk[i][j]) {
        low = 1;
      }
      if ((i + j) % 2 == 0) {
        MaxFlow::addLRE(source, ord(i, j), low, 1);
      } else {
        MaxFlow::addLRE(ord(i, j), sink, low, 1);
      }
      if (j < m && Num[i][j] == Num[i][j + 1]) {
        int a = ord(i, j), b = ord(i, j + 1);
        if ((i + j) % 2 == 1) swap(a, b);
        MaxFlow::addLRE(a, b, 0, 1);
      }
      if (i < n && Num[i][j] == Num[i + 1][j]) {
        int a = ord(i, j), b = ord(i + 1, j);
        if ((i + j) % 2 == 1) swap(a, b);
        MaxFlow::addLRE(a, b, 0, 1);
      }
    }
  }
  MaxFlow::addE(sink, source, 9999999);
  int f = MaxFlow::Get(MaxFlow::TT, MaxFlow::TS, MaxFlow::TT);
  if (sum != f) {
    puts("NO");
    return;
  }
  vector<pair<int, int>> tp = MaxFlow::trace();
  for (auto &t : tp) {
    pair<int, int> t1 = reord(t.first), t2 = reord(t.second);
    int tx = t2.first - t1.first, ty = t2.second - t1.second;
    for (int k = 0; k < 4; k++) {
      if (dx[k] == tx && dy[k] == ty) {
        Res[t1.first][t1.second] = k;
      }
      if (dx[k] == -tx && dy[k] == -ty) {
        Res[t2.first][t2.second] = k;
      }
    }
    Ans[t1.first][t1.second] = w[t1.first][t1.second] / 2;
    Ans[t2.first][t2.second] = (w[t1.first][t1.second] + 1) / 2;
  }
  puts("YES");
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      printf("%d ", Ans[i][j]);
    }
    puts("");
  }
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      printf("%c ", "DRUL"[Res[i][j]]);
    }
    puts("");
  }
}
int main() {
  int TC;
  scanf("%d", &TC);
  while (TC--) {
    Solve();
  }
}