N,K = map(int,input().split())
if N*(N-1)//2-(N-1) - K < 0:
    print(-1)
    exit()
M = N-1 + N*(N-1)//2-(N-1) - K
print(M)
for i in range(2,N+1):
    print(1,i)


r = N*(N-1)//2-(N-1) - K
for i in range(2,N+1):
    for j in range(i+1,N+1):
        if r == 0:
            exit()
        if r > 0:
            print(i,j)
            r -= 1 N,K = map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split K if N*(N-1)//2-(N-1) - K < 0:
    print(-1)
    exit() N*(N-1)//2-(N-1) - K < 0 N*(N-1)//2-(N-1) - K N*(N-1)//2-(N-1) N*(N-1)//2 N*(N-1) N N-1 N 1 2 N-1 N 1 K 0 print(-1) print -1 exit() exit M = N-1 + N*(N-1)//2-(N-1) - K M N-1 + N*(N-1)//2-(N-1) - K N-1 + N*(N-1)//2-(N-1) N-1 + N*(N-1)//2 N-1 N 1 N*(N-1)//2 N*(N-1) N N-1 N 1 2 N-1 N 1 K print(M) print M for i in range(2,N+1):
    print(1,i) i range(2,N+1) range 2 N+1 N 1 print(1,i) print 1 i r = N*(N-1)//2-(N-1) - K r N*(N-1)//2-(N-1) - K N*(N-1)//2-(N-1) N*(N-1)//2 N*(N-1) N N-1 N 1 2 N-1 N 1 K for i in range(2,N+1):
    for j in range(i+1,N+1):
        if r == 0:
            exit()
        if r > 0:
            print(i,j)
            r -= 1 i range(2,N+1) range 2 N+1 N 1 for j in range(i+1,N+1):
        if r == 0:
            exit()
        if r > 0:
            print(i,j)
            r -= 1 j range(i+1,N+1) range i+1 i 1 N+1 N 1 if r == 0:
            exit()
         r == 0 r 0 exit() exit if r > 0:
            print(i,j)
            r -= 1 r > 0 r 0 print(i,j) print i j r -= 1 r 1 r = N*(N-1)//2-(N-1) - K N*(N-1)//2-(N-1) - K r N,K = map(int,input().split()) map(int,input().split()) N r -= 1 1 r M = N-1 + N*(N-1)//2-(N-1) - K N-1 + N*(N-1)//2-(N-1) - K M K = map(int,input().split()) map(int,input().split()) K
N,K = map(int,input().split())
if N*(N-1)//2-(N-1) - K < 0:
    print(-1)
    exit()
M = N-1 + N*(N-1)//2-(N-1) - K
print(M)
for i in range(2,N+1):
    print(1,i)


r = N*(N-1)//2-(N-1) - K
for i in range(2,N+1):
    for j in range(i+1,N+1):
        if r == 0:
            exit()
        if r > 0:
            print(i,j)
            r -= 1