n,k = map(int, input().split())
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)
def comb(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res
cm = comb(n-1,2)

if n==2 and k>=1:
    print(-1)
    exit()

if cm < k:
    print(-1)
    exit()

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

from itertools import *
cnt=0
for e in combinations(range(2,n+1),2):
    if cnt== cm-k:
        break
    cnt+=1
    ans.append([e[0],e[1]])

print(len(ans))
for a in ans:
    print(*a) n,k = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split k def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod) modinv return pow(a, mod-2, mod) pow(a, mod-2, mod) pow a mod-2 mod 2 mod a a mod=10**9+7 mod 10**9+7 10**9 10 9 7 def comb(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res comb r = min(r, n-r) r min(r, n-r) min r n-r n r res = 1 res 1 for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
     i range(r) range r res = res * (n - i) * modinv(i+1, mod) % mod res res * (n - i) * modinv(i+1, mod) % mod res * (n - i) * modinv(i+1, mod) res * (n - i) res n - i n i modinv(i+1, mod) modinv i+1 i 1 mod mod return res res n n r r mod=10**9+7 mod 10**9+7 10**9 10 9 7 cm = comb(n-1,2) cm comb(n-1,2) comb n-1 n 1 2 if n==2 and k>=1:
    print(-1)
    exit() n==2 and k>=1 n==2 n 2 k>=1 k 1 print(-1) print -1 exit() exit if cm < k:
    print(-1)
    exit() cm < k cm k print(-1) print -1 exit() exit ans=[] ans [] for i in range(1,n):
    ans.append([1,i+1]) i range(1,n) range 1 n ans.append([1,i+1]) ans.append ans append [1,i+1] 1 i+1 i 1 from itertools import * cnt=0 cnt 0 for e in combinations(range(2,n+1),2):
    if cnt== cm-k:
        break
    cnt+=1
    ans.append([e[0],e[1]]) e combinations(range(2,n+1),2) combinations range(2,n+1) range 2 n+1 n 1 2 if cnt== cm-k:
        break
     cnt== cm-k cnt cm-k cm k break cnt+=1 cnt 1 ans.append([e[0],e[1]]) ans.append ans append [e[0],e[1]] e[0] e 0 e[1] e 1 print(len(ans)) print len(ans) len ans for a in ans:
    print(*a) a ans print(*a) print *a a k = map(int, input().split()) map(int, input().split()) k cm = comb(n-1,2) comb(n-1,2) cm cnt=0 0 cnt ans=[] [] ans n,k = map(int, input().split()) map(int, input().split()) n def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod) def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod) modinv cnt+=1 1 cnt def comb(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res def comb(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res comb
n,k = map(int, input().split())
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)
def comb(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res
cm = comb(n-1,2)

if n==2 and k>=1:
    print(-1)
    exit()

if cm < k:
    print(-1)
    exit()

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

from itertools import *
cnt=0
for e in combinations(range(2,n+1),2):
    if cnt== cm-k:
        break
    cnt+=1
    ans.append([e[0],e[1]])

print(len(ans))
for a in ans:
    print(*a)