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