#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int main(){
  double x=0,y=0,d,a,b=90;
  for(;;){
    scanf("%lf,%lf",&d,&a);
    if(d == 0 && a == 0) break;
    x+=d*cos(M_PI*b/180);
    y+=d*sin(M_PI*b/180);
    b-=a;
  }
  cout <<(int)x<<endl<<(int)y<<endl;
  return 0;
}