X,Y=map(int,input().split()) print(256,256) for i in range(X*(Y-1)): print(i+1,i+X+1) for i in range(X): print(X*(Y-1)+i+1,X*(Y-1)+(i+1)%X+1)