n,k = map(int,input().split())
mx = (n - 1) * (n - 2) // 2
if mx < k:
    print(-1)
    exit()

l,r = 1,2

res = []
for i in range(1, n):
    res.append([i, n])

while mx > k:
    mx -= 1
    res.append([l, r])
    if r == n - 1:
        l += 1
        r = l + 1
    else:
        r += 1

print(len(res))
for i in res:
    print(*i) n,k = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split k mx = (n - 1) * (n - 2) // 2 mx (n - 1) * (n - 2) // 2 (n - 1) * (n - 2) n - 1 n 1 n - 2 n 2 2 if mx < k:
    print(-1)
    exit() mx < k mx k print(-1) print -1 exit() exit l,r = 1,2 l 1 r 2 res = [] res [] for i in range(1, n):
    res.append([i, n]) i range(1, n) range 1 n res.append([i, n]) res.append res append [i, n] i n while mx > k:
    mx -= 1
    res.append([l, r])
    if r == n - 1:
        l += 1
        r = l + 1
    else:
        r += 1 mx > k mx k mx -= 1 mx 1 res.append([l, r]) res.append res append [l, r] l r if r == n - 1:
        l += 1
        r = l + 1
    else:
        r += 1 r == n - 1 r n - 1 n 1 l += 1 l 1 r = l + 1 r l + 1 l 1 r += 1 r 1 print(len(res)) print len(res) len res for i in res:
    print(*i) i res print(*i) print *i i n,k = map(int,input().split()) map(int,input().split()) n r = l + 1 l + 1 r r = 1,2 2 r res = [] [] res r += 1 1 r mx -= 1 1 mx k = map(int,input().split()) map(int,input().split()) k l += 1 1 l mx = (n - 1) * (n - 2) // 2 (n - 1) * (n - 2) // 2 mx l,r = 1,2 1 l
n,k = map(int,input().split())
mx = (n - 1) * (n - 2) // 2
if mx < k:
    print(-1)
    exit()

l,r = 1,2

res = []
for i in range(1, n):
    res.append([i, n])

while mx > k:
    mx -= 1
    res.append([l, r])
    if r == n - 1:
        l += 1
        r = l + 1
    else:
        r += 1

print(len(res))
for i in res:
    print(*i)