n,k=map(int,input().split())
if k>(n-1)*(n-2)//2:print(-1);exit()
e=[]
for i in range(1,n):e.append((0,i))
ee=[]
for i in range(1,n-1):
  for j in range(i+1,n):
    ee.append((i,j))
for i in range((n-1)*(n-2)//2-k):
  e.append(ee[i])
print(len(e))
for i,j in e:print(i+1,j+1) 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() 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 e=[] e [] for i in range(1,n):e.append((0,i)) i range(1,n) range 1 n ee=[] ee [] for i in range(1,n-1):
  for j in range(i+1,n):
    ee.append((i,j)) i range(1,n-1) range 1 n-1 n 1 for j in range(i+1,n):
    ee.append((i,j)) j range(i+1,n) range i+1 i 1 n ee.append((i,j)) ee.append ee append (i,j) i j for i in range((n-1)*(n-2)//2-k):
  e.append(ee[i]) i range((n-1)*(n-2)//2-k) range (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 e.append(ee[i]) e.append e append ee[i] ee i print(len(e)) print len(e) len e for i,j in e:print(i+1,j+1) i j e k=map(int,input().split()) map(int,input().split()) k ee=[] [] ee e=[] [] e 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()
e=[]
for i in range(1,n):e.append((0,i))
ee=[]
for i in range(1,n-1):
  for j in range(i+1,n):
    ee.append((i,j))
for i in range((n-1)*(n-2)//2-k):
  e.append(ee[i])
print(len(e))
for i,j in e:print(i+1,j+1)