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


print(n-1+val-k)

for i in range(2,n+1):
    print('1' + ' ' + str(i))

v = 2
w = 3
while k < val:
    val -= 1
    print(v, w)
    w += 1
    if w == n + 1:
        v += 1
        w = v + 1 n,k = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split k val = (n-1)*(n-2)//2 val (n-1)*(n-2)//2 (n-1)*(n-2) n-1 n 1 n-2 n 2 2 if k > val:print(-1);exit() k > val k val print(n-1+val-k) print n-1+val-k n-1+val n-1 n 1 val k for i in range(2,n+1):
    print('1' + ' ' + str(i)) i range(2,n+1) range 2 n+1 n 1 print('1' + ' ' + str(i)) print '1' + ' ' + str(i) '1' + ' ' '1' ' ' str(i) str i v = 2 v 2 w = 3 w 3 while k < val:
    val -= 1
    print(v, w)
    w += 1
    if w == n + 1:
        v += 1
        w = v + 1 k < val k val val -= 1 val 1 print(v, w) print v w w += 1 w 1 if w == n + 1:
        v += 1
        w = v + 1 w == n + 1 w n + 1 n 1 v += 1 v 1 w = v + 1 w v + 1 v 1 k = map(int,input().split()) map(int,input().split()) k w = 3 3 w n,k = map(int,input().split()) map(int,input().split()) n v = 2 2 v w += 1 1 w w = v + 1 v + 1 w val -= 1 1 val val = (n-1)*(n-2)//2 (n-1)*(n-2)//2 val v += 1 1 v
n,k = map(int,input().split())
val = (n-1)*(n-2)//2
if k > val:print(-1);exit()


print(n-1+val-k)

for i in range(2,n+1):
    print('1' + ' ' + str(i))

v = 2
w = 3
while k < val:
    val -= 1
    print(v, w)
    w += 1
    if w == n + 1:
        v += 1
        w = v + 1