#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - 48;
    ch = getchar();
  }
  return x * f;
}
const int N = 105;
int n, m, x, a[N][N];
inline void solve() {
  n = read(), m = read();
  for (int i = (1); i <= (n); ++i)
    for (int j = (1); j <= (m); ++j) {
      x = read();
      if (x % 2 == (i + j) % 2) ++x;
      a[i][j] = x;
    }
  for (int i = (1); i <= (n); ++i) {
    for (int j = (1); j <= (m); ++j) printf("%d ", a[i][j]);
    puts("");
  }
}
int main() {
  int T = read();
  while (T--) solve();
  return 0;
}
