#include <stdio.h>
#include <math.h>
#define M_PI 3.141592653589793
#pragma warning(disable:4996)
int main(){
	double x = 0,y = 0;
	int a,b,c=90;

	while(true){
		scanf("%d,%d",&a,&b);
		if(a == 0 && b == 0)break;
		x += a*cos(c*M_PI/180);
		y += a*sin(c*M_PI/180);
		c -= b;
	}
	printf("%d\n%d\n",(int)x,(int)y);
    return 0;
}
