#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define vbe(v,n,m) v.begin()+n,v.begin()+m
#define int long long
#define fi first
#define sec second
const int mod=1e9+7;
const int N=1e5+7;
#define cy cout<<"YES"<<"\n"
#define cn cout<<"NO"<<"\n"
#define ch(n) cout<<"hello-"<<n<<"\n"
#define cot(n) cout<<n<<"\n"
#define ret(n) cout<<n<<"\n";return
#define print(v) for(auto &it:v){cout<<it<<' ';}cout<<"\n";
void judge(){
#ifndef ONLINE_JUDJE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}
void solve(){
int r, c;
cin >> r >> c;
if(r==1 && c==1){
ret(0);
}
/////////////////////////////////////////////////////////////////////
if(r==1){
int ct = 2;
for (int i = 0; i < c;i++){
cout << ct <<' ';
ct++;
}
return;
}
else if(c==1){
int ct = 2;
for (int i = 0; i < r;i++){
cout << ct << '\n';
ct++;
}
return;
}
/////////////////////////////////////////////////////////////////////
bool cc = false;
bool rr = false;
if(c<r){
cc = true;
}
else if(c>r){
rr = true;
// ch(66);
}
vector<int> row(c, 0);
row[0] = 2;
row[1] = 3;
for (int i = 2; i < c;i++){
if(rr && row[i-1]>=(2*r)){
row[i] = row[i - 1] + 1;
}
else{
row[i] = row[i - 1] + 2;
}
}
/////////////////////////////////////////////////////////////////////
vector<int> col(r, 0);
col[0] = 1;
col[1] = 4;
for (int i = 2; i < r;i++){
if(cc && col[i-1]>=2*c){
col[i] = col[i - 1] + 1;
}
else{
col[i] = col[i - 1] + 2;
}
}
/////////////////////////////////////////////////////////////////////
for (int i = 0; i < r;i++){
for (int j = 0; j < c;j++){
cout << row[j] * col[i] << ' ';
}
cout << '\n';
}
//////////////////////////////////////////////////////////////////////
}
signed main()
{
//judge();
ios_base::sync_with_stdio(false);
cin.tie(NULL);
// int test=0;
// cin>>test;
// while (test--){
solve();
// }
return 0;
}
1006A - Adjacent Replacements | 1195C - Basketball Exercise |
1206A - Choose Two Numbers | 1438B - Valerii Against Everyone |
822A - I'm bored with life | 9A - Die Roll |
1430B - Barrels | 279B - Books |
1374B - Multiply by 2 divide by 6 | 1093B - Letters Rearranging |
1213C - Book Reading | 1468C - Berpizza |
1546B - AquaMoon and Stolen String | 1353C - Board Moves |
902A - Visiting a Friend | 299B - Ksusha the Squirrel |
1647D - Madoka and the Best School in Russia | 1208A - XORinacci |
1539B - Love Song | 22B - Bargaining Table |
1490B - Balanced Remainders | 264A - Escape from Stones |
1506A - Strange Table | 456A - Laptops |
855B - Marvolo Gaunt's Ring | 1454A - Special Permutation |
1359A - Berland Poker | 459A - Pashmak and Garden |
1327B - Princesses and Princes | 1450F - The Struggling Contestant |