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;
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << '{';
  string sep;
  for (const auto &x : v) os << sep << x, sep = ", ";
  return os << '}';
}
template <typename T, size_t size>
ostream &operator<<(ostream &os, const array<T, size> &arr) {
  os << '{';
  string sep;
  for (const auto &x : arr) os << sep << x, sep = ", ";
  return os << '}';
}
template <typename A, typename B>
ostream &operator<<(ostream &os, const pair<A, B> &p) {
  return os << '(' << p.first << ", " << p.second << ')';
}
void dbg_out() { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) {
  cerr << ' ' << H;
  dbg_out(T...);
}
const int INF = 1e9 + 5;
template <typename flow_t>
struct dinic {
  struct edge {
    int node, rev;
    flow_t capacity;
    int id = -1;
    edge() {}
    edge(int _node, int _rev, flow_t _capacity, int _id = -1)
        : node(_node), rev(_rev), capacity(_capacity), id(_id) {}
  };
  int V = -1;
  vector<vector<edge>> adj;
  vector<int> dist;
  vector<int> q;
  int q_start, q_end;
  vector<int> edge_index;
  bool flow_called;
  dinic(int vertices = -1) {
    if (vertices >= 0) init(vertices);
  }
  void init(int vertices) {
    V = vertices;
    adj.assign(V, {});
    dist.resize(V);
    q.resize(V);
    edge_index.resize(V);
    flow_called = false;
  }
  void _add_edge(int u, int v, flow_t capacity1, flow_t capacity2, int id1,
                 int id2) {
    assert(0 <= u && u < V && 0 <= v && v < V);
    edge uv_edge(v, int(adj[v].size()) + (u == v ? 1 : 0), capacity1, id1);
    edge vu_edge(u, int(adj[u].size()), capacity2, id2);
    adj[u].push_back(uv_edge);
    adj[v].push_back(vu_edge);
  }
  void add_directional_edge(int u, int v, flow_t capacity, int id = -1) {
    _add_edge(u, v, capacity, 0, id, -1);
  }
  void add_bidirectional_edge(int u, int v, flow_t capacity, int id = -1) {
    _add_edge(u, v, capacity, capacity, id, id);
  }
  edge &reverse_edge(const edge &e) { return adj[e.node][e.rev]; }
  void bfs_check(int node, int potential_dist) {
    if (potential_dist < dist[node]) {
      dist[node] = potential_dist;
      q[q_end++] = node;
    }
  }
  bool bfs(int source, int sink) {
    fill(dist.begin(), dist.end(), INF);
    q_start = q_end = 0;
    bfs_check(source, 0);
    while (q_start < q_end) {
      int node = q[q_start++];
      for (edge &e : adj[node])
        if (e.capacity > 0) bfs_check(e.node, dist[node] + 1);
    }
    return dist[sink] < INF;
  }
  flow_t dfs(int node, flow_t path_cap, int sink) {
    if (node == sink) return path_cap;
    if (dist[node] >= dist[sink]) return 0;
    flow_t total_flow = 0;
    while (edge_index[node] < int(adj[node].size())) {
      edge &e = adj[node][edge_index[node]];
      if (e.capacity > 0 && dist[node] + 1 == dist[e.node]) {
        flow_t path = dfs(e.node, min(path_cap, e.capacity), sink);
        path_cap -= path;
        e.capacity -= path;
        reverse_edge(e).capacity += path;
        total_flow += path;
      }
      if (path_cap == 0) break;
      edge_index[node]++;
    }
    return total_flow;
  }
  flow_t flow(int source, int sink) {
    assert(V >= 0);
    flow_t total_flow = 0;
    while (bfs(source, sink)) {
      for (int i = 0; i < V; i++) edge_index[i] = 0;
      total_flow += dfs(source, numeric_limits<flow_t>::max(), sink);
    }
    flow_called = true;
    return total_flow;
  }
};
struct constrained_bipartite_matching {
  int N, M;
  int source, sink, dummy_source, dummy_sink;
  vector<pair<int, int>> edges;
  dinic<int> graph;
  constrained_bipartite_matching(int n = 0, int m = 0) { init(n, m); }
  void init(int n, int m) {
    N = n;
    M = m;
    edges = {};
    source = N + M;
    sink = N + M + 1;
    dummy_source = N + M + 2;
    dummy_sink = N + M + 3;
  }
  void add_edge(int a, int b) {
    assert(0 <= a && a < N);
    assert(0 <= b && b < M);
    edges.emplace_back(a, N + b);
  }
  pair<int, int> build_graph(const vector<int> &low, const vector<int> &high,
                             int dummy_cap = INF) {
    assert(int(low.size()) == N + M && int(high.size()) == N + M);
    graph.init(N + M + 4);
    int left_sum = 0, right_sum = 0;
    for (int i = 0; i < int(edges.size()); i++)
      graph.add_directional_edge(edges[i].first, edges[i].second, 1, i);
    for (int i = 0; i < N + M; i++)
      if (i < N) {
        graph.add_directional_edge(source, i, low[i]);
        graph.add_directional_edge(dummy_source, i, high[i] - low[i]);
        left_sum += low[i];
      } else {
        graph.add_directional_edge(i, sink, low[i]);
        graph.add_directional_edge(i, dummy_sink, high[i] - low[i]);
        right_sum += low[i];
      }
    graph.add_directional_edge(source, dummy_sink, right_sum);
    graph.add_directional_edge(dummy_sink, dummy_source, dummy_cap);
    graph.add_directional_edge(dummy_source, sink, left_sum);
    return {left_sum, right_sum};
  }
  int &get_capacity(int from, int to) {
    for (auto &e : graph.adj[from])
      if (e.node == to) return e.capacity;
    assert(false);
  }
  void add_to_dummy_edge(int change) {
    get_capacity(dummy_sink, dummy_source) += change;
  }
  pair<bool, vector<bool>> solve(const vector<int> &low,
                                 const vector<int> &high,
                                 bool require_minimum = false) {
    assert(int(low.size()) == N + M && int(high.size()) == N + M);
    for (int i = 0; i < N + M; i++)
      if (low[i] > high[i]) return {false, {}};
    pair<int, int> sums = build_graph(low, high);
    int left_sum = sums.first, right_sum = sums.second;
    int total_flow = graph.flow(source, sink);
    if (total_flow != left_sum + right_sum) return {false, {}};
    if (require_minimum) {
      int upper = get_capacity(dummy_source, dummy_sink);
      int lower = max(left_sum, right_sum);
      assert(lower <= upper);
      if (lower < upper) {
        cerr << "Searching between " << lower << " and " << upper << endl;
        build_graph(low, high, lower);
        total_flow = graph.flow(source, sink);
        if (total_flow != left_sum + right_sum) {
          while (lower < upper) {
            int mid = (lower + upper + 1) / 2;
            dinic<int> graph_copy = graph;
            int total_flow_copy = total_flow;
            add_to_dummy_edge(mid - lower);
            total_flow += graph.flow(source, sink);
            if (total_flow == left_sum + right_sum) {
              upper = mid - 1;
              graph = graph_copy;
              total_flow = total_flow_copy;
            } else {
              lower = mid;
            }
          }
          assert(total_flow != left_sum + right_sum);
          lower++;
          add_to_dummy_edge(1);
          total_flow += graph.flow(source, sink);
        }
        cerr << "Result: " << lower << endl;
        assert(total_flow == left_sum + right_sum);
      }
    }
    vector<bool> matched(edges.size(), false);
    for (auto &e_list : graph.adj)
      for (auto &e : e_list)
        if (e.id >= 0) matched[e.id] = e.capacity == 0;
    return {true, matched};
  }
};
const int DIRS = 4;
const int DR[DIRS] = {-1, 0, +1, 0};
const int DC[DIRS] = {0, +1, 0, -1};
void run_case() {
  int N, M;
  cin >> N >> M;
  vector<vector<int>> A(N, vector<int>(M));
  for (auto &row : A)
    for (auto &x : row) cin >> x;
  auto valid = [&](int r, int c) { return 0 <= r && r < N && 0 <= c && c < M; };
  vector<vector<bool>> is_local_minimum(N, vector<bool>(M, true));
  for (int r = 0; r < N; r++)
    for (int c = 0; c < M; c++)
      for (int dir = 0; dir < DIRS; dir++) {
        int nr = r + DR[dir];
        int nc = c + DC[dir];
        if (valid(nr, nc) && A[nr][nc] < A[r][c])
          is_local_minimum[r][c] = false;
      }
  int even = (N * M + 1) / 2, odd = N * M / 2;
  constrained_bipartite_matching graph(even, odd);
  auto get_graph_index = [&](int r, int c) { return (r * M + c) / 2; };
  vector<array<int, 4>> edges;
  for (int r = 0; r < N; r++)
    for (int c = r % 2; c < M; c += 2)
      for (int dir = 0; dir < DIRS; dir++) {
        int nr = r + DR[dir];
        int nc = c + DC[dir];
        assert((r + c) % 2 == 0 && (nr + nc) % 2 != 0);
        if (valid(nr, nc) && A[nr][nc] == A[r][c]) {
          graph.add_edge(get_graph_index(r, c), get_graph_index(nr, nc));
          edges.push_back({r, c, nr, nc});
        }
      };
  vector<int> match_low(even + odd, 0), match_high(even + odd, 1);
  for (int r = 0; r < N; r++)
    for (int c = 0; c < M; c++)
      if (is_local_minimum[r][c]) {
        if ((r + c) % 2 == 0)
          match_low[get_graph_index(r, c)] = 1;
        else
          match_low[even + get_graph_index(r, c)] = 1;
      }
  auto result = graph.solve(match_low, match_high);
  if (!result.first) {
    cout << "NO" << '\n';
    return;
  }
  vector<bool> matches = result.second;
  vector<vector<int>> cost_ans(N, vector<int>(M, -1));
  vector<vector<char>> dir_ans(N, vector<char>(M, '?'));
  auto get_dir = [](int dr, int dc) {
    assert((dr != 0) ^ (dc != 0));
    if (dr != 0)
      return dr < 0 ? 'U' : 'D';
    else
      return dc < 0 ? 'L' : 'R';
  };
  for (int i = 0; i < int(matches.size()); i++)
    if (matches[i]) {
      array<int, 4> coords = edges[i];
      int r = coords[0], c = coords[1];
      int nr = coords[2], nc = coords[3];
      assert(A[r][c] == A[nr][nc]);
      cost_ans[r][c] = A[r][c] / 2;
      cost_ans[nr][nc] = (A[r][c] + 1) / 2;
      dir_ans[r][c] = get_dir(nr - r, nc - c);
      dir_ans[nr][nc] = get_dir(r - nr, c - nc);
    }
  for (int r = 0; r < N; r++)
    for (int c = 0; c < M; c++)
      if (dir_ans[r][c] == '?') {
        assert(!is_local_minimum[r][c]);
        for (int dir = 0; dir < DIRS; dir++) {
          int nr = r + DR[dir];
          int nc = c + DC[dir];
          if (valid(nr, nc) && A[nr][nc] < A[r][c]) {
            cost_ans[r][c] = A[r][c] - A[nr][nc];
            dir_ans[r][c] = get_dir(nr - r, nc - c);
            break;
          }
        }
      }
  cout << "YES" << '\n';
  for (int r = 0; r < N; r++)
    for (int c = 0; c < M; c++)
      cout << cost_ans[r][c] << (c < M - 1 ? ' ' : '\n');
  for (int r = 0; r < N; r++)
    for (int c = 0; c < M; c++)
      cout << dir_ans[r][c] << (c < M - 1 ? ' ' : '\n');
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int tests;
  cin >> tests;
  while (tests-- > 0) run_case();
}