#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      int k;
      cin >> k;
      if (k % 2 != (i + j) % 2) k++;
      cout << k << " ";
    }
    cout << endl;
  }
}
int main() {
  int n;
  cin >> n;
  while (n--) {
    solve();
  }
  return 0;
}
