#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n, m;
  cin >> n >> m;
  long long arr[n][m];
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      cin >> arr[i][j];
    }
  }
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      if (i % 2 == 0) {
        if (j % 2 == 0) {
          if (arr[i][j] % 2 == 1) arr[i][j]++;
        } else {
          if (arr[i][j] % 2 == 0) arr[i][j]++;
        }
      } else {
        if (j % 2 == 0) {
          if (arr[i][j] % 2 == 0) arr[i][j]++;
        } else {
          if (arr[i][j] % 2 == 1) arr[i][j]++;
        }
      }
    }
  }
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) {
      cout << arr[i][j] << " ";
    }
    cout << "\n";
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long T;
  T = 1;
  cin >> T;
  while (T--) {
    solve();
  }
  return 0;
}
