a,b = map(int,input().split())

S  = (a-1)*(a-2)//2
def solve(x,y,s):
    print(a+s-y-1)
    for i in range(1,a):print(1,1+i)
    c = s-b
    for i in range(1,a):
        for I in range(i+1,a):
            if c > 0:
                print(i+1,I+1)
                c-=1
            else:exit()
# print(b,S)
if not 0<= b <= S:
    print(-1)
    exit()
else:
    solve(a,b,S) a,b = map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b S  = (a-1)*(a-2)//2 S (a-1)*(a-2)//2 (a-1)*(a-2) a-1 a 1 a-2 a 2 2 def solve(x,y,s):
    print(a+s-y-1)
    for i in range(1,a):print(1,1+i)
    c = s-b
    for i in range(1,a):
        for I in range(i+1,a):
            if c > 0:
                print(i+1,I+1)
                c-=1
            else:exit()
# print(b,S) solve print(a+s-y-1) print a+s-y-1 a+s-y a+s a s y 1 for i in range(1,a):print(1,1+i)
     i range(1,a) range 1 a c = s-b c s-b s b for i in range(1,a):
        for I in range(i+1,a):
            if c > 0:
                print(i+1,I+1)
                c-=1
            else:exit()
# print(b,S) i range(1,a) range 1 a for I in range(i+1,a):
            if c > 0:
                print(i+1,I+1)
                c-=1
            else:exit()
# print(b,S) I range(i+1,a) range i+1 i 1 a if c > 0:
                print(i+1,I+1)
                c-=1
            else:exit()
# print(b,S) c > 0 c 0 print(i+1,I+1) print i+1 i 1 I+1 I 1 c-=1 c 1 x x y y s s if not 0<= b <= S:
    print(-1)
    exit()
else:
    solve(a,b,S) not 0<= b <= S 0<= b <= S 0<= b 0 b S print(-1) print -1 exit() exit solve(a,b,S) solve a b S a,b = map(int,input().split()) map(int,input().split()) a def solve(x,y,s):
    print(a+s-y-1)
    for i in range(1,a):print(1,1+i)
    c = s-b
    for i in range(1,a):
        for I in range(i+1,a):
            if c > 0:
                print(i+1,I+1)
                c-=1
            else:exit()
# print(b,S) def solve(x,y,s):
    print(a+s-y-1)
    for i in range(1,a):print(1,1+i)
    c = s-b
    for i in range(1,a):
        for I in range(i+1,a):
            if c > 0:
                print(i+1,I+1)
                c-=1
            else:exit()
# print(b,S) solve S  = (a-1)*(a-2)//2 (a-1)*(a-2)//2 S b = map(int,input().split()) map(int,input().split()) b
a,b = map(int,input().split())

S  = (a-1)*(a-2)//2
def solve(x,y,s):
    print(a+s-y-1)
    for i in range(1,a):print(1,1+i)
    c = s-b
    for i in range(1,a):
        for I in range(i+1,a):
            if c > 0:
                print(i+1,I+1)
                c-=1
            else:exit()
# print(b,S)
if not 0<= b <= S:
    print(-1)
    exit()
else:
    solve(a,b,S)
