#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
double GetRad(int an){
  return (double)an*(M_PI/180.0);
}
main(){

  int x,an;
  double rx=0,ry=0;
  int ra=90;
  while(1){
    scanf("%d,%d",&x,&an);
    if(x==0 && an==0) break;
    double rad=GetRad(ra);
    rx+=cos(rad)*(double)x;
    ry+=sin(rad)*(double)x;
    ra-=an;
  }
  printf("%d\n%d\n",(int)rx,(int)ry);
  
}