import Control.Applicative
import Control.Monad
import Data.List.Split

main :: IO ()
main = do
  ls <- init . lines <$> getContents
  print $ scanl f ((0,0),0) ls
  mapM_ (print . truncate) $ (\(x,y) -> [x,y]) $ fst $ foldl f ((0,0), 0) ls
  where
    f :: ((Double, Double), Double) -> String -> ((Double, Double), Double)
    f ((x,y), ang) l = let
        [d, a] = map read $ splitOn "," l
        ang' = ang/180*pi
      in ((x+d*sin ang', y+d*cos ang'), ang+a)