#include <bits/stdc++.h>
int T, N, M;
int a[105][105];
int main() {
  scanf("%d", &T);
  while (T--) {
    scanf("%d %d", &N, &M);
    for (int i = 1; i <= N; i++) {
      for (int j = 1; j <= M; j++) {
        scanf("%d", &a[i][j]);
        if ((i + j) % 2 != a[i][j] % 2) a[i][j]++;
      }
    }
    for (int i = 1; i <= N; i++) {
      for (int j = 1; j <= M; j++) {
        printf("%d ", a[i][j]);
      }
      printf("\n");
    }
  }
}
