#editorial参照
#星状グラフに追加するのは連結性や総数の把握が困難
#最大の星状グラフから減らすほうがよい
import sys
n,k = map(int,input().split( ))

cnt = (n-2)*(n-1)//2-k

if cnt<0:
    print(-1)
    sys.exit()
edg_ad = []
for v in range(2,n+1):
    if cnt == 0:
        break
    for u in range(2,v):
        if cnt == 0:
            break
        edg_ad.append((u,v))
        cnt -= 1
ans = []
for v in range(2,n+1):
    ans.append((1,v))
ans2 = set(ans)|set(edg_ad)
ans2 = list(ans2)
ans2.sort()
print(len(ans2))####これ
for e in ans2:
    print(*e)

    
    import sys sys n,k = map(int,input().split( )) n map(int,input().split( )) map int input().split( ) ().split () input split k cnt = (n-2)*(n-1)//2-k cnt (n-2)*(n-1)//2-k (n-2)*(n-1)//2 (n-2)*(n-1) n-2 n 2 n-1 n 1 2 k if cnt<0:
    print(-1)
    sys.exit() cnt<0 cnt 0 print(-1) print -1 sys.exit() sys.exit sys exit edg_ad = [] edg_ad [] for v in range(2,n+1):
    if cnt == 0:
        break
    for u in range(2,v):
        if cnt == 0:
            break
        edg_ad.append((u,v))
        cnt -= 1 v range(2,n+1) range 2 n+1 n 1 if cnt == 0:
        break
     cnt == 0 cnt 0 break for u in range(2,v):
        if cnt == 0:
            break
        edg_ad.append((u,v))
        cnt -= 1 u range(2,v) range 2 v if cnt == 0:
            break
         cnt == 0 cnt 0 break edg_ad.append((u,v)) edg_ad.append edg_ad append (u,v) u v cnt -= 1 cnt 1 ans = [] ans [] for v in range(2,n+1):
    ans.append((1,v)) v range(2,n+1) range 2 n+1 n 1 ans.append((1,v)) ans.append ans append (1,v) 1 v ans2 = set(ans)|set(edg_ad) ans2 set(ans)|set(edg_ad) set(ans) set ans set(edg_ad) set edg_ad ans2 = list(ans2) ans2 list(ans2) list ans2 ans2.sort() ans2.sort ans2 sort print(len(ans2)) print len(ans2) len ans2 for e in ans2:
    print(*e)

    
    e ans2 print(*e) print *e e edg_ad = [] [] edg_ad cnt -= 1 1 cnt k = map(int,input().split( )) map(int,input().split( )) k ans2 = set(ans)|set(edg_ad) set(ans)|set(edg_ad) ans2 cnt = (n-2)*(n-1)//2-k (n-2)*(n-1)//2-k cnt n,k = map(int,input().split( )) map(int,input().split( )) n ans = [] [] ans ans2 = list(ans2) list(ans2) ans2
#editorial参照
#星状グラフに追加するのは連結性や総数の把握が困難
#最大の星状グラフから減らすほうがよい
import sys
n,k = map(int,input().split( ))

cnt = (n-2)*(n-1)//2-k

if cnt<0:
    print(-1)
    sys.exit()
edg_ad = []
for v in range(2,n+1):
    if cnt == 0:
        break
    for u in range(2,v):
        if cnt == 0:
            break
        edg_ad.append((u,v))
        cnt -= 1
ans = []
for v in range(2,n+1):
    ans.append((1,v))
ans2 = set(ans)|set(edg_ad)
ans2 = list(ans2)
ans2.sort()
print(len(ans2))####これ
for e in ans2:
    print(*e)

    
   