N, K = map(int,input().split())
if K>((N-1)*(N-2))//2:
    print(-1)
else:
    ans = []
    for i in range(N-1):
        ans.append([1,i+2])
    if N!=2:
        k = 2
        l = 2
        for i in range(((N-1)*(N-2))//2-K):
            if l==N:
                k+=1
                l=k+1
            else:
                l+=1
            ans.append([k,l])
    print(len(ans))
    for i in ans:
        print(*i) N, K = map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split K if K>((N-1)*(N-2))//2:
    print(-1)
else:
    ans = []
    for i in range(N-1):
        ans.append([1,i+2])
    if N!=2:
        k = 2
        l = 2
        for i in range(((N-1)*(N-2))//2-K):
            if l==N:
                k+=1
                l=k+1
            else:
                l+=1
            ans.append([k,l])
    print(len(ans))
    for i in ans:
        print(*i) 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 ans = [] ans [] for i in range(N-1):
        ans.append([1,i+2])
     i range(N-1) range N-1 N 1 ans.append([1,i+2]) ans.append ans append [1,i+2] 1 i+2 i 2 if N!=2:
        k = 2
        l = 2
        for i in range(((N-1)*(N-2))//2-K):
            if l==N:
                k+=1
                l=k+1
            else:
                l+=1
            ans.append([k,l])
     N!=2 N 2 k = 2 k 2 l = 2 l 2 for i in range(((N-1)*(N-2))//2-K):
            if l==N:
                k+=1
                l=k+1
            else:
                l+=1
            ans.append([k,l])
     i range(((N-1)*(N-2))//2-K) range ((N-1)*(N-2))//2-K ((N-1)*(N-2))//2 (N-1)*(N-2) N-1 N 1 N-2 N 2 2 K if l==N:
                k+=1
                l=k+1
            else:
                l+=1
             l==N l N k+=1 k 1 l=k+1 l k+1 k 1 l+=1 l 1 ans.append([k,l]) ans.append ans append [k,l] k l print(len(ans)) print len(ans) len ans for i in ans:
        print(*i) i ans print(*i) print *i i K = map(int,input().split()) map(int,input().split()) K N, K = map(int,input().split()) map(int,input().split()) N k = 2 2 k ans = [] [] ans l = 2 2 l l=k+1 k+1 l l+=1 1 l k+=1 1 k
N, K = map(int,input().split())
if K>((N-1)*(N-2))//2:
    print(-1)
else:
    ans = []
    for i in range(N-1):
        ans.append([1,i+2])
    if N!=2:
        k = 2
        l = 2
        for i in range(((N-1)*(N-2))//2-K):
            if l==N:
                k+=1
                l=k+1
            else:
                l+=1
            ans.append([k,l])
    print(len(ans))
    for i in ans:
        print(*i)