#include <bits/stdc++.h>
using namespace std;
int v[103][103];
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        cin >> v[i][j];
      }
    }
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        if (v[i][j] % 2 != (i + j) % 2) {
          v[i][j]++;
        }
      }
    }
    for (int i = 1; i <= n; ++i) {
      for (int j = 1; j <= m; j++) {
        cout << v[i][j] << " ";
      }
      cout << "\n";
    }
  }
  return 0;
}
