n,k=map(int,input().split())
def ans():
  m=n
  if k>((n-1)*(n-2)//2):
    print(-1)
    return
  else:
    c=(n-1)*(n-2)//2-k
    a=[]
    for i in range(2,n+1):
      a.append([1,i])
    if c>0:
      for i in range(2,n+1):
        for j in range(i+1,n+1):
          a.append([i,j])
          c-=1
          if c==0:
            break
        if c==0:
          break
    print(len(a))
    for i in range(len(a)):
      print(a[i][0],a[i][1])
ans() n,k=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split k def ans():
  m=n
  if k>((n-1)*(n-2)//2):
    print(-1)
    return
  else:
    c=(n-1)*(n-2)//2-k
    a=[]
    for i in range(2,n+1):
      a.append([1,i])
    if c>0:
      for i in range(2,n+1):
        for j in range(i+1,n+1):
          a.append([i,j])
          c-=1
          if c==0:
            break
        if c==0:
          break
    print(len(a))
    for i in range(len(a)):
      print(a[i][0],a[i][1]) ans m=n m n if k>((n-1)*(n-2)//2):
    print(-1)
    return
  else:
    c=(n-1)*(n-2)//2-k
    a=[]
    for i in range(2,n+1):
      a.append([1,i])
    if c>0:
      for i in range(2,n+1):
        for j in range(i+1,n+1):
          a.append([i,j])
          c-=1
          if c==0:
            break
        if c==0:
          break
    print(len(a))
    for i in range(len(a)):
      print(a[i][0],a[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 return c=(n-1)*(n-2)//2-k c (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 a=[] a [] for i in range(2,n+1):
      a.append([1,i])
     i range(2,n+1) range 2 n+1 n 1 a.append([1,i]) a.append a append [1,i] 1 i if c>0:
      for i in range(2,n+1):
        for j in range(i+1,n+1):
          a.append([i,j])
          c-=1
          if c==0:
            break
        if c==0:
          break
     c>0 c 0 for i in range(2,n+1):
        for j in range(i+1,n+1):
          a.append([i,j])
          c-=1
          if c==0:
            break
        if c==0:
          break
     i range(2,n+1) range 2 n+1 n 1 for j in range(i+1,n+1):
          a.append([i,j])
          c-=1
          if c==0:
            break
         j range(i+1,n+1) range i+1 i 1 n+1 n 1 a.append([i,j]) a.append a append [i,j] i j c-=1 c 1 if c==0:
            break
         c==0 c 0 break if c==0:
          break
     c==0 c 0 break print(len(a)) print len(a) len a for i in range(len(a)):
      print(a[i][0],a[i][1]) i range(len(a)) range len(a) len a print(a[i][0],a[i][1]) print a[i][0] [i] a i 0 a[i][1] [i] a i 1 ans() ans k=map(int,input().split()) map(int,input().split()) k n,k=map(int,input().split()) map(int,input().split()) n def ans():
  m=n
  if k>((n-1)*(n-2)//2):
    print(-1)
    return
  else:
    c=(n-1)*(n-2)//2-k
    a=[]
    for i in range(2,n+1):
      a.append([1,i])
    if c>0:
      for i in range(2,n+1):
        for j in range(i+1,n+1):
          a.append([i,j])
          c-=1
          if c==0:
            break
        if c==0:
          break
    print(len(a))
    for i in range(len(a)):
      print(a[i][0],a[i][1]) def ans():
  m=n
  if k>((n-1)*(n-2)//2):
    print(-1)
    return
  else:
    c=(n-1)*(n-2)//2-k
    a=[]
    for i in range(2,n+1):
      a.append([1,i])
    if c>0:
      for i in range(2,n+1):
        for j in range(i+1,n+1):
          a.append([i,j])
          c-=1
          if c==0:
            break
        if c==0:
          break
    print(len(a))
    for i in range(len(a)):
      print(a[i][0],a[i][1]) ans
n,k=map(int,input().split())
def ans():
  m=n
  if k>((n-1)*(n-2)//2):
    print(-1)
    return
  else:
    c=(n-1)*(n-2)//2-k
    a=[]
    for i in range(2,n+1):
      a.append([1,i])
    if c>0:
      for i in range(2,n+1):
        for j in range(i+1,n+1):
          a.append([i,j])
          c-=1
          if c==0:
            break
        if c==0:
          break
    print(len(a))
    for i in range(len(a)):
      print(a[i][0],a[i][1])
ans()