# ABC 131 E

N,K=map(int,input().split())

M=(N-1)*(N-2)//2
if K<=M:
    # OK
    print(N-1+M-K)
    for i in range(1,N):
        print(i,N)
    i,j=1,2
    for _ in range(M-K):
        print(i,j)
        j+=1
        if j==N:
            i+=1
            j=i+1
else:
    # NG
    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 K<=M:
    # OK
    print(N-1+M-K)
    for i in range(1,N):
        print(i,N)
    i,j=1,2
    for _ in range(M-K):
        print(i,j)
        j+=1
        if j==N:
            i+=1
            j=i+1
else:
    # NG
    print(-1) K<=M K M print(N-1+M-K) print N-1+M-K N-1+M N-1 N 1 M K for i in range(1,N):
        print(i,N)
     i range(1,N) range 1 N print(i,N) print i N i,j=1,2 i 1 j 2 for _ in range(M-K):
        print(i,j)
        j+=1
        if j==N:
            i+=1
            j=i+1 _ range(M-K) range M-K M K print(i,j) print i j j+=1 j 1 if j==N:
            i+=1
            j=i+1 j==N j N i+=1 i 1 j=i+1 j i+1 i 1 print(-1) print -1 N,K=map(int,input().split()) map(int,input().split()) N i+=1 1 i j=i+1 i+1 j i,j=1,2 1 i M=(N-1)*(N-2)//2 (N-1)*(N-2)//2 M j=1,2 2 j j+=1 1 j K=map(int,input().split()) map(int,input().split()) K
# ABC 131 E

N,K=map(int,input().split())

M=(N-1)*(N-2)//2
if K<=M:
    # OK
    print(N-1+M-K)
    for i in range(1,N):
        print(i,N)
    i,j=1,2
    for _ in range(M-K):
        print(i,j)
        j+=1
        if j==N:
            i+=1
            j=i+1
else:
    # NG
    print(-1)