#include <bits/stdc++.h>   using namespace std;   void solve(int cnum) {     int di[] = {-1, 0, 0, 1};     int dj[] = {0, -1, 1, 0};     int n, m;     cin >> n >> m;     vector<vector<int>> arr(n, vector<int>(m));     vector<vector<int>> ans(n, vector<int>(m));     for (int i = 0; i < n; ++i)       for (int j = 0; j < m; ++j) cin >> arr[i][j];     auto isvalid = [&](int i, int j) {       if (i < 0 || j < 0) return false;       if (i >= n || j >= m) return false;       return true;     };     for (int i = 0; i < n; ++i) {       for (int j = 0; j < m; ++j) {         int neicnt = 0;         for (int k = 0; k < 4; ++k) {           if (isvalid(i + di[k], j + dj[k])) neicnt++;         }         if (neicnt < arr[i][j]) {           cout <<  NO n ;           return;         }         ans[i][j] = neicnt;       }     }     cout <<  YES n ;     for (auto a : ans) {       for (auto b : a) cout << b <<    ;       cout <<   n ;     }   }   int main() {     int t;     int count = 1;     for (cin >> t; t--; solve(count), count++)       ;     return 0;   }   