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;
using db = double;
using str = string;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using pd = pair<db, db>;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<ll>;
using vd = vector<db>;
using vs = vector<str>;
using vpi = vector<pi>;
using vpl = vector<pl>;
using vpd = vector<pd>;
template <class T>
using V = vector<T>;
template <class T, size_t SZ>
using AR = array<T, SZ>;
const int MOD = 1e9 + 7;
const int MX = 1e5 + 5;
const ll INF = 1e18;
const ld PI = acos((ld)-1);
const int xd[4] = {1, 0, -1, 0}, yd[4] = {0, 1, 0, -1};
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());
constexpr int pct(int x) { return __builtin_popcount(x); }
constexpr int bits(int x) { return 31 - __builtin_clz(x); }
ll cdiv(ll a, ll b) { return a / b + ((a ^ b) > 0 && a % b); }
ll fdiv(ll a, ll b) { return a / b - ((a ^ b) < 0 && a % b); }
template <class T>
bool ckmin(T& a, const T& b) {
  return b < a ? a = b, 1 : 0;
}
template <class T>
bool ckmax(T& a, const T& b) {
  return a < b ? a = b, 1 : 0;
}
template <class T, class U>
T fstTrue(T lo, T hi, U first) {
  hi++;
  assert(lo <= hi);
  while (lo < hi) {
    T mid = lo + (hi - lo) / 2;
    first(mid) ? hi = mid : lo = mid + 1;
  }
  return lo;
}
template <class T, class U>
T lstTrue(T lo, T hi, U first) {
  lo--;
  assert(lo <= hi);
  while (lo < hi) {
    T mid = lo + (hi - lo + 1) / 2;
    first(mid) ? lo = mid : hi = mid - 1;
  }
  return lo;
}
template <class T>
void remDup(vector<T>& v) {
  sort(begin(v), end(v));
  v.erase(unique(begin(v), end(v)), end(v));
}
template <class T, class U>
void erase(T& t, const U& u) {
  auto it = t.find(u);
  assert(it != end(t));
  t.erase(u);
}
template <class T>
void re(complex<T>& c);
template <class T, class U>
void re(pair<T, U>& p);
template <class T>
void re(vector<T>& v);
template <class T, size_t SZ>
void re(AR<T, SZ>& a);
template <class T>
void re(T& x) {
  cin >> x;
}
void re(db& d) {
  str t;
  re(t);
  d = stod(t);
}
void re(ld& d) {
  str t;
  re(t);
  d = stold(t);
}
template <class T, class... U>
void re(T& t, U&... u) {
  re(t);
  re(u...);
}
template <class T>
void re(complex<T>& c) {
  T a, b;
  re(a, b);
  c = {a, b};
}
template <class T, class U>
void re(pair<T, U>& p) {
  re(p.first, p.second);
}
template <class T>
void re(vector<T>& x) {
  for (auto& a : x) re(a);
}
template <class T, size_t SZ>
void re(AR<T, SZ>& x) {
  for (auto& a : x) re(a);
}
str to_string(char c) { return str(1, c); }
str to_string(const char* second) { return (str)second; }
str to_string(str second) { return second; }
str to_string(bool b) { return to_string((int)b); }
template <class T>
str to_string(complex<T> c) {
  stringstream ss;
  ss << c;
  return ss.str();
}
str to_string(vector<bool> v) {
  str res = "{";
  for (int i = (0); i < ((int)(v).size()); ++i) res += char('0' + v[i]);
  res += "}";
  return res;
}
template <size_t SZ>
str to_string(bitset<SZ> b) {
  str res = "";
  for (int i = (0); i < (SZ); ++i) res += char('0' + b[i]);
  return res;
}
template <class T, class U>
str to_string(pair<T, U> p);
template <class T>
str to_string(T v) {
  bool fst = 1;
  str res = "";
  for (const auto& x : v) {
    if (!fst) res += " ";
    fst = 0;
    res += to_string(x);
  }
  return res;
}
template <class T, class U>
str to_string(pair<T, U> p) {
  return to_string(p.first) + " " + to_string(p.second);
}
template <class T>
void pr(T x) {
  cout << to_string(x);
}
template <class T, class... U>
void pr(const T& t, const U&... u) {
  pr(t);
  pr(u...);
}
void ps() { pr("\n"); }
template <class T, class... U>
void ps(const T& t, const U&... u) {
  pr(t);
  if (sizeof...(u)) pr(" ");
  ps(u...);
}
void DBG() { cerr << "]" << endl; }
template <class T, class... U>
void DBG(const T& t, const U&... u) {
  cerr << to_string(t);
  if (sizeof...(u)) cerr << ", ";
  DBG(u...);
}
void setIn(str second) { freopen(second.c_str(), "r", stdin); }
void setOut(str second) { freopen(second.c_str(), "w", stdout); }
void unsyncIO() { cin.tie(0)->sync_with_stdio(0); }
void setIO(str second = "") {
  unsyncIO();
  if ((int)(second).size()) {
    setIn(second + ".in"), setOut(second + ".out");
  }
}
struct Dinic {
  using F = ll;
  struct Edge {
    int to;
    F flo, cap;
  };
  int N;
  V<Edge> eds;
  V<vi> adj;
  void init(int _N) {
    N = _N;
    adj.resize(N), cur.resize(N);
  }
  void ae(int u, int v, F cap, F rcap = 0) {
    assert(min(cap, rcap) >= 0);
    adj[u].push_back((int)(eds).size());
    eds.push_back({v, 0, cap});
    adj[v].push_back((int)(eds).size());
    eds.push_back({u, 0, rcap});
  }
  vi lev;
  V<vi::iterator> cur;
  bool bfs(int second, int t) {
    lev = vi(N, -1);
    for (int i = (0); i < (N); ++i) cur[i] = begin(adj[i]);
    queue<int> q({second});
    lev[second] = 0;
    while ((int)(q).size()) {
      int u = q.front();
      q.pop();
      for (auto& e : adj[u]) {
        const Edge& E = eds[e];
        int v = E.to;
        if (lev[v] < 0 && E.flo < E.cap) q.push(v), lev[v] = lev[u] + 1;
      }
    }
    return lev[t] >= 0;
  }
  F dfs(int v, int t, F flo) {
    if (v == t) return flo;
    for (; cur[v] != end(adj[v]); cur[v]++) {
      Edge& E = eds[*cur[v]];
      if (lev[E.to] != lev[v] + 1 || E.flo == E.cap) continue;
      F df = dfs(E.to, t, min(flo, E.cap - E.flo));
      if (df) {
        E.flo += df;
        eds[*cur[v] ^ 1].flo -= df;
        return df;
      }
    }
    return 0;
  }
  F maxFlow(int second, int t) {
    F tot = 0;
    while (bfs(second, t))
      while (F df = dfs(second, t, numeric_limits<F>::max())) tot += df;
    return tot;
  }
};
int n, m;
V<vi> A;
int hsh(int a, int b) { return m * a + b; }
Dinic D;
int need;
void fix(int a, int b) {
  D.ae(n * m + 2, b, 1);
  D.ae(a, n * m + 3, 1);
  need++;
}
void solve() {
  re(n, m);
  need = 0;
  A = V<vi>(n, vi(m));
  re(A);
  D = Dinic();
  D.init(n * m + 4);
  D.ae(n * m + 1, n * m, MOD);
  for (int i = (0); i < (n); ++i) {
    for (int j = (0); j < (m); ++j) {
      bool les = 0;
      for (int k = (0); k < (4); ++k) {
        int I = i + xd[k], J = j + yd[k];
        if (I < 0 || I >= n || J < 0 || J >= m) continue;
        les |= A[I][J] < A[i][j];
        if (A[I][J] == A[i][j] && (i + j) % 2 == 0) {
          D.ae(hsh(i, j), hsh(I, J), 1);
        }
      }
      if ((i + j) % 2 == 0) {
        if (les) {
          D.ae(n * m, hsh(i, j), 1);
        } else {
          fix(n * m, hsh(i, j));
        }
      } else {
        if (les) {
          D.ae(hsh(i, j), n * m + 1, 1);
        } else {
          fix(hsh(i, j), n * m + 1);
        }
      }
    }
  }
  if (D.maxFlow(n * m + 2, n * m + 3) != need) {
    ps("NO");
    return;
  }
  vs ans(n, str(m, '.'));
  V<vi> ANS(n, vi(m));
  auto con = [&](int x) -> pi { return {x / m, x % m}; };
  auto make_dir = [&](pi X, pi Y) {
    if (Y == make_pair(X.first + 1, X.second)) ans[X.first][X.second] = 'D';
    if (Y == make_pair(X.first - 1, X.second)) ans[X.first][X.second] = 'U';
    if (Y == make_pair(X.first, X.second + 1)) ans[X.first][X.second] = 'R';
    if (Y == make_pair(X.first, X.second - 1)) ans[X.first][X.second] = 'L';
  };
  auto make_edge = [&](int x, int y) {
    pi X = con(x), Y = con(y);
    ANS[X.first][X.second] = A[X.first][X.second] - 1;
    ANS[Y.first][Y.second] = 1;
    make_dir(X, Y);
    make_dir(Y, X);
  };
  map<int, int> nex;
  for (int i = (0); i < (n * m); ++i)
    for (auto& t : D.adj[i])
      if (D.eds[t].flo > 0 && D.eds[t].to < n * m) {
        make_edge(i, D.eds[t].to);
      }
  for (int i = (0); i < (n); ++i)
    for (int j = (0); j < (m); ++j)
      if (ans[i][j] == '.') {
        for (int k = (0); k < (4); ++k) {
          int I = i + xd[k], J = j + yd[k];
          if (I < 0 || I >= n || J < 0 || J >= m) continue;
          if (A[I][J] < A[i][j]) {
            ANS[i][j] = A[i][j] - A[I][J];
            make_dir({i, j}, {I, J});
          }
        }
      }
  ps("YES");
  for (auto& t : ANS) {
    for (auto& u : t) pr(u, ' ');
    ps();
  }
  for (auto& t : ans) {
    for (auto& u : t) pr(u, ' ');
    ps();
  }
}
int main() {
  setIO();
  int T;
  re(T);
  for (int i = (0); i < (T); ++i) solve();
}