#include <bits/stdc++.h>
using namespace std;
int main() {
int a,b;
cin >> a >> b;
cout << a*b << "\n";
for(int i =0; i < a; i++) {
for(int j =0; j < b; j++) {
cout << i*b+b-j;
if(j < b-1) cout << " ";}
cout << ((i == a-1)?"\n":" ");}
return 0;}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbWFpbigpIHsKCWludCBhLGI7CgljaW4gPj4gYSA+PiBiOwoJY291dCA8PCBhKmIgPDwgIlxuIjsKCWZvcihpbnQgaSA9MDsgaSA8IGE7IGkrKykgewoJCWZvcihpbnQgaiA9MDsgaiA8IGI7IGorKykgewoJCQljb3V0IDw8IGkqYitiLWo7CgkJCWlmKGogPCBiLTEpIGNvdXQgPDwgIiAiO30KCQljb3V0IDw8ICgoaSA9PSBhLTEpPyJcbiI6IiAiKTt9CglyZXR1cm4gMDt9