#include <bits/stdc++.h>
using namespace std;
long long power(long long x, long long y, long long m) {
  long long r = 1;
  for (; y; y >>= 1) {
    if (y & 1) r = r * x % m;
    x = x * x % m;
  }
  return r;
}
const long long N = 105, M = 105;
long long a[N][M];
int run_test() {
  long long n, m;
  cin >> n >> m;
  for (long long i = 0; i < n; i++)
    for (long long j = 0; j < m; j++) cin >> a[i][j];
  for (long long i = 0; i < n; i++)
    for (long long j = 0; j < m; j++) {
      if (a[i][j] % 2 != (i + j) % 2) a[i][j]++;
    }
  for (long long i = 0; i < n; i++) {
    for (long long j = 0; j < m; j++) cout << a[i][j] << " ";
    cout << "\n";
  }
  return 0;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  srand(time(NULL));
  ;
  long long t;
  t = 1;
  cin >> t;
  while (t--) {
    run_test();
  }
}
