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 maxn = 100 * 1000 + 10;
int dx[4] = {-1, -0, +0, +1};
int dy[4] = {-0, -1, +1, +0};
char dir_char[] = "ULRD";
struct Prob {
  int n, m;
  int **a;
  int **num;
  char **dir;
  vector<int> adj[maxn], madj[maxn];
  int match[maxn];
  bool mark[maxn];
  void add_edge(int u, int v) { adj[u].push_back(v); }
  bool is_valid(int i, int j) { return 0 <= i and i < n and 0 <= j and j < m; }
  bool is_black(int id) {
    int i = id / m, j = id % m;
    for (int d = 0; d < 4; d++) {
      int ii = i + dx[d], jj = j + dy[d];
      if (is_valid(ii, jj) and a[ii][jj] < a[i][j]) return false;
    }
    return true;
  }
  bool oddcell(int id) {
    int i = id / m, j = id % m;
    return (i + j) & 1;
  }
  bool evencell(int id) { return !oddcell(id); }
  bool dfs(int u) {
    mark[u] = true;
    for (auto v : adj[u]) {
      if (match[v] == -1) {
        match[u] = v;
        match[v] = u;
        return true;
      }
      if (mark[match[v]]) continue;
      if (dfs(match[v])) {
        match[u] = v;
        match[v] = u;
        return true;
      }
    }
    return false;
  }
  int solve() {
    cin >> n >> m;
    {
      a = new int *[n];
      num = new int *[n];
      dir = new char *[n];
      for (int i = 0; i < n; i++) {
        a[i] = new int[m];
        num[i] = new int[m];
        dir[i] = new char[m];
      }
    }
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++) cin >> a[i][j];
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++)
        for (int d = 0; d < 4; d++) {
          int ii = i + dx[d];
          int jj = j + dy[d];
          if (is_valid(ii, jj) and a[i][j] == a[ii][jj])
            add_edge(i * m + j, ii * m + jj);
        }
    bool found;
    memset(match, -1, sizeof match);
    found = true;
    while (found) {
      memset(mark, false, sizeof mark);
      found = false;
      for (int i = 0; i < n * m; i++)
        if (oddcell(i) and !mark[i] and match[i] == -1 and is_black(i) and
            dfs(i))
          found = true;
    }
    for (int i = 0; i < n * m; i++) {
      if (match[i] != -1)
        madj[i].push_back(match[i]);
      else if (oddcell(i) and is_black(i))
        return cout << "NO\n", 0;
    }
    memset(match, -1, sizeof match);
    found = true;
    while (found) {
      memset(mark, false, sizeof mark);
      found = false;
      for (int i = 0; i < n * m; i++)
        if (evencell(i) and !mark[i] and match[i] == -1 and is_black(i) and
            dfs(i))
          found = true;
    }
    for (int i = 0; i < n * m; i++) {
      if (match[i] != -1 and
          (((int)(madj[i]).size()) == 0 or madj[i][0] != match[i]))
        madj[i].push_back(match[i]);
      if (evencell(i) and match[i] == -1 and is_black(i))
        return cout << "NO\n", 0;
    }
    memset(match, -1, sizeof match);
    memset(mark, false, sizeof mark);
    for (int u = 0; u < n * m; u++)
      if (((int)(madj[u]).size()) == 1 and !mark[u]) {
        vector<int> vec;
        int v = u, prv = -1;
        vec.push_back(v);
        do {
          int cur = v;
          v = madj[v][0] == prv ? madj[v][1] : madj[v][0];
          prv = cur;
          vec.push_back(v);
          mark[v] = true;
        } while (((int)(madj[v]).size()) == 2);
        if (((int)(vec).size()) & 1) {
          for (int i = !is_black(vec[0]); i + 1 < ((int)(vec).size()); i += 2) {
            match[vec[i + 0]] = vec[i + 1];
            match[vec[i + 1]] = vec[i + 0];
          }
        } else {
          for (int i = 0; i < ((int)(vec).size()); i += 2) {
            match[vec[i + 0]] = vec[i + 1];
            match[vec[i + 1]] = vec[i + 0];
          }
        }
      }
    for (int u = 0; u < n * m; u++)
      if (!mark[u] and ((int)(madj[u]).size()) == 2) {
        vector<int> vec;
        int v = u;
        do {
          mark[v] = true;
          vec.push_back(v);
          v = mark[madj[v][0]] ? madj[v][1] : madj[v][1];
        } while (v != u);
        for (int i = 0; i < ((int)(vec).size()); i += 2) {
          match[vec[i + 0]] = vec[i + 1];
          match[vec[i + 1]] = vec[i + 0];
        }
      }
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++) {
        int id = i * m + j;
        if (~match[id]) {
          int ii = match[id] / m, jj = match[id] % m;
          num[i][j] = ((i + j) & 1) ? 1 : a[i][j] - 1;
          for (int d = 0; d < 4; d++)
            if (ii - i == dx[d] and jj - j == dy[d]) dir[i][j] = dir_char[d];
        } else {
          assert(!is_black(id));
          for (int d = 0; d < 4; d++) {
            int ii = i + dx[d], jj = j + dy[d];
            if (is_valid(ii, jj) and a[ii][jj] < a[i][j]) {
              num[i][j] = a[i][j] - a[ii][jj];
              dir[i][j] = dir_char[d];
            }
          }
        }
      }
    cout << "YES\n";
    for (int i = 0; i < n; i++, cout << '\n')
      for (int j = 0; j < m; j++) cout << num[i][j] << ' ';
    for (int i = 0; i < n; i++, cout << '\n')
      for (int j = 0; j < m; j++) cout << dir[i][j] << ' ';
    return 0;
  }
};
int solve() {
  Prob p;
  return p.solve();
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int q;
  cin >> q;
  while (q--) solve();
  return 0;
}