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