import scala.io.StdIn.readLine

object Main extends App {
  def read(e:Double,n:Double,angle:Double):(Double,Double) = {
    val Array(x,y) = readLine.split(",").map(_.toDouble)
    if(x==0 && y==0) (e,n)
    else read(e+x*Math.cos(Math.toRadians(angle)),n+x*Math.sin(Math.toRadians(angle)),angle-y)
  }
  val (e,n) = read(0,0,90)
  println(e.toInt)
  println(n.toInt)
}