N, K = gets.split.map &:to_i
max = (N - 2) * (N - 1) / 2
if K > max
  p -1
  exit
end

cnt = 0
ans = []
(1...N).each{|i|
  ans << [0, i]
}
(1...N).each{|i|
  break if cnt >= max - K
  (i+1...N).each{|j|
    break if cnt >= max - K
    ans << [i, j]
    cnt += 1
  }
}
p ans.size
ans.each{|from, to|
  puts [from+1, to+1]* " "
}
