n, m = map(int, input().split()) print(n*m, n*m) for i in range(n*m): if i < n: print(i+1, (i+1) % n + 1) else: print(i+1, i+1-n)