#include <bits/stdc++.h>
using namespace std;
int main() {
  int T, n, m, x;
  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", &x);
        printf("%d%c", x + (x + i + j + 1) % 2, " \n"[j == m]);
      }
  }
  return 0;
}
