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