N,K=map(int, input().split())


if K>((N-1)*(N-2)//2):
    print(-1)
    exit()

#最大値　(N-1)(N-2)//2
G=[]
for i in range(2,N+1):
    G.append((1,i))

res=(N-1)*(N-2)//2-K

count=0
flag=False
for i in range(2,N):
    for j in range(i+1,N+1):
        if count<res:
            G.append((i,j))
            count+=1
        if count==res:
            flag=True
            break
    if flag:
        break

print(len(G))
for t in G:
    a,b=t
    print(a,b) N,K=map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split K if K>((N-1)*(N-2)//2):
    print(-1)
    exit()

#最大値　(N-1)(N-2)//2 K>((N-1)*(N-2)//2) K (N-1)*(N-2)//2 (N-1)*(N-2) N-1 N 1 N-2 N 2 2 print(-1) print -1 exit() exit G=[] G [] for i in range(2,N+1):
    G.append((1,i)) i range(2,N+1) range 2 N+1 N 1 G.append((1,i)) G.append G append (1,i) 1 i res=(N-1)*(N-2)//2-K res (N-1)*(N-2)//2-K (N-1)*(N-2)//2 (N-1)*(N-2) N-1 N 1 N-2 N 2 2 K count=0 count 0 flag=False flag False for i in range(2,N):
    for j in range(i+1,N+1):
        if count<res:
            G.append((i,j))
            count+=1
        if count==res:
            flag=True
            break
    if flag:
        break i range(2,N) range 2 N for j in range(i+1,N+1):
        if count<res:
            G.append((i,j))
            count+=1
        if count==res:
            flag=True
            break
     j range(i+1,N+1) range i+1 i 1 N+1 N 1 if count<res:
            G.append((i,j))
            count+=1
         count<res count res G.append((i,j)) G.append G append (i,j) i j count+=1 count 1 if count==res:
            flag=True
            break
     count==res count res flag=True flag True break if flag:
        break flag break print(len(G)) print len(G) len G for t in G:
    a,b=t
    print(a,b) t G a,b=t a t b print(a,b) print a b K=map(int, input().split()) map(int, input().split()) K res=(N-1)*(N-2)//2-K (N-1)*(N-2)//2-K res flag=False False flag count=0 0 count flag=True True flag a,b=t t a b=t t b count+=1 1 count G=[] [] G N,K=map(int, input().split()) map(int, input().split()) N
N,K=map(int, input().split())


if K>((N-1)*(N-2)//2):
    print(-1)
    exit()

#最大値　(N-1)(N-2)//2
G=[]
for i in range(2,N+1):
    G.append((1,i))

res=(N-1)*(N-2)//2-K

count=0
flag=False
for i in range(2,N):
    for j in range(i+1,N+1):
        if count<res:
            G.append((i,j))
            count+=1
        if count==res:
            flag=True
            break
    if flag:
        break

print(len(G))
for t in G:
    a,b=t
    print(a,b)
