n, k = map(int, input().split())

mx = int((n - 1) * (n - 2) / 2)
if mx < k:
    print(-1)
    exit()

ans = []
for i in range(n - 1):
    ans.append([i + 1, n])

edge = []
add = int(mx - k)
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 range(len(ans)):
    print(ans[i][0], ans[i][1]) n, k = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split k mx = int((n - 1) * (n - 2) / 2) mx int((n - 1) * (n - 2) / 2) int (n - 1) * (n - 2) / 2 (n - 1) * (n - 2) n - 1 n 1 n - 2 n 2 2 if mx < k:
    print(-1)
    exit() mx < k mx k print(-1) print -1 exit() exit 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 edge = [] edge [] add = int(mx - k) add int(mx - k) int mx - k mx k 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 range(len(ans)):
    print(ans[i][0], ans[i][1]) i range(len(ans)) range len(ans) len ans print(ans[i][0], ans[i][1]) print ans[i][0] [i] ans i 0 ans[i][1] [i] ans i 1 add = int(mx - k) int(mx - k) add ans = [] [] ans n, k = map(int, input().split()) map(int, input().split()) n k = map(int, input().split()) map(int, input().split()) k mx = int((n - 1) * (n - 2) / 2) int((n - 1) * (n - 2) / 2) mx edge = [] [] edge
n, k = map(int, input().split())

mx = int((n - 1) * (n - 2) / 2)
if mx < k:
    print(-1)
    exit()

ans = []
for i in range(n - 1):
    ans.append([i + 1, n])

edge = []
add = int(mx - k)
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 range(len(ans)):
    print(ans[i][0], ans[i][1])
