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;
namespace Dinic {
struct edge {
  int from, to, flow, next;
} E[400000 * 2 + 5];
int head[100000 + 5], cur[100000 + 5];
int esz = 1;
vector<int> nodes;
void add_edge(int u, int v, int w) {
  nodes.push_back(u);
  nodes.push_back(v);
  esz++;
  E[esz].from = u;
  E[esz].to = v;
  E[esz].flow = w;
  E[esz].next = head[u];
  head[u] = esz;
  esz++;
  E[esz].from = v;
  E[esz].to = u;
  E[esz].flow = 0;
  E[esz].next = head[v];
  head[v] = esz;
}
int deep[100000 + 5];
bool bfs(int s, int t) {
  for (int first : nodes) deep[first] = 0;
  queue<int> q;
  deep[s] = 1;
  q.push(s);
  while (!q.empty()) {
    int first = q.front();
    q.pop();
    for (int i = head[first]; i; i = E[i].next) {
      int second = E[i].to;
      if (!deep[second] && E[i].flow) {
        deep[second] = deep[first] + 1;
        q.push(second);
      }
    }
  }
  return deep[t] > 0;
}
int dfs(int first, int t, int minf) {
  if (first == t) return minf;
  int rest = minf, k;
  for (int &i = cur[first]; i; i = E[i].next) {
    int second = E[i].to;
    if (E[i].flow && deep[second] == deep[first] + 1) {
      k = dfs(second, t, min(rest, E[i].flow));
      E[i].flow -= k;
      E[i ^ 1].flow += k;
      rest -= k;
      if (k == 0) deep[second] = 0;
      if (rest == 0) break;
    }
  }
  return minf - rest;
}
int dinic(int s, int t) {
  int ans = 0, now;
  while (bfs(s, t)) {
    for (int first : nodes) cur[first] = head[first];
    while ((now = dfs(s, t, 0x3f3f3f3f))) ans += now;
  }
  return ans;
}
void clear() {
  esz = 1;
  for (int first : nodes) head[first] = 0;
  nodes.clear();
}
}  // namespace Dinic
namespace bdf {
struct edgeb {
  int from, to, lb, rb;
} E[400000 + 5];
int esz = 0;
int suml = 0;
vector<int> nodes;
void add_edge(int u, int v, int l, int r) {
  esz++;
  E[esz].from = u;
  E[esz].to = v;
  E[esz].lb = l;
  E[esz].rb = r;
  suml += l;
  nodes.push_back(u);
  nodes.push_back(v);
}
int dflow[100000 + 5];
int solve(int s, int t) {
  Dinic::clear();
  int ss = t + 1, tt = t + 2;
  add_edge(t, s, 0, 0x3f3f3f3f);
  sort(nodes.begin(), nodes.end());
  nodes.resize(unique(nodes.begin(), nodes.end()) - nodes.begin());
  for (int i = 1; i <= esz; i++) {
    dflow[E[i].to] += E[i].lb;
    dflow[E[i].from] -= E[i].lb;
    Dinic::add_edge(E[i].from, E[i].to, E[i].rb - E[i].lb);
  }
  int sum = 0;
  for (int i : nodes) {
    if (dflow[i] > 0) {
      Dinic::add_edge(ss, i, dflow[i]);
      sum += dflow[i];
    } else if (dflow[i] < 0)
      Dinic::add_edge(i, tt, -dflow[i]);
  }
  int delta = Dinic::dinic(ss, tt);
  if (delta != sum)
    return -1;
  else
    return delta + suml;
}
void clear() {
  esz = 0;
  suml = 0;
  for (int first : nodes) dflow[first] = 0;
  nodes.clear();
  Dinic::clear();
}
}  // namespace bdf
int T, n, m;
vector<int> c[100000 + 5];
vector<int> ans[100000 + 5];
vector<pair<int, int> > poi;
inline int gid(int first, int second) { return (first - 1) * m + second; }
inline int gx(int id) { return id % m == 0 ? id / m : id / m + 1; }
inline int gy(int id) { return id % m == 0 ? m : id % m; }
const char dirs[5] = "RLDU";
const int dirx[4] = {0, 0, 1, -1}, diry[4] = {1, -1, 0, 0};
void solve() {
  poi.clear();
  for (int i = 1; i <= n; i++) ans[i].resize(m + 1);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) poi.push_back(make_pair(i, j));
  sort(poi.begin(), poi.end(), [&](pair<int, int> p, pair<int, int> q) -> bool {
    return c[p.first][p.second] < c[q.first][q.second];
  });
  for (int l = 0, r; l < (int)poi.size(); l++) {
    r = l;
    while (r + 1 < (int)poi.size() &&
           c[poi[l].first][poi[l].second] ==
               c[poi[r + 1].first][poi[r + 1].second])
      r++;
    bdf::clear();
    int s = n * m + 1, t = n * m + 2;
    for (int i = l; i <= r; i++) {
      int first = poi[i].first, second = poi[i].second;
      int flag = 1;
      for (int k = 0; k < 4; k++) {
        int xx = first + dirx[k], yy = second + diry[k];
        if (xx >= 1 && xx <= n && yy >= 1 && yy <= m) {
          if (c[xx][yy] < c[first][second]) {
            flag = 0;
            ans[first][second] = k;
          } else if (c[xx][yy] == c[first][second]) {
            if ((first + second) % 2)
              bdf::add_edge(gid(first, second), gid(xx, yy), 0, 1);
          }
        }
      }
      if ((first + second) % 2)
        bdf::add_edge(s, gid(first, second), flag, 1);
      else
        bdf::add_edge(gid(first, second), t, flag, 1);
    }
    if (c[poi[l].first][poi[l].second] == 3) {
      s = n * m + 1;
    }
    if (bdf::solve(s, t) == -1) {
      puts("NO");
      return;
    } else {
      for (int i = l; i <= r; i++) {
        int first = poi[i].first, second = poi[i].second;
        if ((first + second) % 2) {
          int u = gid(first, second);
          for (int j = Dinic::head[u]; j; j = Dinic::E[j].next) {
            int v = Dinic::E[j].to;
            if (v <= n * m && Dinic::E[j ^ 1].flow) {
              int xx = gx(v), yy = gy(v);
              for (int k = 0; k < 4; k++)
                if (first + dirx[k] == xx && second + diry[k] == yy)
                  ans[first][second] = k;
              ans[xx][yy] = ans[first][second] ^ 1;
              break;
            }
          }
        }
      }
    }
    l = r;
  }
  puts("YES");
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      int first = i + dirx[ans[i][j]], second = j + diry[ans[i][j]];
      if (c[i][j] == c[first][second])
        printf("%d ", (c[i][j] + (i + j) % 2) / 2);
      else
        printf("%d ", c[i][j] - c[first][second]);
    }
    puts("");
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) printf("%c ", dirs[ans[i][j]]);
    puts("");
  }
}
int main() {
  scanf("%d", &T);
  while (T--) {
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= n; i++) {
      c[i].resize(m + 1);
      for (int j = 1; j <= m; j++) scanf("%d", &c[i][j]);
    }
    solve();
  }
}