#include <bits/stdc++.h>
const int N = 5e5 + 5, INF = 0x3f3f3f3f, mod = 1e9 + 7;
using namespace std;
namespace fast_IO {
long long read() {
  long long x = 0;
  char c;
  bool flag = false;
  while ((c = getchar()) == ' ' || c == '\n' || c == '\r')
    ;
  if (c == '-')
    flag = true;
  else
    x = c ^ 48;
  while ((c = getchar()) != ' ' && c != '\n' && c != '\r' && ~c)
    x = (x << 1) + (x << 3) + (c ^ 48);
  if (flag) return -x;
  return x;
}
void write(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x >= 10) write(x / 10);
  putchar(x % 10 ^ 48);
}
}  // namespace fast_IO
int a[105][105];
bool flag[105][105];
int main() {
  int T = fast_IO::read();
  while (T--) {
    int n = fast_IO::read(), m = fast_IO::read();
    for (int i = 1; i <= n; ++i)
      for (int j = 1; j <= m; ++j) a[i][j] = fast_IO::read();
    for (int i = 1; i <= n; ++i)
      for (int j = 1; j <= m; ++j)
        if (((a[i][j] & 1) && i + j & 1) || (!(a[i][j] & 1) && !(i + j & 1)))
          ++a[i][j];
    for (int i = 1; i <= n; ++i) {
      for (int j = 1; j <= m; ++j) printf("%d ", a[i][j]);
      putchar('\n');
    }
  }
  return 0;
}
