#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  int b = 1;
  int a[100][100];
  int h;
  string ans = "NO";
  cin >> h;
  for (int q = 0; q < h; q++) {
    cin >> n;
    cin >> b;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < b; j++) {
        cin >> a[i][j];
      }
    }
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < b; j++) {
        if ((i + j) % 2 == 1 && a[i][j] % 2 == 0) {
          a[i][j]++;
        }
        if ((i + j) % 2 == 0 && a[i][j] % 2 == 1) {
          a[i][j]++;
        }
      }
    }
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < b; j++) {
        cout << a[i][j] << " ";
      }
      cout << endl;
    }
  }
}
