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