#include <bits/stdc++.h>
using namespace std;
int main() {
  int T;
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  while (cin >> T) {
    while (T--) {
      int n, m;
      cin >> n >> m;
      int a[105][105], cnt = 0;
      for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
          cin >> a[i][j];
          if ((i + j) & 1) {
            if ((a[i][j] & 1) == 0) a[i][j]++;
          } else {
            if (a[i][j] & 1) a[i][j]++;
          }
        }
      }
      for (int i = 0; i < n; i++) {
        for (int j = 0; j < m - 1; j++) cout << a[i][j] << ' ';
        cout << a[i][m - 1] << endl;
      }
    }
  }
  return 0;
}
