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

if K > (N-1)*(N-2)//2:
    print(-1)
else:
    L = []
    for i in range(N-1):
        L.append(["1", str(i+2)])
    k = (N-1)*(N-2)//2 - K
    i = 2
    j = 3
    while k > 0:
        L.append([str(i), str(j)])
        j += 1
        if j == N+1:
            i += 1
            j = i+1
        k -= 1
        
    print(len(L))
    for i in range(len(L)):
        print(" ".join(L[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:
    L = []
    for i in range(N-1):
        L.append(["1", str(i+2)])
    k = (N-1)*(N-2)//2 - K
    i = 2
    j = 3
    while k > 0:
        L.append([str(i), str(j)])
        j += 1
        if j == N+1:
            i += 1
            j = i+1
        k -= 1
        
    print(len(L))
    for i in range(len(L)):
        print(" ".join(L[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 L = [] L [] for i in range(N-1):
        L.append(["1", str(i+2)])
     i range(N-1) range N-1 N 1 L.append(["1", str(i+2)]) L.append L append ["1", str(i+2)] "1" str(i+2) str i+2 i 2 k = (N-1)*(N-2)//2 - K 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 K i = 2 i 2 j = 3 j 3 while k > 0:
        L.append([str(i), str(j)])
        j += 1
        if j == N+1:
            i += 1
            j = i+1
        k -= 1
        
     k > 0 k 0 L.append([str(i), str(j)]) L.append L append [str(i), str(j)] str(i) str i str(j) str j j += 1 j 1 if j == N+1:
            i += 1
            j = i+1
         j == N+1 j N+1 N 1 i += 1 i 1 j = i+1 j i+1 i 1 k -= 1 k 1 print(len(L)) print len(L) len L for i in range(len(L)):
        print(" ".join(L[i])) i range(len(L)) range len(L) len L print(" ".join(L[i])) print " ".join(L[i]) " ".join " " join L[i] L i j += 1 1 j K = map(int, input().split()) map(int, input().split()) K L = [] [] L j = 3 3 j i += 1 1 i k = (N-1)*(N-2)//2 - K (N-1)*(N-2)//2 - K k j = i+1 i+1 j N,K = map(int, input().split()) map(int, input().split()) N i = 2 2 i k -= 1 1 k
N,K = map(int, input().split())

if K > (N-1)*(N-2)//2:
    print(-1)
else:
    L = []
    for i in range(N-1):
        L.append(["1", str(i+2)])
    k = (N-1)*(N-2)//2 - K
    i = 2
    j = 3
    while k > 0:
        L.append([str(i), str(j)])
        j += 1
        if j == N+1:
            i += 1
            j = i+1
        k -= 1
        
    print(len(L))
    for i in range(len(L)):
        print(" ".join(L[i]))