from sys import stdin

N, K = [int(x) for x in stdin.readline().rstrip().split()]

if K > ((N - 1) * (N - 2)) // 2:
    print(-1)
    exit()

ans = []
for i in range(2, N + 1):
    ans.append((1, i))

E = ((N - 1) * (N - 2)) // 2 - K

for j in range(2, N + 1):
    if E == 0:
        break
    for k in range(j + 1, N + 1):
        ans.append((j, k))
        E -= 1
        if E == 0:
            break

print(N - 1 + ((N - 1) * (N - 2)) // 2 - K)
for a in ans:
    print(*a) from sys import stdin int(x) for x in stdin.readline().rstrip().split() for x in stdin.readline().rstrip().split() x stdin.readline().rstrip().split() stdin.readline().rstrip().split stdin.readline().rstrip() stdin.readline().rstrip stdin.readline() stdin.readline stdin readline rstrip split for x in stdin.readline().rstrip().split() int(x) int x N, K = [int(x) for x in stdin.readline().rstrip().split()] N [int(x) for x in stdin.readline().rstrip().split()] K if K > ((N - 1) * (N - 2)) // 2:
    print(-1)
    exit() K > ((N - 1) * (N - 2)) // 2 K ((N - 1) * (N - 2)) // 2 (N - 1) * (N - 2) N - 1 N 1 N - 2 N 2 2 print(-1) print -1 exit() exit ans = [] ans [] for i in range(2, N + 1):
    ans.append((1, i)) i range(2, N + 1) range 2 N + 1 N 1 ans.append((1, i)) ans.append ans append (1, i) 1 i E = ((N - 1) * (N - 2)) // 2 - K E ((N - 1) * (N - 2)) // 2 - K ((N - 1) * (N - 2)) // 2 (N - 1) * (N - 2) N - 1 N 1 N - 2 N 2 2 K for j in range(2, N + 1):
    if E == 0:
        break
    for k in range(j + 1, N + 1):
        ans.append((j, k))
        E -= 1
        if E == 0:
            break j range(2, N + 1) range 2 N + 1 N 1 if E == 0:
        break
     E == 0 E 0 break for k in range(j + 1, N + 1):
        ans.append((j, k))
        E -= 1
        if E == 0:
            break k range(j + 1, N + 1) range j + 1 j 1 N + 1 N 1 ans.append((j, k)) ans.append ans append (j, k) j k E -= 1 E 1 if E == 0:
            break E == 0 E 0 break print(N - 1 + ((N - 1) * (N - 2)) // 2 - K) print N - 1 + ((N - 1) * (N - 2)) // 2 - K N - 1 + ((N - 1) * (N - 2)) // 2 N - 1 N 1 ((N - 1) * (N - 2)) // 2 (N - 1) * (N - 2) N - 1 N 1 N - 2 N 2 2 K for a in ans:
    print(*a) a ans print(*a) print *a a E -= 1 1 E ans = [] [] ans K = [int(x) for x in stdin.readline().rstrip().split()] [int(x) for x in stdin.readline().rstrip().split()] K E = ((N - 1) * (N - 2)) // 2 - K ((N - 1) * (N - 2)) // 2 - K E N, K = [int(x) for x in stdin.readline().rstrip().split()] [int(x) for x in stdin.readline().rstrip().split()] N
from sys import stdin

N, K = [int(x) for x in stdin.readline().rstrip().split()]

if K > ((N - 1) * (N - 2)) // 2:
    print(-1)
    exit()

ans = []
for i in range(2, N + 1):
    ans.append((1, i))

E = ((N - 1) * (N - 2)) // 2 - K

for j in range(2, N + 1):
    if E == 0:
        break
    for k in range(j + 1, N + 1):
        ans.append((j, k))
        E -= 1
        if E == 0:
            break

print(N - 1 + ((N - 1) * (N - 2)) // 2 - K)
for a in ans:
    print(*a)
