#include <bits/stdc++.h>
using namespace std;
const int N = 110;
const int MOD = 1000000007;
const int INF = 1009000999;
const long long LINF = (1ll << 60) + 1337;
const long double EPS = 0.00000001;
int a[N][N];
int n, m;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int tt;
  cin >> tt;
  while (tt--) {
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        cin >> a[i][j];
        if (a[i][j] % 2 != (i + j) % 2) a[i][j]++;
        cout << a[i][j] << " ";
      }
      cout << "\n";
    }
  }
}
