def lscan;gets.split.map(&:to_i);end

n, k = lscan

if n >= k
  edges = []
  (1..n).to_a.combination(2) do |u, v|
    if v - u == 1
      k -= 1
      next if k >= 0
    end
    edges << [u, v]
  end
  p edges.size
  puts edges.map{|e| e*' '}
  exit 0
end

kei = n - 2
(1..n).each do |i|
  kei += i
  if kei > k
    p -1
    exit 0
  end
  if kei == k
    edges = []
    v = 1
    u = 2
    (i + 1).times do |i|
      edges << [v, u]
      u += 1
    end
    while u <= n
      edges << [v, u]
      v, u = u, u + 1
    end
    p edges.size
    puts edges.map{|e| e*' '}
    exit 0
  end
end