main = getContents >>= print . vmax . map (map read . words) . tail . lines vmax = uncurry max . foldr (\[i,j,s] (a,d) -> if i