#include <bits/stdc++.h>
using namespace std;
int A[100][100];
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < n; ++i)
      for (int j = 0; j < m; ++j) cin >> A[i][j];
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < m; ++j) {
        if ((i + j) % 2 != A[i][j] % 2) A[i][j] += 1;
        cout << A[i][j] << ' ';
      }
      cout << '\n';
    }
  }
  return 0;
}
