N,K = map(int,input().split())
if N==2:
    if K==0:
        print(1)
        print(1,2)
    elif K==1:
        print(-1)
elif N==3:
    if K==0:
        print(3)
        print(1,2)
        print(2,3)
        print(1,3)
    elif K==1:
        print(2)
        print(1,2)
        print(1,3)
    elif K>=2:
        print(-1)
elif N==4:
    if K==0:
        print(6)
        print(1,2)
        print(1,3)
        print(1,4)
        print(2,3)
        print(2,4)
        print(3,4)
    elif K==1:
        print(5)
        print(1,3)
        print(1,4)
        print(2,3)
        print(2,4)
        print(3,4)
    elif K==2:
        print(4)
        print(1,3)
        print(1,4)
        print(2,4)
        print(3,4)
    elif K>=3:
        print(-1)
else:
    if K>((N-1)*(N-2))//2:
        print(-1)
    else:
        A = [(i,j) for i in range(1,N) for j in range(i+1,N+1)]
        i = 2
        j = 3
        cnt = 0
        while cnt<K:
            if (i,j) in A:
                A.remove((i,j))
            j += 1
            if j>N:
                i += 1
                j = i+1
            cnt += 1
        print((N*(N-1))//2-K)
        for a in A:
            print(a[0],a[1]) N,K = map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split K if N==2:
    if K==0:
        print(1)
        print(1,2)
    elif K==1:
        print(-1)
elif N==3:
    if K==0:
        print(3)
        print(1,2)
        print(2,3)
        print(1,3)
    elif K==1:
        print(2)
        print(1,2)
        print(1,3)
    elif K>=2:
        print(-1)
elif N==4:
    if K==0:
        print(6)
        print(1,2)
        print(1,3)
        print(1,4)
        print(2,3)
        print(2,4)
        print(3,4)
    elif K==1:
        print(5)
        print(1,3)
        print(1,4)
        print(2,3)
        print(2,4)
        print(3,4)
    elif K==2:
        print(4)
        print(1,3)
        print(1,4)
        print(2,4)
        print(3,4)
    elif K>=3:
        print(-1)
else:
    if K>((N-1)*(N-2))//2:
        print(-1)
    else:
        A = [(i,j) for i in range(1,N) for j in range(i+1,N+1)]
        i = 2
        j = 3
        cnt = 0
        while cnt<K:
            if (i,j) in A:
                A.remove((i,j))
            j += 1
            if j>N:
                i += 1
                j = i+1
            cnt += 1
        print((N*(N-1))//2-K)
        for a in A:
            print(a[0],a[1]) N==2 N 2 if K==0:
        print(1)
        print(1,2)
    elif K==1:
        print(-1) K==0 K 0 print(1) print 1 print(1,2) print 1 2 elif K==1:
        print(-1) K==1 K 1 print(-1) print -1 elif N==3:
    if K==0:
        print(3)
        print(1,2)
        print(2,3)
        print(1,3)
    elif K==1:
        print(2)
        print(1,2)
        print(1,3)
    elif K>=2:
        print(-1) N==3 N 3 if K==0:
        print(3)
        print(1,2)
        print(2,3)
        print(1,3)
    elif K==1:
        print(2)
        print(1,2)
        print(1,3)
    elif K>=2:
        print(-1) K==0 K 0 print(3) print 3 print(1,2) print 1 2 print(2,3) print 2 3 print(1,3) print 1 3 elif K==1:
        print(2)
        print(1,2)
        print(1,3)
     K==1 K 1 print(2) print 2 print(1,2) print 1 2 print(1,3) print 1 3 elif K>=2:
        print(-1) K>=2 K 2 print(-1) print -1 elif N==4:
    if K==0:
        print(6)
        print(1,2)
        print(1,3)
        print(1,4)
        print(2,3)
        print(2,4)
        print(3,4)
    elif K==1:
        print(5)
        print(1,3)
        print(1,4)
        print(2,3)
        print(2,4)
        print(3,4)
    elif K==2:
        print(4)
        print(1,3)
        print(1,4)
        print(2,4)
        print(3,4)
    elif K>=3:
        print(-1) N==4 N 4 if K==0:
        print(6)
        print(1,2)
        print(1,3)
        print(1,4)
        print(2,3)
        print(2,4)
        print(3,4)
    elif K==1:
        print(5)
        print(1,3)
        print(1,4)
        print(2,3)
        print(2,4)
        print(3,4)
    elif K==2:
        print(4)
        print(1,3)
        print(1,4)
        print(2,4)
        print(3,4)
    elif K>=3:
        print(-1) K==0 K 0 print(6) print 6 print(1,2) print 1 2 print(1,3) print 1 3 print(1,4) print 1 4 print(2,3) print 2 3 print(2,4) print 2 4 print(3,4) print 3 4 elif K==1:
        print(5)
        print(1,3)
        print(1,4)
        print(2,3)
        print(2,4)
        print(3,4)
     K==1 K 1 print(5) print 5 print(1,3) print 1 3 print(1,4) print 1 4 print(2,3) print 2 3 print(2,4) print 2 4 print(3,4) print 3 4 elif K==2:
        print(4)
        print(1,3)
        print(1,4)
        print(2,4)
        print(3,4)
     K==2 K 2 print(4) print 4 print(1,3) print 1 3 print(1,4) print 1 4 print(2,4) print 2 4 print(3,4) print 3 4 elif K>=3:
        print(-1) K>=3 K 3 print(-1) print -1 if K>((N-1)*(N-2))//2:
        print(-1)
    else:
        A = [(i,j) for i in range(1,N) for j in range(i+1,N+1)]
        i = 2
        j = 3
        cnt = 0
        while cnt<K:
            if (i,j) in A:
                A.remove((i,j))
            j += 1
            if j>N:
                i += 1
                j = i+1
            cnt += 1
        print((N*(N-1))//2-K)
        for a in A:
            print(a[0],a[1]) K>((N-1)*(N-2))//2 K ((N-1)*(N-2))//2 (N-1)*(N-2) N-1 N 1 N-2 N 2 2 print(-1) print -1 (i,j) for i in range(1,N) for j in range(i+1,N+1) for i in range(1,N) for j in range(i+1,N+1) i range(1,N) range 1 N for j in range(i+1,N+1) j range(i+1,N+1) range i+1 i 1 N+1 N 1 for j in range(i+1,N+1) (i,j) i j A = [(i,j) for i in range(1,N) for j in range(i+1,N+1)] A [(i,j) for i in range(1,N) for j in range(i+1,N+1)] i = 2 i 2 j = 3 j 3 cnt = 0 cnt 0 while cnt<K:
            if (i,j) in A:
                A.remove((i,j))
            j += 1
            if j>N:
                i += 1
                j = i+1
            cnt += 1
         cnt<K cnt K if (i,j) in A:
                A.remove((i,j))
             (i,j) in A (i,j) i j A A.remove((i,j)) A.remove A remove (i,j) 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 cnt += 1 cnt 1 print((N*(N-1))//2-K) print (N*(N-1))//2-K (N*(N-1))//2 N*(N-1) N N-1 N 1 2 K for a in A:
            print(a[0],a[1]) a A print(a[0],a[1]) print a[0] a 0 a[1] a 1 j = 3 3 j N,K = map(int,input().split()) map(int,input().split()) N A = [(i,j) for i in range(1,N) for j in range(i+1,N+1)] [(i,j) for i in range(1,N) for j in range(i+1,N+1)] A K = map(int,input().split()) map(int,input().split()) K i += 1 1 i j = i+1 i+1 j cnt += 1 1 cnt cnt = 0 0 cnt i = 2 2 i j += 1 1 j
N,K = map(int,input().split())
if N==2:
    if K==0:
        print(1)
        print(1,2)
    elif K==1:
        print(-1)
elif N==3:
    if K==0:
        print(3)
        print(1,2)
        print(2,3)
        print(1,3)
    elif K==1:
        print(2)
        print(1,2)
        print(1,3)
    elif K>=2:
        print(-1)
elif N==4:
    if K==0:
        print(6)
        print(1,2)
        print(1,3)
        print(1,4)
        print(2,3)
        print(2,4)
        print(3,4)
    elif K==1:
        print(5)
        print(1,3)
        print(1,4)
        print(2,3)
        print(2,4)
        print(3,4)
    elif K==2:
        print(4)
        print(1,3)
        print(1,4)
        print(2,4)
        print(3,4)
    elif K>=3:
        print(-1)
else:
    if K>((N-1)*(N-2))//2:
        print(-1)
    else:
        A = [(i,j) for i in range(1,N) for j in range(i+1,N+1)]
        i = 2
        j = 3
        cnt = 0
        while cnt<K:
            if (i,j) in A:
                A.remove((i,j))
            j += 1
            if j>N:
                i += 1
                j = i+1
            cnt += 1
        print((N*(N-1))//2-K)
        for a in A:
            print(a[0],a[1])