#include<stdio.h>
#include<math.h>
int main()
{
	int k,h,f;
	double p=3.141592653589,tt,yk,x=0,y=0,r,mk=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;
		}
		if(mk>=0){
			f=1;
		}else{
			f=0;
		}
		k=fabs(k);
		r=((90-mk)*p)/180;
		yk=cos(r)*h;
		tt=sin(r)*h;
		if(f){
			x+=yk;
		}else{
			x-=yk;
		}
		y+=tt;
	}
	printf("%d,%d\n",(int)x,(int)y);
	return 0;
}