#include <bits/stdc++.h>
using namespace std;
long long int n, t, arr[209][209], brr[209][209], crr[209];
vector<long long int> v;
int main() {
  scanf("%lld", &t);
  while (t--) {
    long long int m;
    scanf("%lld %lld", &n, &m);
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) scanf("%lld", &arr[i][j]), brr[i][j] = 0;
    }
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        if (i % 2 == j % 2) {
          if (arr[i][j] % 2 == 0) arr[i][j]++;
        } else {
          if (arr[i][j] % 2) arr[i][j]++;
        }
        printf("%lld ", arr[i][j]);
      }
      printf("\n");
    }
  }
  return 0;
}
