#include <bits/stdc++.h>
using namespace std;
template <typename A>
ostream &operator<<(ostream &cout, vector<A> const &v) {
  cout << "[";
  for (int i = 0; i < v.size(); i++) {
    if (i) cout << ", ";
    cout << v[i];
  }
  return cout << "]";
}
template <typename A, typename B>
ostream &operator<<(ostream &cout, pair<A, B> const &p) {
  return cout << "(" << p.first << ", " << p.second << ")";
}
template <typename A, typename B>
istream &operator>>(istream &cin, pair<A, B> &p) {
  cin >> p.first;
  return cin >> p.second;
}
long long int const mod = 998244353;
long long int const maxn = 1e6 + 9;
void solve() {
  int n, m;
  cin >> n >> m;
  int lol[n][m];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) cin >> lol[i][j];
  }
  int c = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (c == 0) {
        if (j % 2 == 0) {
          if (lol[i][j] % 2 == 1) lol[i][j]++;
        } else {
          if (lol[i][j] % 2 == 0) lol[i][j]++;
        }
      } else {
        if (j % 2 == 0) {
          if (lol[i][j] % 2 == 0) lol[i][j]++;
        } else {
          if (lol[i][j] % 2 == 1) lol[i][j]++;
        }
      }
      cout << lol[i][j] << " ";
    }
    c ^= 1;
    cout << endl;
  }
  cout << endl;
}
int main() {
  int tc;
  cin >> tc;
  while (tc--) solve();
}
