#include <bits/stdc++.h>
const long long INF = 1e18;
const long long inf = 1e5 + 5;
using namespace std;
long long power(long long a, long long b) {
  long long result = 1;
  while (b) {
    if (b % 2) result = (result * a) % 1000000007;
    a = (a * a) % 1000000007;
    b /= 2;
  }
  return result;
}
void solve() {
  int n, m, i, j;
  cin >> n >> m;
  long long arr[n][m];
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      cin >> arr[i][j];
      if ((i + j) % 2 == 0) {
        if (arr[i][j] % 2 == 0) {
          arr[i][j]++;
        }
      } else {
        if (arr[i][j] % 2 == 1) {
          arr[i][j]++;
        }
      }
    }
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      cout << arr[i][j] << " ";
    }
    cout << endl;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
