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;
using ld = long double;
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
int p = 1000000007;
int mul(int a, int b) { return (1LL * a * b) % p; }
int add(int a, int b) {
  int s = (a + b);
  if (s >= p) s -= p;
  return s;
}
int sub(int a, int b) {
  int s = (a + p - b);
  if (s >= p) s -= p;
  return s;
}
int po(int a, int deg) {
  if (deg == 0) return 1;
  if (deg % 2 == 1) return mul(a, po(a, deg - 1));
  int t = po(a, deg / 2);
  return mul(t, t);
}
int inv(int n) { return po(n, p - 2); }
mt19937 rnd(time(0));
struct FlowEdge {
  int v, u;
  long long cap, flow = 0;
  FlowEdge(int v, int u, long long cap) : v(v), u(u), cap(cap) {}
};
struct Dinic {
  const long long flow_inf = 1e18;
  vector<FlowEdge> edges;
  vector<vector<int>> adj;
  int n, m = 0;
  int s, t;
  vector<int> level, ptr;
  queue<int> q;
  Dinic(int n, int s, int t) : n(n), s(s), t(t) {
    adj.resize(n);
    level.resize(n);
    ptr.resize(n);
  }
  void add_edge(int v, int u, long long cap) {
    edges.emplace_back(v, u, cap);
    edges.emplace_back(u, v, 0);
    adj[v].push_back(m);
    adj[u].push_back(m + 1);
    m += 2;
  }
  bool bfs() {
    while (!q.empty()) {
      int v = q.front();
      q.pop();
      for (int id : adj[v]) {
        if (edges[id].cap - edges[id].flow < 1) continue;
        if (level[edges[id].u] != -1) continue;
        level[edges[id].u] = level[v] + 1;
        q.push(edges[id].u);
      }
    }
    return level[t] != -1;
  }
  long long dfs(int v, long long pushed) {
    if (pushed == 0) return 0;
    if (v == t) return pushed;
    for (int& cid = ptr[v]; cid < (int)adj[v].size(); cid++) {
      int id = adj[v][cid];
      int u = edges[id].u;
      if (level[v] + 1 != level[u] || edges[id].cap - edges[id].flow < 1)
        continue;
      long long tr = dfs(u, min(pushed, edges[id].cap - edges[id].flow));
      if (tr == 0) continue;
      edges[id].flow += tr;
      edges[id ^ 1].flow -= tr;
      return tr;
    }
    return 0;
  }
  long long flow() {
    long long f = 0;
    while (true) {
      fill(level.begin(), level.end(), -1);
      level[s] = 0;
      q.push(s);
      if (!bfs()) break;
      fill(ptr.begin(), ptr.end(), 0);
      while (long long pushed = dfs(s, flow_inf)) {
        f += pushed;
      }
    }
    return f;
  }
};
void solve() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> a(n, vector<int>(m));
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> a[i][j];
  int cnt = 0;
  vector<vector<int>> special(n, vector<int>(m));
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      special[i][j] = 1;
      if (i > 0 && a[i - 1][j] < a[i][j]) special[i][j] = 0;
      if (j > 0 && a[i][j - 1] < a[i][j]) special[i][j] = 0;
      if (i < n - 1 && a[i + 1][j] < a[i][j]) special[i][j] = 0;
      if (j < m - 1 && a[i][j + 1] < a[i][j]) special[i][j] = 0;
      cnt += special[i][j];
    }
  Dinic G(2 + 2 * n * m, 0, 1 + 2 * n * m);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      if (special[i][j]) {
        G.add_edge(0, 1 + i * m + j, 1);
        if (i > 0 && a[i - 1][j] == a[i][j])
          G.add_edge(1 + i * m + j, (1 + n * m) + (i - 1) * m + j, 1);
        if (j > 0 && a[i][j - 1] == a[i][j])
          G.add_edge(1 + i * m + j, (1 + n * m) + i * m + (j - 1), 1);
        if (i < n - 1 && a[i + 1][j] == a[i][j])
          G.add_edge(1 + i * m + j, (1 + n * m) + (i + 1) * m + j, 1);
        if (j < m - 1 && a[i][j + 1] == a[i][j])
          G.add_edge(1 + i * m + j, (1 + n * m) + i * m + (j + 1), 1);
      }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      G.add_edge((1 + n * m) + i * m + j, 1 + 2 * n * m, 1);
  ll ans = G.flow();
  if (cnt != ans) {
    cout << "NO" << endl;
    return;
  }
  cout << "YES" << endl;
  vector<pair<int, int>> edges;
  for (auto it : G.edges)
    if (it.flow == -1 && it.u != 0 && it.v != 1 + 2 * n * m && it.u < it.v) {
      edges.push_back(make_pair(it.u - 1, it.v - 1 - n * m));
    }
  vector<int> indeg(n * m);
  for (auto it : edges) indeg[it.second]++;
  vector<bool> visited(n * m);
  vector<pair<int, int>> pairs;
  vector<int> nxt(n * m, -1);
  for (auto it : edges) nxt[it.first] = it.second;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      if (special[i][j] && indeg[i * m + j] == 0) {
        int st = i * m + j;
        while (special[st / m][st % m]) {
          int en = nxt[st];
          pairs.push_back(make_pair(st, en));
          visited[st] = true;
          visited[en] = true;
          if (special[en / m][en % m])
            st = nxt[en];
          else
            break;
        }
      }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      if (special[i][j] && !visited[i * m + j]) {
        int st = i * m + j;
        while (!visited[st]) {
          int en = nxt[st];
          pairs.push_back(make_pair(st, en));
          visited[st] = true;
          visited[en] = true;
          st = nxt[en];
        }
      }
  vector<vector<char>> grid(n, vector<char>(m, '?'));
  vector<vector<int>> values(n, vector<int>(m));
  for (auto it : pairs) {
    int x1 = it.first / m;
    int y1 = it.first % m;
    int x2 = it.second / m;
    int y2 = it.second % m;
    if (x1 == x2 - 1) {
      grid[x1][y1] = 'D';
      grid[x2][y2] = 'U';
    }
    if (x1 == x2 + 1) {
      grid[x1][y1] = 'U';
      grid[x2][y2] = 'D';
    }
    if (y1 == y2 - 1) {
      grid[x1][y1] = 'R';
      grid[x2][y2] = 'L';
    }
    if (y1 == y2 + 1) {
      grid[x1][y1] = 'L';
      grid[x2][y2] = 'R';
    }
    values[x1][y1] = 1;
    values[x2][y2] = a[x2][y2] - 1;
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      if (grid[i][j] == '?') {
        if (i > 0 && a[i - 1][j] < a[i][j]) {
          values[i][j] = a[i][j] - a[i - 1][j];
          grid[i][j] = 'U';
          continue;
        }
        if (j > 0 && a[i][j - 1] < a[i][j]) {
          values[i][j] = a[i][j] - a[i][j - 1];
          grid[i][j] = 'L';
          continue;
        }
        if (i < n - 1 && a[i + 1][j] < a[i][j]) {
          values[i][j] = a[i][j] - a[i + 1][j];
          grid[i][j] = 'D';
          continue;
        }
        if (j < m - 1 && a[i][j + 1] < a[i][j]) {
          values[i][j] = a[i][j] - a[i][j + 1];
          grid[i][j] = 'R';
          continue;
        }
      }
  for (auto vec : values) {
    for (auto x : vec) cout << x << ' ';
    cout << endl;
  }
  for (auto vec : grid) {
    for (auto x : vec) cout << x << ' ';
    cout << endl;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr);
  int t;
  cin >> t;
  while (t--) solve();
}