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