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