main = getContents >>= putStrLn . fout . treasure_hunt 0 0 (pi/2.0) . map fin . init . lines
fin s = (read $ takeWhile (/= ',') s, read $ tail $ dropWhile (/= ',') s)
fout = unlines . map show

treasure_hunt x y r [] = [x,y]
treasure_hunt x y r ((d,a):das) = treasure_hunt (x+(cos (r+r')*d)) (y+(sin (r+r')*d)) (r+r') das
 where r' = a * pi / (-180.0)