require 'prime'
loop do
  n, p = gets.split.map(&:to_i)
  break if n == -1
  p Prime.each.lazy.drop_while{ |e| e <= n }
         .take(p).to_a
         .repeated_combination(2)
         .map{ |a, b| a + b }.sort[p - 1]
end