n, k = map(int, input().split())
maxim = (n-2) * (n-1) // 2
if k > maxim:
    print(-1)
    exit()

edges = [[x for x in range(n) if x > i] for i in range(n)]
count = 0
node = n-1
while count != k:
    if len(edges[node]) == 0:
        node -= 1
    edges[node].pop()
    count += 1

m = n * (n-1) // 2 - k
print(m)
for _from in range(n-1):
    for to in edges[_from]:
        print(_from+1, to+1) n, k = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split k maxim = (n-2) * (n-1) // 2 maxim (n-2) * (n-1) // 2 (n-2) * (n-1) n-2 n 2 n-1 n 1 2 if k > maxim:
    print(-1)
    exit() k > maxim k maxim print(-1) print -1 exit() exit [x for x in range(n) if x > i] for i in range(n) for i in range(n) i range(n) range n for i in range(n) [x for x in range(n) if x > i] edges = [[x for x in range(n) if x > i] for i in range(n)] edges [[x for x in range(n) if x > i] for i in range(n)] count = 0 count 0 node = n-1 node n-1 n 1 while count != k:
    if len(edges[node]) == 0:
        node -= 1
    edges[node].pop()
    count += 1 count != k count k if len(edges[node]) == 0:
        node -= 1
     len(edges[node]) == 0 len(edges[node]) len edges[node] edges node 0 node -= 1 node 1 edges[node].pop() [node].pop [node] edges node pop count += 1 count 1 m = n * (n-1) // 2 - k m n * (n-1) // 2 - k n * (n-1) // 2 n * (n-1) n n-1 n 1 2 k print(m) print m for _from in range(n-1):
    for to in edges[_from]:
        print(_from+1, to+1) _from range(n-1) range n-1 n 1 for to in edges[_from]:
        print(_from+1, to+1) to edges[_from] edges _from print(_from+1, to+1) print _from+1 _from 1 to+1 to 1 k = map(int, input().split()) map(int, input().split()) k maxim = (n-2) * (n-1) // 2 (n-2) * (n-1) // 2 maxim n, k = map(int, input().split()) map(int, input().split()) n count += 1 1 count count = 0 0 count edges = [[x for x in range(n) if x > i] for i in range(n)] [[x for x in range(n) if x > i] for i in range(n)] edges m = n * (n-1) // 2 - k n * (n-1) // 2 - k m node = n-1 n-1 node node -= 1 1 node
n, k = map(int, input().split())
maxim = (n-2) * (n-1) // 2
if k > maxim:
    print(-1)
    exit()

edges = [[x for x in range(n) if x > i] for i in range(n)]
count = 0
node = n-1
while count != k:
    if len(edges[node]) == 0:
        node -= 1
    edges[node].pop()
    count += 1

m = n * (n-1) // 2 - k
print(m)
for _from in range(n-1):
    for to in edges[_from]:
        print(_from+1, to+1)