T = [[60, 80, 100, 120, 140, 160], [2, 5, 10, 15, 20, 25], [600, 800, 1000, 1200, 1400, 1600]].transpose.freeze
loop do
  n = gets.to_i
  break if n.zero?
  p n.times.map {
    x, y, h, w = gets.split.map(&:to_i)
    q = T.find {|a, b, _| x + y + h <= a && w <= b }
    q ? q[2] : 0
  }.inject 0, :+
end