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>
const int MN = 1e5 + 10;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
const char dir[] = "URDL";
const int INF = 0x3f3f3f3f;
template <typename F, int MN, int MM>
struct MaxFlow {
  int hd[MN], nx[MM * 2], to[MM * 2], N, M, S, T, lvl[MN], cur[MN];
  bool vis[MN];
  F flow[MM * 2], cap[MM * 2];
  void init(int _N) {
    N = _N;
    memset(hd, -1, N * sizeof *hd);
    M = 0;
  }
  void adde1(int u, int v, F w) {
    to[M] = v, nx[M] = hd[u], hd[u] = M;
    flow[M] = 0, cap[M] = w;
    ++M;
  }
  void adde(int u, int v, F w) {
    adde1(u, v, w);
    adde1(v, u, 0);
  }
  bool bfs() {
    memset(lvl, -1, N * sizeof *lvl);
    cur[0] = S;
    lvl[S] = 1;
    for (int q = 0, n, Q = 1; q < Q; ++q) {
      n = cur[q];
      for (int i = hd[n]; ~i; i = nx[i]) {
        if (cap[i] - flow[i] > 0 && !~lvl[to[i]])
          lvl[cur[Q++] = to[i]] = lvl[n] + 1;
      }
    }
    return ~lvl[T];
  }
  F dfs(int n, F f = 1) {
    if (n == T) return f;
    for (int &i = cur[n], x; ~i; i = nx[i])
      if (cap[i] - flow[i] > 0 && lvl[x = to[i]] == lvl[n] + 1) {
        F ff = dfs(x, std::min(f, cap[i] - flow[i]));
        if (ff) return flow[i] += ff, flow[i ^ 1] -= ff, ff;
      }
    return 0;
  }
  F saturate(int _S, int _T) {
    S = _S, T = _T;
    F tot = 0;
    for (; bfs();) {
      memcpy(cur, hd, N * sizeof *hd);
      bool ok = 0;
      for (F x; x = dfs(S);) {
        tot += x;
        ok = 1;
      }
      if (!ok) break;
    }
    return tot;
  }
};
MaxFlow<int, MN, 8 * MN> maxflow;
void fail() { printf("NO\n"); }
struct Event {
 public:
  int v, i, j;
  bool operator<(const Event& o) const { return v < o.v; }
};
int T, N, M, a[MN], f[MN], f2[MN], id[MN];
char ok[MN];
bool vis[MN];
std::vector<Event> event;
std::vector<int> g[2];
bool okay(int x, int y) { return 0 <= x && x < N && 0 <= y && y < M; }
int get_dir(int u, int v) {
  if ((u - v) % M)
    return u < v ? 1 : 3;
  else
    return u < v ? 2 : 0;
}
void dfs(int x, int y, int val, bool t = 0) {
  vis[x * M + y] = 1;
  id[x * M + y] = g[t].size();
  g[t].push_back(x * M + y);
  for (int k = 0; k < 4; ++k) {
    int nx = x + dx[k], ny = y + dy[k];
    if (okay(nx, ny) && !vis[nx * M + ny] && a[nx * M + ny] == val)
      dfs(nx, ny, val, !t);
  }
}
void solve() {
  scanf("%d%d", &N, &M);
  for (int i = 0; i < N; ++i)
    for (int j = 0; j < M; ++j) {
      scanf("%d", a + (i * M + j));
      event.push_back({a[i * M + j], i, j});
    }
  memset(ok, -1, N * M * sizeof *ok);
  memset(f, -1, N * M * sizeof *f);
  for (int i = 0; i < N; ++i)
    for (int j = 0; j < M; ++j)
      for (int k = 0; k < 4; ++k) {
        int nx = i + dx[k], ny = j + dy[k];
        if (okay(nx, ny) && a[nx * M + ny] < a[i * M + j]) ok[i * M + j] = k;
      }
  std::sort(event.begin(), event.end());
  for (int i = 0, j; i < event.size(); i = j) {
    int val = event[i].v;
    for (j = i; j < event.size() && event[j].v == val; ++j) {
      int x = event[j].i, y = event[j].j;
      if (!vis[x * M + y]) {
        dfs(x, y, val);
        int X = g[0].size() + g[1].size();
        maxflow.init(X + 4);
        for (int i = 0; i < g[0].size(); ++i) {
          int x = g[0][i] / M, y = g[0][i] - x * M;
          for (int k = 0; k < 4; ++k) {
            int nx = x + dx[k], ny = y + dy[k];
            if (okay(nx, ny) && a[nx * M + ny] == val)
              maxflow.adde(i, id[nx * M + ny] + g[0].size(), 1);
          }
        }
        int s_dem = 0, t_exc = 0, tot;
        for (int n = 0; n < g[0].size(); ++n)
          if (~ok[g[0][n]])
            maxflow.adde(X, n, 1);
          else
            ++s_dem, maxflow.adde(X + 2, n, 1);
        for (int n = 0; n < g[1].size(); ++n)
          if (~ok[g[1][n]])
            maxflow.adde(g[0].size() + n, X + 1, 1);
          else
            ++t_exc, maxflow.adde(g[0].size() + n, X + 3, 1);
        maxflow.adde(X + 1, X, INF);
        if (s_dem) maxflow.adde(X, X + 3, s_dem);
        if (t_exc) maxflow.adde(X + 2, X + 1, t_exc);
        tot = s_dem + t_exc;
        if (tot != maxflow.saturate(X + 2, X + 3)) return fail();
        for (int n = 0; n < g[0].size(); ++n)
          for (int id = maxflow.hd[n]; ~id; id = maxflow.nx[id])
            if (maxflow.flow[id] == 1) {
              int oth = maxflow.to[id] - g[0].size();
              assert(!~f[g[0][n]]);
              assert(!~f[g[1][oth]]);
              f[g[0][n]] = 1;
              f[g[1][oth]] = val - 1;
              f2[g[0][n]] = get_dir(g[0][n], g[1][oth]);
              f2[g[1][oth]] = f2[g[0][n]] ^ 2;
            }
        g[0].clear(), g[1].clear();
      }
    }
  }
  printf("YES\n");
  for (int i = 0; i < N; ++i)
    for (int j = 0; j < M; ++j) {
      if (~f[i * M + j])
        printf("%d", f[i * M + j]);
      else {
        f2[i * M + j] = ok[i * M + j];
        int nx = i + dx[f2[i * M + j]], ny = j + dy[f2[i * M + j]];
        printf("%d", a[i * M + j] - a[nx * M + ny]);
      }
      if (j + 1 == M)
        printf("\n");
      else
        printf(" ");
    }
  for (int i = 0; i < N; ++i)
    for (int j = 0; j < M; ++j)
      printf("%c%c", dir[f2[i * M + j]], " \n"[j + 1 == M]);
}
void reset() {
  event.clear();
  memset(vis, 0, N * M * sizeof *vis);
  g[0].clear(), g[1].clear();
}
int main() {
  scanf("%d", &T);
  for (; T--;) solve(), reset();
  return 0;
}