#include <bits/stdc++.h>
using namespace std;
int t, n, m;
const int maxn = 105;
long long a[maxn][maxn];
int main() {
  cin >> t;
  while (t--) {
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        scanf("%lld", &a[i][j]);
        if ((i + j) % 2) {
          if (a[i][j] % 2 == 0) {
            a[i][j]++;
          }
        } else if (a[i][j] % 2)
          a[i][j]++;
      }
    }
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        if (j != m)
          cout << a[i][j] << " ";
        else
          cout << a[i][j] << endl;
      }
    }
  }
  return 0;
}
