#!/usr/bin/ruby

def measurePoints(r, t)
  (r / 100) + (t / 30) * 5
end

def nearTR(tr,tr_flag)
  a = Array.new
  if tr_flag == 't'
    devide = 30
  elsif tr_flag == 'r'
    devide = 100
  else
    raise "unexpected flag"
  end

  if (tr % devide) == 0
    a << tr
  else
    sh = tr / devide * devide
    a << sh
    a << sh + devide
  end
  a
end

n = STDIN.gets.chomp.to_i

n.times do
  r, t = STDIN.gets.chomp.split(/\s+/).map(&:to_i)

  rP = nearTR(r,'r')
  tP = nearTR(t,'t')

  ans = Array.new
  rP.each do |rp|
    tP.each do |tp|
      ans << measurePoints(rp,tp)
    end
  end

  puts ans.sort.join(" ")
end