#include #include #define rep(i,n) for(int i=0;i vi; typedef vector vl; typedef vector> vvi; typedef vector> vvl; typedef long double ld; typedef pair P; ostream& operator<<(ostream& os, const modint& a) {os << a.val(); return os;} template ostream& operator<<(ostream& os, const static_modint& a) {os << a.val(); return os;} template ostream& operator<<(ostream& os, const dynamic_modint& a) {os << a.val(); return os;} template istream& operator>>(istream& is, vector& v){int n = v.size(); assert(n > 0); rep(i, n) is >> v[i]; return is;} template ostream& operator<<(ostream& os, const pair& p){os << p.first << ' ' << p.second; return os;} template ostream& operator<<(ostream& os, const vector& v){int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "\n" : " "); return os;} template ostream& operator<<(ostream& os, const vector>& v){int n = v.size(); rep(i, n) os << v[i] << (i == n - 1 ? "\n" : ""); return os;} template void chmin(T& a, T b){a = min(a, b);} template void chmax(T& a, T b){a = max(a, b);} int main(){ int n, m; cin >> n >> m; if(n > 1 and m > 1){ cout << "-1\n"; return 0; } bool is_flip = false; if(n > m){ is_flip = true; swap(n, m); } vector> a(2, vector(1 << m)); rep(i, 1 << m) a[0][i] = i; rep(i, 1 << m) a[1][i] = i + (1 << m); if(is_flip){ rep(x, 1 << m){ rep(y, 2) cout << a[y][x] << ' ' ; cout << "\n"; } }else cout << a; return 0; }