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

readInt = read :: String -> Int
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
cond t f c = if c then t else f
-- end of templete

f :: (Floating f, RealFrac f) => (f, f, Int) -> [[Int]] -> [Int]
f (x, y, _) [] = map truncate [x, y]
f (x, y, t) ([d, a]:s) = f (x + d' * cos theta, y + d' * sin theta, mod (t - a) 360) s
  where
    d' = fromIntegral d
    theta = (fromIntegral t) * pi / 180

main = do
  takeWhile (any (/=0)) . map (map readInt . wordsBy (==',')) . lines <$> getContents >>= mapM print . f (0, 0, 90)