#include <cstdio>
#include <cmath>

using namespace std;

#define PI 4 * atan(1.0)

int main(void){
	int w, r, d = 0;
	double x = 0, y = 0;
	while(1){
		scanf("%d%*c%d%*c",&w,&r);
		if(w == 0 && r == 0){
			break;
		}
		x += w * cos(d * PI / 180);
		y += w * sin(d * PI / 180);
		d += r;
	}
	printf("%d\n%d\n",(int)y,(int)x);
	return 0;
}