n = gets.to_i
n.times do
    r, t = gets.split.map(&:to_i)
    if r % 100 == 0 and t % 30 == 0
        puts (t / 30) * 5 + (r / 100)
    elsif r % 100 > 0 and t % 30 == 0
        puts [(t / 30) * 5 + (r / 100), (t / 30) * 5 + (r / 100) + 1] * ' '
    elsif r % 100 == 0 and t % 30 > 0
        puts [(t / 30) * 5 + (r / 100), (t / 30 + 1) * 5 + (r / 100)] * ' '
    else
        puts [(t / 30) * 5 + (r / 100), (t / 30) * 5 + (r / 100) + 1, (t / 30 + 1) * 5 + (r / 100), (t / 30 + 1) * 5 + (r / 100) + 1] * ' '
    end
end
