#include <bits/stdc++.h>
using namespace std;
void solve(int n, int m) {
  int ar[n][m];
  for (int i = 0; i < n; ++i) {
    int c = i % 2;
    for (int j = 0; j < m; ++j) {
      cin >> ar[i][j];
      int d = ar[i][j];
      if (d % 2 != c % 2) {
        ar[i][j]++;
      }
      ++c;
    }
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      cout << ar[i][j] << ' ';
    }
    cout << "\n";
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t, n, m;
  cin >> t;
  for (int i = 0; i < t; ++i) {
    cin >> n >> m;
    solve(n, m);
    cout << "\n";
  }
  return 0;
}
