N, K = gets.split.map(&:to_i)

path_cnt = (1..(N - 2)).inject(:+) || 0

if path_cnt < K
  puts -1
  exit
end

edges = []

2.upto(N) do |v|
  edges << [1, v]
end

from = 2
to = 3

while path_cnt > K
  edges << [from, to]

  to += 1

  if to > N
    from += 1
    to = from + 1
  end

  path_cnt -= 1
end

puts edges.size
edges.each do |u, v|
  puts [u, v].join(' ')
end
