N,K = map(int,input().split())
M = (N-1)*(N-2)//2

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

if M >= K:
    print(M-K+N-1)
    for i in range(1,N):
        print(1,1+i)
    tmp = 0
    for i in range(2,N):
        for j in range(i+1,N+1):
            if tmp == M-K:
                break
            print(i,j)
            tmp += 1
else:
    print(-1)