import sys input = lambda: sys.stdin.readline().rstrip() # sys.setrecursionlimit(10**7) # sys.set_int_max_str_digits(10**6) # import pypyjit # pypyjit.set_param('max_unroll_recursion=-1') def mp():return map(int,input().split()) def lmp():return list(map(int,input().split())) def lm1(LIST): return list(map(lambda x:x-1, LIST)) def mps(A):return [tuple(map(int, input().split())) for _ in range(A)] def stoi(LIST):return list(map(int,LIST)) def itos(LIST):return list(map(str,LIST)) def atoi(LIST): return [ord(i)-ord("a") for i in LIST] def Atoi(LIST): return [ord(i)-ord("A") for i in LIST] def LT(LIST,N): return LIST[bisect.bisect_left(LIST,N)-1] def LE(LIST,N): return LIST[bisect.bisect_right(LIST,N)-1] def GT(LIST,N): return LIST[bisect.bisect_right(LIST,N)] def GE(LIST,N): return LIST[bisect.bisect_left(LIST,N)] def bitA(X,A):return X & 1<= 1200 and u[:4].count("o") != 4: # # ans += 1 # print(ans) # ok = 0 # ng = 10**9+1 # while (ok-ng) != 1: # m = (ok+ng)//2 # print(m) # ans = int(input()) # if ans == 1: # exit() # elif ans == 0: # ng = m x,y = mp() print(x*y,x*y) for i in range(x-1): print(i+1,i+2) print(x,1) for i in range(1,x+1): for j in range(1,y): print(i+(j-1)*x,j*x+i)