#include<bits/stdc++.h>
#define PI 3.14159265
using namespace std;

int main(){

  double d, a;
  double r = 90.0;
  double x = 0, y = 0;

  while(true){
    scanf(" %lf,%lf", &d, &a);

    if(!d && !a) break;
    y += d*sin((r*PI)/180.0);
    x += d*cos((r*PI)/180.0);
    r -= a;
  }

  printf("%d\n%d\n", (int)x, (int)y);

}

