import Data.List

main :: IO ()
main = do
  input <- parse <$> readFile "input"
  print $ product $ map race input
  print $ race (p2ify input)

parse :: String -> [[Int]]
parse = transpose . map (map read . tail . words) . lines

p2ify :: [[Int]] -> [Int]
p2ify = map (read . concatMap show) . transpose

race :: [Int] -> Int
race [x,y] = length $ filter (>y) $ zipWith (*) [0..x] [x, pred x..]
