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;
using ll = long long;
const int Node = 100005, Edge = 2 * (Node * 2 + Node * 2);
struct MinCostMaxFlow {
  int to[Edge], nt[Edge], hd[Node], f[Edge], w[Edge], h[Node], cur[Node],
      ec = 0;
  int S, T;
  int n;
  void init(int nc) {
    ec = 0;
    n = nc;
    fill(hd, hd + nc, -1);
  }
  MinCostMaxFlow() { init(Node); }
  int link(int x, int y, int flow, int cost) {
    to[ec] = y;
    nt[ec] = hd[x];
    hd[x] = ec;
    f[ec] = flow;
    w[ec] = cost;
    ++ec;
    to[ec] = x;
    nt[ec] = hd[y];
    hd[y] = ec;
    f[ec] = 0;
    w[ec] = -cost;
    ++ec;
    return ec - 1;
  }
  bool spfa() {
    deque<int> q;
    fill(h, h + n, 0x3f3f3f3f);
    h[S] = 0;
    q.push_back(S);
    while (!q.empty()) {
      int x = q.front();
      q.pop_front();
      for (int i = hd[x]; i != -1; i = nt[i]) {
        if (f[i] && h[to[i]] > h[x] + w[i]) {
          h[to[i]] = h[x] + w[i];
          if (!q.empty() && h[to[i]] <= h[q.front()])
            q.push_front(to[i]);
          else
            q.push_back(to[i]);
        }
      }
    }
    return h[T] != 0x3f3f3f3f;
  }
  bool vis[Node];
  int dfs(int x, int flow) {
    if (x == T || !flow) return flow;
    int res = 0;
    vis[x] = true;
    for (int i = hd[x]; i != -1; i = nt[i]) {
      if (vis[to[i]] || h[to[i]] != h[x] + w[i] || !f[i]) continue;
      int aug = min(flow, f[i]);
      if ((aug = min(aug, dfs(to[i], aug)))) {
        f[i] -= aug;
        f[i ^ 1] += aug;
        flow -= aug;
        res += aug;
      }
      if (!flow) break;
    }
    vis[x] = false;
    if (!res) h[x] = 0x3f3f3f3f;
    return res;
  }
  int mincost() {
    int res = 0;
    int aug = 0;
    while (spfa()) {
      if (h[T] >= 0) break;
      ++aug;
      int fl = dfs(S, 0x3f3f3f3f);
      res += fl * h[T];
      for (int i = 1; i <= 10000000; ++i)
        ;
    }
    fprintf(stderr, "%d augments.\n", aug);
    return res;
  }
} G;
const int N = 100005;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
const char dir[] = "DRUL";
int a[N], d[N], eid[N][4];
bool type[N];
bool cover[N];
char res[N];
int val[N];
int n, m;
int id(int x, int y) { return x * m + y; }
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    scanf("%d%d", &n, &m);
    G.init(n * m + 2);
    for (int i = 0, li = n * m; i < li; ++i)
      for (int d = 0; d < 4; ++d) eid[i][d] = -1;
    G.S = n * m;
    G.T = n * m + 1;
    for (int i = 0; i < n; ++i)
      for (int j = 0; j < m; ++j) {
        int x = id(i, j);
        scanf("%d", &a[x]);
        type[x] = (i ^ j) & 1;
      }
    fill(cover, cover + n * m, true);
    int require = n * m;
    for (int i = 0; i < n; ++i)
      for (int j = 0; j < m; ++j) {
        int x = id(i, j);
        for (int d = 0; d < 4; ++d) {
          int ni = i + dx[d], nj = j + dy[d];
          if (ni < 0 || ni >= n || nj < 0 || nj >= m) continue;
          int y = id(ni, nj);
          if (a[x] > a[y]) {
            cover[x] = false;
            --require;
            break;
          }
        }
      }
    for (int i = 0; i < n * m; ++i)
      if (type[i])
        G.link(i, G.T, 1, -int(cover[i]));
      else
        G.link(G.S, i, 1, -int(cover[i]));
    for (int i = 0; i < n; ++i)
      for (int j = 0; j < m; ++j)
        for (int d = 0; d < 4; ++d) {
          int ni = i + dx[d], nj = j + dy[d];
          if (ni < 0 || ni >= n || nj < 0 || nj >= m) continue;
          int x = id(i, j), y = id(ni, nj);
          if (a[x] == a[y] && !type[x]) eid[x][d] = G.link(x, y, 1, 0);
        }
    int c = -G.mincost();
    if (c < require) {
      puts("NO");
      continue;
    } else {
      puts("YES");
      fill(res, res + n * m, 0);
      for (int i = 0; i < n; ++i)
        for (int j = 0; j < m; ++j) {
          int x = id(i, j);
          for (int d = 0; d < 4; ++d)
            if (eid[x][d] != -1 && G.f[eid[x][d]] == 1) {
              int y = id(i + dx[d], j + dy[d]);
              res[x] = dir[d];
              res[y] = dir[d ^ 2];
              val[x] = 1;
              val[y] = a[x] - 1;
            }
        }
      for (int i = 0; i < n; ++i)
        for (int j = 0; j < m; ++j) {
          int x = id(i, j);
          if (!res[x])
            for (int d = 0; d < 4; ++d) {
              int ni = i + dx[d], nj = j + dy[d];
              if (ni >= 0 && ni < n && nj >= 0 && nj < m) {
                int y = id(ni, nj);
                if (a[x] > a[y]) res[x] = dir[d], val[x] = a[x] - a[y];
              }
            }
        }
      for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) printf("%d ", val[id(i, j)]);
        putchar('\n');
      }
      for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) putchar(res[id(i, j)]), putchar(' ');
        putchar('\n');
      }
    }
  }
  return 0;
}