n,k=map(int,input().split())
m=(n-1)*(n-2)//2
if k>m:
    print(-1)
else:
    l=m-k
    lst=[]
    for i in range(1,n):
        lst.append([i,n])
    for i in range(1,n):
        for j in range(i+1,n):
            if l==0:
                break
            lst.append([i, j])
            l-=1
        else:
            continue
        break
    print(len(lst))
    for a,b in lst:
        print(a,b) n,k=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split k m=(n-1)*(n-2)//2 m (n-1)*(n-2)//2 (n-1)*(n-2) n-1 n 1 n-2 n 2 2 if k>m:
    print(-1)
else:
    l=m-k
    lst=[]
    for i in range(1,n):
        lst.append([i,n])
    for i in range(1,n):
        for j in range(i+1,n):
            if l==0:
                break
            lst.append([i, j])
            l-=1
        else:
            continue
        break
    print(len(lst))
    for a,b in lst:
        print(a,b) k>m k m print(-1) print -1 l=m-k l m-k m k lst=[] lst [] for i in range(1,n):
        lst.append([i,n])
     i range(1,n) range 1 n lst.append([i,n]) lst.append lst append [i,n] i n for i in range(1,n):
        for j in range(i+1,n):
            if l==0:
                break
            lst.append([i, j])
            l-=1
        else:
            continue
        break
     i range(1,n) range 1 n for j in range(i+1,n):
            if l==0:
                break
            lst.append([i, j])
            l-=1
        else:
            continue
         j range(i+1,n) range i+1 i 1 n if l==0:
                break
             l==0 l 0 break lst.append([i, j]) lst.append lst append [i, j] i j l-=1 l 1 continue break print(len(lst)) print len(lst) len lst for a,b in lst:
        print(a,b) a b lst print(a,b) print a b l=m-k m-k l k=map(int,input().split()) map(int,input().split()) k lst=[] [] lst l-=1 1 l n,k=map(int,input().split()) map(int,input().split()) n m=(n-1)*(n-2)//2 (n-1)*(n-2)//2 m
n,k=map(int,input().split())
m=(n-1)*(n-2)//2
if k>m:
    print(-1)
else:
    l=m-k
    lst=[]
    for i in range(1,n):
        lst.append([i,n])
    for i in range(1,n):
        for j in range(i+1,n):
            if l==0:
                break
            lst.append([i, j])
            l-=1
        else:
            continue
        break
    print(len(lst))
    for a,b in lst:
        print(a,b)