import Control.Applicative
import Control.Monad

f [x, y, h, w]
  | x<=60 && w<=2 = 600
  | x<=80 && w<=5 = 800
  | x<=100 && w<=10 = 1000
  | x<=120 && w<=15 = 1200
  | x<=140 && w<=20 = 1400
  | x<=160 && w<=25 = 1600
  | otherwise = 0
  where
    l = x + y + h

main = do
    n <- readLn
    when (n/=0) $ do
        sum . map (f . map read . words) <$> replicateM n getLine >>= print
        main

