#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n >> m;
    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 + j) & 1)
          a[i][j] = (a[i][j] & 1) ? a[i][j] : a[i][j] + 1;
        else
          a[i][j] = (a[i][j] & 1) ? a[i][j] + 1 : a[i][j];
      }
    }
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) cout << a[i][j] << " ";
      cout << endl;
    }
  }
}
