func_code_string: #include <bits/stdc++.h>   #pragma GCC target( avx2 )   #pragma GCC optimization( O3 )   #pragma GCC optimization( unroll-loops )   using namespace std;   using ll = long long;   using ld = long double;   const ll MOD = 1000000007;   const ll root = 62;   ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }   ll binpow(ll a, ll b) {     ll res = 1;     while (b) {       if (b & 1) res = (res * a) % MOD;       a = (a * a) % MOD;       b >>= 1;     }     return res;   }   ll modInv(ll a) { return binpow(a, MOD - 2); }   const double PI = acos(-1);   const double eps = 1e-10;   const int INF = 0x3f3f3f3f;   const int NINF = 0xc0c0c0c0;   const ll INFLL = 0x3f3f3f3f3f3f3f3f;   const ll NINFLL = 0xc0c0c0c0c0c0c0c0;   struct Dinic {     struct Edge {       int to, rev;       ll flo, cap;     };     int N;     vector<vector<Edge>> adj;     void init(int _N) {       N = _N;       adj.resize(N);     }     void add(int a, int b, ll cap, ll 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});     }     vector<int> lev, ptr;     bool bfs(int s, int t) {       lev = ptr = vector<int>(N);       queue<int> Q({s});       lev[s] = 1;       while (!Q.empty()) {         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];     }     ll dfs(int v, int t, ll flo) {       if (v == t) return flo;       for (int& i = ptr[v]; i < (adj[v].size()); i++) {         Edge& e = adj[v][i];         ll dif = e.cap - e.flo;         if (lev[e.to] != lev[v] + 1 || !dif) continue;         if (ll df = dfs(e.to, t, min(flo, dif))) {           e.flo += df;           adj[e.to][e.rev].flo -= df;           return df;         }       }       return 0;     }     ll Flow(int s, int t) {       ll tot = 0;       while (bfs(s, t))         while (ll df = dfs(s, t, numeric_limits<ll>::max())) tot += df;       return tot;     }   };   vector<vector<int>> arr;   vector<vector<char>> res;   vector<vector<int>> ans;   int n, m;   int dx[4] = {1, 0, -1, 0};   int dy[4] = {0, 1, 0, -1};   bool inside(int x, int y) { return x >= 0 && x < n && y >= 0 && y < m; }   pair<int, int> pos(int a) { return {a / m, a % m}; }   char getdir(pair<int, int> a, pair<int, int> b) {     if (a.first == b.first && a.second == b.second - 1) {       return  R ;     } else if (a.first == b.first && a.second == b.second + 1) {       return  L ;     } else if (a.first == b.first - 1 && a.second == b.second) {       return  D ;     } else if (a.first == b.first + 1 && a.second == b.second) {       return  U ;     } else {       cout <<  GFYAHFGAIJOTGIOWGEOG n ;     }     return  ? ;   }   void solve() {     cin >> n >> m;     Dinic G;     G.init(n * m + 4);     arr.resize(n);     res.resize(n);     ans.resize(n);     for (auto i = (0); i < (n); ++i) {       arr[i].resize(m);       res[i].resize(m);       ans[i].resize(m);     }     for (auto i = (0); i < (n); ++i) {       for (auto j = (0); j < (m); ++j) {         cin >> arr[i][j];         ans[i][j] = -1;       }     }     G.add(n * m + 1, n * m, INF);     int req = 0;     for (auto i = (0); i < (n); ++i) {       for (auto j = (0); j < (m); ++j) {         bool go = false;         for (auto d = (0); d < (4); ++d) {           if (inside(i + dx[d], j + dy[d])) {             go |= (arr[i + dx[d]][j + dy[d]] < arr[i][j]);             if (arr[i + dx[d]][j + dy[d]] == arr[i][j] && ((i + j) & 1) == 0) {               G.add(i * m + j, (i + dx[d]) * m + j + dy[d], 1);             }           }         }         if (((i + j) & 1) == 0) {           if (go) {             G.add(n * m, i * m + j, 1);           } else {             G.add(n * m + 2, i * m + j, 1);             G.add(n * m, n * m + 3, 1);             req++;           }         } else {           if (go) {             G.add(i * m + j, n * m + 1, 1);           } else {             G.add(i * m + j, n * m + 3, 1);             G.add(n * m + 2, n * m + 1, 1);             req++;           }         }       }     }     if (G.Flow(n * m + 2, n * m + 3) != req) {       cout <<  NO n ;       return;     }     cout <<  YES n ;     for (auto i = (0); i < (n * m); ++i) {       for (auto e : G.adj[i]) {         if (e.flo > 0 && e.to < n * m) {           auto [x, y] = pos(i);           auto [dx, dy] = pos(e.to);           res[x][y] = getdir({x, y}, {dx, dy});           res[dx][dy] = getdir({dx, dy}, {x, y});           ans[x][y] = 1;           ans[dx][dy] = arr[x][y] - 1;         }       }     }     for (auto i = (0); i < (n); ++i) {       for (auto j = (0); j < (m); ++j) {         if (ans[i][j] != -1) continue;         for (auto d = (0); d < (4); ++d) {           if (inside(i + dx[d], j + dy[d])) {             if (arr[i + dx[d]][j + dy[d]] < arr[i][j]) {               res[i][j] = getdir({i, j}, {i + dx[d], j + dy[d]});               ans[i][j] = arr[i][j] - arr[i + dx[d]][j + dy[d]];             }           }         }       }     }     for (auto i = (0); i < (n); ++i) {       for (auto j = (0); j < (m); ++j) {         cout << ans[i][j] <<    ;       }       cout <<   n ;     }     for (auto i = (0); i < (n); ++i) {       for (auto j = (0); j < (m); ++j) {         cout << res[i][j] <<    ;       }       cout <<   n ;     }     return;   }   int T;   int main() {     mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());     cin.tie(0)->sync_with_stdio(0);     cin >> T;     while (T--) {       solve();     }     return 0;   }   