{-# LANGUAGE OverloadedStrings #-}
import qualified Data.Text as T
import qualified Data.Text.IO as T
import Control.Applicative

data Point = Point Double Double Double deriving Eq

textToDouble :: T.Text -> Double
textToDouble t = (read . T.unpack) t :: Double

degToRad :: Double -> Double
degToRad d = d * pi / 180

advance :: (Double, Double) -> Point -> Point
advance (a, b) (Point x y t) =
    (Point (x + a * sin (degToRad t)) (y + a * cos (degToRad t)) (t + b))

main :: IO ()
main = do
    args <- reverse . map (\[a, b] -> (a, b)) . map (map textToDouble) . map (T.splitOn ",") . T.lines <$> T.getContents
    putStr $ unlines $ map show $ map round $ (\(Point x y _) -> [x, y]) $ foldr advance (Point 0 0 0) args