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 = 2e5 + 5;
const ll INF = 1e18;
const ld PI = acos((ld)-1);
const int xd[4] = {0, 0, -1, 1}, yd[4] = {-1, 1, 0, 0};
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, rev;
    F flo, cap;
  };
  int N;
  V<V<Edge>> adj;
  void init(int _N) {
    N = _N;
    adj.resize(N);
  }
  void ae(int a, int b, F cap, F rcap = 0) {
    assert(min(cap, rcap) >= 0);
    adj[a].push_back({b, (int)(adj[b]).size(), 0, cap});
    adj[b].push_back({a, (int)(adj[a]).size() - 1, 0, rcap});
  }
  vi lev, ptr;
  bool bfs(int second, int t) {
    lev = ptr = vi(N);
    queue<int> q({second});
    lev[second] = 1;
    while ((int)(q).size()) {
      int u = q.front();
      q.pop();
      for (auto& e : adj[u]) {
        if (!lev[e.to] && e.cap - e.flo) q.push(e.to), lev[e.to] = lev[u] + 1;
      }
    }
    return lev[t];
  }
  F dfs(int v, int t, F flo) {
    if (v == t) return flo;
    for (int& i = ptr[v]; i < (int)(adj[v]).size(); i++) {
      Edge& e = adj[v][i];
      F dif = e.cap - e.flo;
      if (lev[e.to] != lev[v] + 1 || !dif) continue;
      if (F df = dfs(e.to, t, min(flo, dif))) {
        e.flo += df;
        adj[e.to][e.rev].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;
vi g[MX];
vb need;
int mt[MX], vis[MX];
bool bad = 0;
int tt;
int u[MX];
bool dfs(int v) {
  if (u[v] == tt) return false;
  u[v] = tt;
  for (int x : g[v]) {
    if (mt[x] == -1 || dfs(mt[x])) {
      mt[x] = v;
      return true;
    }
  }
  return false;
}
vi SOLVE(vector<int> a, vector<int> b) {
  vector<char> ok(n * m);
  for (int i = (0); i < (n * m); ++i) mt[i] = -1;
  for (int x : b) ok[x] = 1;
  tt++;
  sort(a.begin(), a.end(), [&](int u, int v) { return need[u] > need[v]; });
  for (int x : a) {
    vector<int> now;
    for (int t : g[x]) {
      if (ok[t]) {
        now.push_back(t);
      }
    }
    g[x] = now;
  }
  vector<int> ret;
  for (int x : a) {
    if (dfs(x)) {
      ret.push_back(x);
      tt++;
    } else if (need[x]) {
      bad = true;
    }
  }
  return ret;
}
void solve() {
  re(n, m);
  A = V<vi>(n, vi(m));
  re(A);
  need = vb(n * m);
  for (int i = (0); i < (n * m); ++i) g[i].clear();
  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]) g[hsh(i, j)].push_back(hsh(I, J));
      }
      if (!les) {
        need[hsh(i, j)] = 1;
        0;
      }
    }
  }
  bad = 0;
  vi l, r;
  for (int i = (0); i < (n); ++i)
    for (int j = (0); j < (m); ++j) {
      if ((i + j) & 1)
        l.push_back(hsh(i, j));
      else
        r.push_back(hsh(i, j));
    }
  0;
  vi L = SOLVE(l, r);
  if (bad) {
    ps("NO");
    return;
  }
  0;
  vi R = SOLVE(r, L);
  0;
  if (bad) {
    ps("NO");
    return;
  }
  0;
  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);
  };
  for (int i = (0); i < (n * m); ++i)
    if (mt[i] != -1) {
      make_edge(mt[i], i);
      0;
    }
  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();
}