from collections import defaultdict, deque, Counter # from functools import cache # import copy from itertools import combinations, permutations, product, accumulate, groupby, chain # from more_itertools import distinct_permutations from heapq import heapify, heappop, heappush, heappushpop import math import bisect # from pprint import pprint from random import randint, shuffle, randrange # from sortedcontainers import SortedSet, SortedList, SortedDict import sys # sys.setrecursionlimit(2000000) input = lambda: sys.stdin.readline().rstrip('\n') inf = float('inf') mod1 = 10**9+7 mod2 = 998244353 def ceil_div(x, y): return -(-x//y) ################################################# X, Y = map(int, input().split()) N = X*Y; M = X*Y print(N, M) E = [] for i in range(X): print(i+1, (i+1)%X+1) u = X+1 for i in range(1, X+1): for j in range(Y-2): print(u, u+1) u += 1 print(u, i) u += 1