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