type Point = (Double, Double)
type Direction = Int
type Distance = Int

main = do
    ((x,y),_) <- steps ((0.0, 0.0), 90)
    print (truncate x)
    print (truncate y)

steps :: (Point, Direction) -> IO (Point, Direction)
steps (p,ct) = do
    (d,t) <- input
    if d == 0 && t == 0
        then return (p,ct)
        else steps $ update (p,ct) (d,t)

input :: IO (Distance, Direction)
input = do
    line <- getLine
    return (split line)
    where
    split line = (read d, read t)
        where
        (d, _:t) = break (==',') line

update :: (Point, Direction) -> (Distance, Direction) -> (Point, Direction)
update ((x,y),ct) (d,t) = ((x',y'), ct')
    where
    x' = x + (fromIntegral d) * (cos ((fromIntegral ct) * pi / 180.0))
    y' = y + (fromIntegral d) * (sin ((fromIntegral ct) * pi / 180.0))
    ct' = ct - t