n, m = map(int, input().split()) if n % 2 == 1 or m % 2 == 1: print(-1) exit() print(n*m - 1) for i in range(0, n, 2): t = range(0, m, 2) for j in (t if i%4 == 0 else reversed(t)): if i % 4 == 0: if j == 0: print(i+1, j+2) print(i+2, j+1) else: print(i+2, j+1) print(i+1, j+2) print(i+1, j+1) print(i+2, j+2) else: print(i+1, j+2) print(i+2, j+1) if j == 0: print(i+2, j+2) print(i+1, j+1) else: print(i+1, j+1) print(i+2, j+2)