import sys
sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


N, K = map(int, input().split())

up = (N - 1) * (N - 2) // 2

if up < K:
    print(-1)
    exit()

res = []

for i in range(2, N+1):
    res.append((1, i))

K = up - K

for i in range(2, N):
    for j in range(i+1, N + 1):
        if K == 0:
            break
        res.append((i, j))
        K -= 1

    if K == 0:
        break

print(len(res))

for u, v in res:
    print(u, v) import sys sys sys.setrecursionlimit(10 ** 7) sys.setrecursionlimit sys setrecursionlimit 10 ** 7 10 7 read = sys.stdin.buffer.read read sys.stdin.buffer.read sys.stdin.buffer sys.stdin sys stdin buffer read readline = sys.stdin.buffer.readline readline sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline readlines = sys.stdin.buffer.readlines readlines sys.stdin.buffer.readlines sys.stdin.buffer sys.stdin sys stdin buffer readlines N, K = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split K up = (N - 1) * (N - 2) // 2 up (N - 1) * (N - 2) // 2 (N - 1) * (N - 2) N - 1 N 1 N - 2 N 2 2 if up < K:
    print(-1)
    exit() up < K up K print(-1) print -1 exit() exit res = [] res [] for i in range(2, N+1):
    res.append((1, i)) i range(2, N+1) range 2 N+1 N 1 res.append((1, i)) res.append res append (1, i) 1 i K = up - K K up - K up K for i in range(2, N):
    for j in range(i+1, N + 1):
        if K == 0:
            break
        res.append((i, j))
        K -= 1

    if K == 0:
        break i range(2, N) range 2 N for j in range(i+1, N + 1):
        if K == 0:
            break
        res.append((i, j))
        K -= 1

     j range(i+1, N + 1) range i+1 i 1 N + 1 N 1 if K == 0:
            break
         K == 0 K 0 break res.append((i, j)) res.append res append (i, j) i j K -= 1 K 1 if K == 0:
        break K == 0 K 0 break print(len(res)) print len(res) len res for u, v in res:
    print(u, v) u v res print(u, v) print u v res = [] [] res readlines = sys.stdin.buffer.readlines sys.stdin.buffer.readlines readlines N, K = map(int, input().split()) map(int, input().split()) N K -= 1 1 K read = sys.stdin.buffer.read sys.stdin.buffer.read read readline = sys.stdin.buffer.readline sys.stdin.buffer.readline readline K = map(int, input().split()) map(int, input().split()) K up = (N - 1) * (N - 2) // 2 (N - 1) * (N - 2) // 2 up K = up - K up - K K
import sys
sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


N, K = map(int, input().split())

up = (N - 1) * (N - 2) // 2

if up < K:
    print(-1)
    exit()

res = []

for i in range(2, N+1):
    res.append((1, i))

K = up - K

for i in range(2, N):
    for j in range(i+1, N + 1):
        if K == 0:
            break
        res.append((i, j))
        K -= 1

    if K == 0:
        break

print(len(res))

for u, v in res:
    print(u, v)
