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 dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const char dc[] = {'R', 'D', 'L', 'U'};
const int INF = (int)1e6;
const int MAXN = (int)3e5 + 5;
namespace {
struct Edge {
  int v, to, f, c;
  Edge() { v = to = f = c = 0; }
  Edge(int v, int to, int c) : v(v), to(to), c(c) { f = 0; }
};
vector<Edge> e;
vector<int> adj[MAXN];
int ptr[MAXN], d[MAXN], q[MAXN];
int S, T, newS, newT, V;
int cap[2][MAXN];
void prep() {
  e.clear();
  for (int i = 0; i < V; ++i) {
    adj[i].clear();
    ptr[i] = d[i] = q[i] = 0;
    cap[0][i] = cap[1][i] = 0;
  }
}
void addEdge(int u, int v, int c) {
  adj[u].push_back((int)e.size());
  e.push_back(Edge(u, v, c));
  adj[v].push_back((int)e.size());
  e.push_back(Edge(v, u, 0));
}
void addEdgeLim(int u, int v) {
  ++cap[0][v];
  ++cap[1][u];
}
bool bfs() {
  fill(d, d + V, -1);
  d[newS] = 0;
  int l = 0, r = 0;
  q[r++] = newS;
  while (l < r) {
    int v = q[l++];
    for (int id : adj[v]) {
      if (e[id].f < e[id].c) {
        int to = e[id].to;
        if (d[to] == -1) {
          d[to] = d[v] + 1;
          q[r++] = to;
        }
      }
    }
  }
  return d[newT] != -1;
}
int dfs(int v, int flow = INF) {
  if (!flow || v == newT) {
    return flow;
  }
  int sum = 0;
  for (; ptr[v] < (int)adj[v].size(); ++ptr[v]) {
    int id = adj[v][ptr[v]];
    int to = e[id].to;
    int can = e[id].c - e[id].f;
    if (d[to] != d[v] + 1 || can == 0) {
      continue;
    }
    int pushed = dfs(to, min(flow, can));
    if (pushed > 0) {
      e[id].f += pushed;
      e[id ^ 1].f -= pushed;
      sum += pushed;
      flow -= pushed;
      if (flow == 0) {
        return sum;
      }
    }
  }
  return sum;
}
int maxFlow() {
  int ret = 0;
  while (bfs()) {
    fill(ptr, ptr + V, 0);
    while (int pushed = dfs(newS)) {
      ret += pushed;
    }
  }
  return ret;
}
}  // namespace
vector<vector<int> > arr, follow;
int n, m;
bool inside(int x, int y) { return 0 <= x && x < n && 0 <= y && y < m; }
int id(int x, int y) { return x * m + y; }
void solve() {
  scanf("%d %d", &n, &m);
  arr = follow = vector<vector<int> >(n, vector<int>(m, -1));
  S = n * m;
  T = S + 1;
  newS = T + 1;
  newT = newS + 1;
  V = newT + 1;
  prep();
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      scanf("%d", &arr[i][j]);
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      for (int dir = 0; dir < 4; ++dir) {
        int ni = i + dx[dir], nj = j + dy[dir];
        if (inside(ni, nj)) {
          if (arr[ni][nj] < arr[i][j]) {
            follow[i][j] = dir;
          } else if ((i + j) % 2 == 0 && arr[ni][nj] == arr[i][j]) {
            addEdge(id(i, j), id(ni, nj), 1);
          }
        }
      }
      if (follow[i][j] == -1) {
        if ((i + j) % 2) {
          addEdgeLim(id(i, j), T);
        } else {
          addEdgeLim(S, id(i, j));
        }
      } else {
        if ((i + j) % 2) {
          addEdge(id(i, j), T, 1);
        } else {
          addEdge(S, id(i, j), 1);
        }
      }
    }
  }
  for (int i = 0; i <= T; ++i) {
    if (cap[0][i] > 0) {
      addEdge(newS, i, cap[0][i]);
    }
    if (cap[1][i] > 0) {
      addEdge(i, newT, cap[1][i]);
    }
  }
  addEdge(T, S, INF);
  maxFlow();
  for (int id : adj[newS]) {
    if (e[id].f != e[id].c) {
      printf("NO\n");
      return;
    }
  }
  vector<vector<int> > ansv, ansc;
  ansv = ansc = vector<vector<int> >(n, vector<int>(m));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      int dir = follow[i][j];
      if (dir != -1) {
        int ni = i + dx[dir], nj = j + dy[dir];
        ansv[i][j] = arr[i][j] - arr[ni][nj];
        ansc[i][j] = dir;
      }
    }
  }
  for (Edge it : e) {
    int v = it.v, to = it.to;
    if (max(v, to) < n * m && it.f == it.c && it.c == 1) {
      int ax = v / m, ay = v % m;
      int bx = to / m, by = to % m;
      ansv[ax][ay] = arr[ax][ay] - 1;
      ansv[bx][by] = 1;
      for (int dir = 0; dir < 4; ++dir) {
        if (make_pair(ax + dx[dir], ay + dy[dir]) == make_pair(bx, by)) {
          ansc[ax][ay] = dir;
          ansc[bx][by] = (dir + 2) % 4;
        }
      }
    }
  }
  printf("YES\n");
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      printf("%d%c", ansv[i][j], " \n"[j == m - 1]);
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      printf("%c%c", dc[ansc[i][j]], " \n"[j == m - 1]);
    }
  }
}
int main() {
  int tt;
  scanf("%d", &tt);
  while (tt--) {
    solve();
  }
  return 0;
}