#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7, mxn = 2e5 + 5;
int n, m;
int gr[101][101];
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        cin >> gr[i][j];
        if ((i + j) % 2 != gr[i][j] % 2) {
          gr[i][j]++;
        }
        cout << gr[i][j] << " ";
      }
      cout << '\n';
    }
  }
  return 0;
}
