n = gets.to_i
n.times{
    r, t = gets.chomp.split.map(&:to_i)
    type = ([100, 200, 300, 400, 500].include? r) ? 1 : 0
    type += ([0, 30, 60, 90, 120, 150, 180].include? t) ? 2 : 0
    points = []
    case type
    when 3
        points << (t / 30) * 5 + (r / 100)
    when 2
        points << (t / 30) * 5 + (r / 100)
        points << (t / 30) * 5 + (r / 100) + 1
    when 1
        points << (t / 30) * 5 + (r / 100)
        points << (t / 30 + 1) * 5 + (r / 100)
    else
        points << (t / 30) * 5 + (r / 100)
        points << (t / 30) * 5 + (r / 100) + 1
        points << (t / 30 + 1) * 5 + (r / 100)
        points << (t / 30 + 1) * 5 + (r / 100) + 1
    end
    puts points.join(" ")    
}

