#include<stdio.h>
#include<math.h>
int main()
{
	int k,h;
	double p,tt,yk,x=0,y=0,r,mk=0;
	p=atan(1.0) * 4.0;
	while(1){
		scanf("%d,%d",&h,&k);
		if(h==0&&k==0){
			break;
		}
		mk+=k;
		if(mk>=360){
			mk-=360;
		}
		if(mk<=360){
			mk+=360;
		}

		r=((90-mk)*p)/180;
		yk=cos(r)*h;
		tt=sin(r)*h;
		x+=yk;
		y+=tt;
	}
	printf("%d\n%d\n",(int)x,(int)y);
	return 0;
}