n, k = map(int, input().split()) if n == 1: if k == 0: print(-1) else: print(1) print(1, 1) exit() if 2 * k < n: print(-1) exit() print(n + k) for i in range(1, k + 1): print(i, i) j = 1 + n // 2 for i in range(1, n + 1): print(i, j) j += 1 if j > n: j -= n