#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int zz = 1;
  cin >> zz;
  for (int zzz = 1; zzz <= zz; zzz++) {
    int n, m;
    cin >> n >> m;
    int a[n][m];
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++) {
        cin >> a[i][j];
        if ((i + j) % 2 != a[i][j] % 2) ++a[i][j];
      }
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) cout << a[i][j] << " ";
      cout << endl;
    }
  }
  return 0;
}
