#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int t;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n >> m;
    int a[n][m];
    for (long long int i = 0; i < n; i++)
      for (long long int j = 0; j < m; j++) {
        cin >> a[i][j];
        if ((i + j) % 2 == 0) {
          if (a[i][j] % 2 == 1) a[i][j] += 1;
        } else {
          if (a[i][j] % 2 == 0) {
            a[i][j] += 1;
          }
        }
      }
    for (long long int i = 0; i < n; i++) {
      for (long long int j = 0; j < m; j++) {
        cout << a[i][j] << " ";
      }
      cout << "\n";
    }
  }
  return 0;
}
