def main():
  N, K  = map(int, input().split())
  max_pair = (N-1)*(N-2)//2
  if max_pair < K:
    print(-1)
  else:
    edge = []
    for i in range(N-1):
      edge.append([1, 2+i])
    from_ = 2
    to_ = 3
    for i in range(max_pair-K):
      edge.append([from_, to_])
      to_ += 1
      if to_ > N:
        from_ += 1
        to_ = from_ + 1
    num = len(edge)
    print(num)
    [print(*edge[i]) for i in range(num)]
    
if __name__ == "__main__":
  main()   def main():
  N, K  = map(int, input().split())
  max_pair = (N-1)*(N-2)//2
  if max_pair < K:
    print(-1)
  else:
    edge = []
    for i in range(N-1):
      edge.append([1, 2+i])
    from_ = 2
    to_ = 3
    for i in range(max_pair-K):
      edge.append([from_, to_])
      to_ += 1
      if to_ > N:
        from_ += 1
        to_ = from_ + 1
    num = len(edge)
    print(num)
    [print(*edge[i]) for i in range(num)]
     main N, K  = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split K max_pair = (N-1)*(N-2)//2 max_pair (N-1)*(N-2)//2 (N-1)*(N-2) N-1 N 1 N-2 N 2 2 if max_pair < K:
    print(-1)
  else:
    edge = []
    for i in range(N-1):
      edge.append([1, 2+i])
    from_ = 2
    to_ = 3
    for i in range(max_pair-K):
      edge.append([from_, to_])
      to_ += 1
      if to_ > N:
        from_ += 1
        to_ = from_ + 1
    num = len(edge)
    print(num)
    [print(*edge[i]) for i in range(num)]
     max_pair < K max_pair K print(-1) print -1 edge = [] edge [] for i in range(N-1):
      edge.append([1, 2+i])
     i range(N-1) range N-1 N 1 edge.append([1, 2+i]) edge.append edge append [1, 2+i] 1 2+i 2 i from_ = 2 from_ 2 to_ = 3 to_ 3 for i in range(max_pair-K):
      edge.append([from_, to_])
      to_ += 1
      if to_ > N:
        from_ += 1
        to_ = from_ + 1
     i range(max_pair-K) range max_pair-K max_pair K edge.append([from_, to_]) edge.append edge append [from_, to_] from_ to_ to_ += 1 to_ 1 if to_ > N:
        from_ += 1
        to_ = from_ + 1
     to_ > N to_ N from_ += 1 from_ 1 to_ = from_ + 1 to_ from_ + 1 from_ 1 num = len(edge) num len(edge) len edge print(num) print num print(*edge[i]) for i in range(num) for i in range(num) i range(num) range num for i in range(num) print(*edge[i]) print *edge[i] edge[i] edge i [print(*edge[i]) for i in range(num)] if __name__ == "__main__":
  main()   __name__ == "__main__" __name__ "__main__" main() main def main():
  N, K  = map(int, input().split())
  max_pair = (N-1)*(N-2)//2
  if max_pair < K:
    print(-1)
  else:
    edge = []
    for i in range(N-1):
      edge.append([1, 2+i])
    from_ = 2
    to_ = 3
    for i in range(max_pair-K):
      edge.append([from_, to_])
      to_ += 1
      if to_ > N:
        from_ += 1
        to_ = from_ + 1
    num = len(edge)
    print(num)
    [print(*edge[i]) for i in range(num)]
     def main():
  N, K  = map(int, input().split())
  max_pair = (N-1)*(N-2)//2
  if max_pair < K:
    print(-1)
  else:
    edge = []
    for i in range(N-1):
      edge.append([1, 2+i])
    from_ = 2
    to_ = 3
    for i in range(max_pair-K):
      edge.append([from_, to_])
      to_ += 1
      if to_ > N:
        from_ += 1
        to_ = from_ + 1
    num = len(edge)
    print(num)
    [print(*edge[i]) for i in range(num)]
     main
def main():
  N, K  = map(int, input().split())
  max_pair = (N-1)*(N-2)//2
  if max_pair < K:
    print(-1)
  else:
    edge = []
    for i in range(N-1):
      edge.append([1, 2+i])
    from_ = 2
    to_ = 3
    for i in range(max_pair-K):
      edge.append([from_, to_])
      to_ += 1
      if to_ > N:
        from_ += 1
        to_ = from_ + 1
    num = len(edge)
    print(num)
    [print(*edge[i]) for i in range(num)]
    
if __name__ == "__main__":
  main()  