#include <bits/stdc++.h>
using namespace std;
int main() {
  int T;
  cin >> T;
  int arr[105][105];
  int n, m;
  for (int cas = 0; cas < T; cas++) {
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        cin >> arr[i][j];
        if ((i + j) % 2) {
          arr[i][j] = arr[i][j] % 2 ? arr[i][j] : arr[i][j] + 1;
        } else {
          arr[i][j] = arr[i][j] % 2 ? arr[i][j] + 1 : arr[i][j];
        }
      }
    }
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        cout << arr[i][j] << ' ';
      }
      cout << endl;
    }
  }
  return 0;
}
