object Main extends App {
  import java.util.Scanner
  val sc = new Scanner(System.in)
  case class Status(x: Double = 0.0, y: Double = 0.0, angle: Double = Math.PI/2)
  def loop(status: Status): Status = {
    val (a, b) = (sc.nextInt(), sc.nextInt())
    if (a == 0 && b == 0) {
      println(status.x.toInt)
      println(status.y.toInt)
      status
    }
    else {
      loop(new Status(status.x + a*Math.cos(status.angle), status.y + a*Math.sin(status.angle), status.angle + Math.PI*b/180.0))
    }
  }
  loop(new Status)
}