n,k=map(int,input().split())
if k>(n-1)*(n-2)//2:
  print(-1)
else:
  count=0
  now=2
  ans=[]
  for i in range(2,n+1):
    ans.append([1,i])
  now1=2
  while count<(n-1)*(n-2)//2-k:
    count+=1
    now1+=1
    if now1==n+1:
      now+=1
      now1=now+1
    ans.append([now,now1])
  print(len(ans))
  for i in ans:
    print(i[0],i[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)
else:
  count=0
  now=2
  ans=[]
  for i in range(2,n+1):
    ans.append([1,i])
  now1=2
  while count<(n-1)*(n-2)//2-k:
    count+=1
    now1+=1
    if now1==n+1:
      now+=1
      now1=now+1
    ans.append([now,now1])
  print(len(ans))
  for i in ans:
    print(i[0],i[1]) 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 count=0 count 0 now=2 now 2 ans=[] ans [] for i in range(2,n+1):
    ans.append([1,i])
   i range(2,n+1) range 2 n+1 n 1 ans.append([1,i]) ans.append ans append [1,i] 1 i now1=2 now1 2 while count<(n-1)*(n-2)//2-k:
    count+=1
    now1+=1
    if now1==n+1:
      now+=1
      now1=now+1
    ans.append([now,now1])
   count<(n-1)*(n-2)//2-k count (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+=1 count 1 now1+=1 now1 1 if now1==n+1:
      now+=1
      now1=now+1
     now1==n+1 now1 n+1 n 1 now+=1 now 1 now1=now+1 now1 now+1 now 1 ans.append([now,now1]) ans.append ans append [now,now1] now now1 print(len(ans)) print len(ans) len ans for i in ans:
    print(i[0],i[1]) i ans print(i[0],i[1]) print i[0] i 0 i[1] i 1 count+=1 1 count k=map(int,input().split()) map(int,input().split()) k now1=now+1 now+1 now1 ans=[] [] ans now=2 2 now count=0 0 count n,k=map(int,input().split()) map(int,input().split()) n now1+=1 1 now1 now1=2 2 now1 now+=1 1 now
n,k=map(int,input().split())
if k>(n-1)*(n-2)//2:
  print(-1)
else:
  count=0
  now=2
  ans=[]
  for i in range(2,n+1):
    ans.append([1,i])
  now1=2
  while count<(n-1)*(n-2)//2-k:
    count+=1
    now1+=1
    if now1==n+1:
      now+=1
      now1=now+1
    ans.append([now,now1])
  print(len(ans))
  for i in ans:
    print(i[0],i[1])