#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main(void){
  int l,r,r2=90;
  double x=0,y=0;
  double pi=3.141592653589793;
  for(;;){
    scanf("%d,%d",&l,&r);
    if(!l && !r) break;
    x+=l*cos(r2*pi/180);
    y+=l*sin(r2*pi/180);
    r2-=r;
  }
  printf("%d\n%d\n",(int)x,(int)y);
}
