#include <bits/stdc++.h>
using namespace std;
map<int, bool> mp;
const int N = 105;
long long arr[N][N];
int main() {
  int t, n, m;
  long long x;
  cin >> t;
  while (t--) {
    cin >> n >> m;
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++) {
        cin >> arr[i][j];
        if ((i + j) & 1) {
          if (!(arr[i][j] & 1)) arr[i][j] += 1;
        } else {
          if (arr[i][j] & 1) arr[i][j] += 1;
        }
      }
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        cout << arr[i][j] << " ";
      }
      cout << endl;
    }
  }
  return 0;
}
