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 infinity = 1e7;
class DinitzFlow {
 private:
  struct Edge {
    int src, dst, cap, flow;
    Edge() {}
    Edge(int src, int dst, int cap, int flow)
        : src(src), dst(dst), cap(cap), flow(flow) {}
  };
  int n, s, t;
  vector<Edge> edges;
  vector<vector<int>> g;
  vector<int> layer;
  vector<int> ptr;
  inline bool bfs() {
    layer.assign(n, -1);
    queue<int> q;
    layer[s] = 0;
    q.push(s);
    while (!q.empty() && layer[t] < 0) {
      int v = q.front();
      q.pop();
      for (int eid : g[v]) {
        int to = edges[eid].dst;
        if (edges[eid].cap > edges[eid].flow) {
          if (layer[to] < 0) {
            layer[to] = layer[v] + 1;
            q.push(to);
          }
        }
      }
    }
    return layer[t] >= 0;
  }
  int dfs(int v, int flow = infinity) {
    if (v == t) {
      return flow;
    }
    if (flow == 0) {
      return 0;
    }
    for (; ptr[v] < (int)g[v].size(); ptr[v]++) {
      int eid = g[v][ptr[v]];
      int to = edges[eid].dst;
      if (layer[to] == layer[v] + 1) {
        int can = edges[eid].cap - edges[eid].flow;
        int pushed = dfs(to, min(flow, can));
        if (pushed > 0) {
          edges[eid].flow += pushed;
          edges[eid ^ 1].flow -= pushed;
          return pushed;
        }
      }
    }
    return 0;
  }

 public:
  inline void changeSrcDst(int ns, int nt) {
    s = ns;
    t = nt;
    for (Edge &e : edges) {
      e.flow = 0;
    }
  }
  inline const vector<Edge> &getEdges() const { return edges; }
  inline vector<char> getCut() {
    vector<char> side(n, 0);
    function<void(int)> dfs = [&](int v) {
      if (side[v]) {
        return;
      }
      side[v] = 1;
      for (int eid : g[v]) {
        if (edges[eid].cap == edges[eid].flow) {
          continue;
        }
        dfs(edges[eid].dst);
      }
    };
    dfs(s);
    return side;
  }
  inline int flow() {
    int ans = 0;
    while (bfs()) {
      ptr.assign(n, 0);
      int pushed = dfs(s);
      while (pushed != 0) {
        ans += pushed;
        pushed = dfs(s);
      }
    }
    return ans;
  }
  inline void addEdge(int src, int dst, int cap) {
    g[src].push_back(edges.size());
    edges.emplace_back(src, dst, cap, 0);
    g[dst].push_back(edges.size());
    edges.emplace_back(dst, src, 0, 0);
  }
  DinitzFlow(int n, int s, int t) : n(n), s(s), t(t), g(n), layer(n), ptr(n) {}
};
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int tst;
  cin >> tst;
  while (tst--) {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> a(n, vector<int>(m, 0));
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        cin >> a[i][j];
      }
    }
    vector<vector<bool>> good(n, vector<bool>(m, false));
    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];
          int ny = j + dy[k];
          if (nx < 0 || nx >= n || ny < 0 || ny >= m) continue;
          if (a[i][j] > a[nx][ny]) good[i][j] = true;
        }
      }
    }
    int old_source = n * m;
    int old_sink = n * m + 1;
    int new_source = n * m + 2;
    int new_sink = n * m + 3;
    DinitzFlow ds(new_sink + 1, new_source, new_sink);
    int sum = 0;
    auto add_edge = [&](int from, int to, int l, int r) {
      sum += l;
      if (l == 0) {
        ds.addEdge(from, to, r);
      } else {
        ds.addEdge(from, to, r - l);
        ds.addEdge(new_source, to, l);
        ds.addEdge(from, new_sink, l);
      }
    };
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if ((i + j) % 2 == 0) {
          add_edge(old_source, i * m + j, !good[i][j], 1);
        } else {
          add_edge(i * m + j, old_sink, !good[i][j], 1);
        }
        for (int k = 0; k < 4; k++) {
          int ni = i + dx[k];
          int nj = j + dy[k];
          if (ni < 0 || ni >= n || nj < 0 || nj >= m) continue;
          if (a[i][j] != a[ni][nj]) continue;
          if ((i + j) % 2 == 0) {
            ds.addEdge(i * m + j, ni * m + nj, 1);
          } else {
            ds.addEdge(ni * m + nj, i * m + j, 1);
          }
        }
      }
    }
    ds.addEdge(old_sink, old_source, 3 * n * m);
    int p = ds.flow();
    if (p != sum) {
      cout << "NO\n";
      continue;
    }
    vector<vector<char>> sym(n, vector<char>(m, 'Z'));
    vector<vector<int>> val(n, vector<int>(m));
    for (auto &it : ds.getEdges()) {
      if (it.src < n * m && it.dst < n * m && it.flow > 0) {
        int x = it.src / m;
        int y = it.src % m;
        int nx = it.dst / m;
        int ny = it.dst % m;
        if ((x + y) % 2 == 0) {
          assert(it.flow == 1);
          assert(abs(nx - x) + abs(ny - y) == 1);
          assert(a[x][y] == a[nx][ny]);
          val[x][y] = 1;
          val[nx][ny] = a[x][y] - 1;
          if (ny == y - 1) {
            sym[x][y] = 'L';
            sym[nx][ny] = 'R';
          } else if (ny == y + 1) {
            sym[x][y] = 'R';
            sym[nx][ny] = 'L';
          } else if (nx == x + 1) {
            sym[x][y] = 'D';
            sym[nx][ny] = 'U';
          } else {
            sym[x][y] = 'U';
            sym[nx][ny] = 'D';
          }
        }
      }
    }
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        if (sym[i][j] != 'Z') continue;
        for (int k = 0; k < 4; k++) {
          int ni = i + dx[k];
          int nj = j + dy[k];
          if (ni < 0 || ni >= n || nj < 0 || nj >= m) continue;
          if (a[i][j] > a[ni][nj]) {
            val[i][j] = a[i][j] - a[ni][nj];
            int x = i;
            int y = j;
            int nx = ni;
            int ny = nj;
            if (ny == y - 1) {
              sym[x][y] = 'L';
            } else if (ny == y + 1) {
              sym[x][y] = 'R';
            } else if (nx == x + 1) {
              sym[x][y] = 'D';
            } else {
              sym[x][y] = 'U';
            }
            break;
          }
        }
      }
    }
    cout << "YES\n";
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        cout << val[i][j] << " ";
      }
      cout << '\n';
    }
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        assert(sym[i][j] != 'Z');
        cout << sym[i][j] << " ";
      }
      cout << '\n';
    }
  }
  return 0;
}