#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>

using namespace std;

int main(){
  int d, r;
  double y = 0.0, x = 0.0, t = 90.0;
  while( scanf("%d,%d", &d, &r), d){
    y += d * sin( t / 180.0 * M_PI);
    x += d * cos( t / 180.0 * M_PI);
    t -= r;

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