x,y=map(int,input().split()) print(x*y,x*y) for i in range(x):print(i+1,-~i%x+1) for i in range(y-1): for j in range(x): print(i*x-~j,i*x-~j+x)