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

maxi = (n-1)*(n-2)/2
if k > maxi:
    print(-1)
    exit()

nokori = int(maxi - k)
print(nokori + n-1)
for i in range(1, n):
    print(i, n)

for i in range(1, n):
    if nokori == 0: break
    for j in range(i+1, n):
        print(i, j)
        nokori -= 1
        if nokori == 0: break n, k = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split k maxi = (n-1)*(n-2)/2 maxi (n-1)*(n-2)/2 (n-1)*(n-2) n-1 n 1 n-2 n 2 2 if k > maxi:
    print(-1)
    exit() k > maxi k maxi print(-1) print -1 exit() exit nokori = int(maxi - k) nokori int(maxi - k) int maxi - k maxi k print(nokori + n-1) print nokori + n-1 nokori + n nokori n 1 for i in range(1, n):
    print(i, n) i range(1, n) range 1 n print(i, n) print i n for i in range(1, n):
    if nokori == 0: break
    for j in range(i+1, n):
        print(i, j)
        nokori -= 1
        if nokori == 0: break i range(1, n) range 1 n if nokori == 0: break
     nokori == 0 nokori 0 for j in range(i+1, n):
        print(i, j)
        nokori -= 1
        if nokori == 0: break j range(i+1, n) range i+1 i 1 n print(i, j) print i j nokori -= 1 nokori 1 if nokori == 0: break nokori == 0 nokori 0 nokori -= 1 1 nokori n, k = map(int, input().split()) map(int, input().split()) n maxi = (n-1)*(n-2)/2 (n-1)*(n-2)/2 maxi nokori = int(maxi - k) int(maxi - k) nokori k = map(int, input().split()) map(int, input().split()) k
n, k = map(int, input().split())

maxi = (n-1)*(n-2)/2
if k > maxi:
    print(-1)
    exit()

nokori = int(maxi - k)
print(nokori + n-1)
for i in range(1, n):
    print(i, n)

for i in range(1, n):
    if nokori == 0: break
    for j in range(i+1, n):
        print(i, j)
        nokori -= 1
        if nokori == 0: break