#include <cstdio>
#include <cmath>
#define PI 3.14159265358979323846

int correct(int d){
  if(d<0){
    return d+360;
  }else if(d>360){
    return d-360;
  }else{
    return d;
  }
}

int main(){
  double x=0,y=0;
  int l,d,dir=0;

  while(scanf("%d,%d",&l,&d),l){
    x += l*sin(PI*dir/180);
    y += l*cos(PI*dir/180);
    dir = correct(dir+d);
  }

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