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([i+1, N])
    add = (N-1)*(N-2)//2 - K
    edge = []
    for i in range(N - 1):
        for j in range(i):
            edge.append([i+1, j+1])
    for i in range(add):
        ans.append(edge[i])
    print(len(ans))
    for i in ans:
        print(i[0], end=' ')
        print(i[1]) 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([i+1, N])
    add = (N-1)*(N-2)//2 - K
    edge = []
    for i in range(N - 1):
        for j in range(i):
            edge.append([i+1, j+1])
    for i in range(add):
        ans.append(edge[i])
    print(len(ans))
    for i in ans:
        print(i[0], end=' ')
        print(i[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 ans = [] ans [] for i in range(N - 1):
        ans.append([i+1, N])
     i range(N - 1) range N - 1 N 1 ans.append([i+1, N]) ans.append ans append [i+1, N] i+1 i 1 N add = (N-1)*(N-2)//2 - K add (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 edge = [] edge [] for i in range(N - 1):
        for j in range(i):
            edge.append([i+1, j+1])
     i range(N - 1) range N - 1 N 1 for j in range(i):
            edge.append([i+1, j+1])
     j range(i) range i edge.append([i+1, j+1]) edge.append edge append [i+1, j+1] i+1 i 1 j+1 j 1 for i in range(add):
        ans.append(edge[i])
     i range(add) range add ans.append(edge[i]) ans.append ans append edge[i] edge i print(len(ans)) print len(ans) len ans for i in ans:
        print(i[0], end=' ')
        print(i[1]) i ans print(i[0], end=' ') print i[0] i 0 end=' ' end ' ' print(i[1]) print i[1] i 1 edge = [] [] edge ans = [] [] ans N, K = map(int, input().split()) map(int, input().split()) N add = (N-1)*(N-2)//2 - K (N-1)*(N-2)//2 - K add K = map(int, input().split()) map(int, input().split()) 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([i+1, N])
    add = (N-1)*(N-2)//2 - K
    edge = []
    for i in range(N - 1):
        for j in range(i):
            edge.append([i+1, j+1])
    for i in range(add):
        ans.append(edge[i])
    print(len(ans))
    for i in ans:
        print(i[0], end=' ')
        print(i[1])