#include using namespace std; #ifdef TEMPURA #else #define debug(...) ((void)0) #define msg(...) ((void)0) #endif #define rep(i, n) for(int i = 0; i < (int)(n); i++) #define REP(i, m, n) for(int i = (int)(m); i < (int)(n); i++) using ll = long long; using ull = unsigned long long; using i128 = __int128_t; template inline bool chmin(T &a, T b) { if(a > b) { a = b; return true; } return false; } template inline bool chmax(T &a, T b) { if(a < b) { a = b; return true; } return false; } // #include // using mint = atcoder::modint998244353; vector create_permutation(int n) { assert(n % 2 == 0); int b = 0; while((1 << (b + 1)) <= n) { b += 1; } vector ret; int cur = 0; rep(i, (1 << b)) { ret.push_back(cur); if(i % 2 == 0) { if((cur ^ (1 << b)) < n) { ret.push_back(cur ^ (1 << b)); ret.push_back(cur ^ (1 << b) ^ 1); } } int c = countr_zero(unsigned(i + 1)); cur ^= 1 << c; } debug(ret); return ret; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int h, w; cin >> h >> w; if(h % 2 == 1 || w % 2 == 1) { cout << -1 << endl; return 0; } auto vh = create_permutation(h), vw = create_permutation(w); int bh = 32 - countl_zero(unsigned(h - 1)), bw = 32 - countl_zero(unsigned(w - 1)); debug(bh, bw); int ma1 = ((h - 1) << bw) + w - 1, ma2 = ((w - 1) << bh) + h - 1; if(ma1 < ma2) { rep(i, h) { rep(j, w) cout << ((vh[i] << bw) + vw[j]) << " \n"[j + 1 == w]; } } else { rep(i, h) { rep(j, w) cout << (vh[i] + (vw[j] << bh)) << " \n"[j + 1 == w]; } } return 0; }