#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> a(n, vector<int>(m));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }
  vector<vector<int>> b = a;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (a[i][j] % 2 != (i + j) % 2)
        b[i][j] = a[i][j] + 1;
      else
        b[i][j] = a[i][j];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cout << b[i][j] << ' ';
    }
    cout << "\n";
  }
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
