#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
int main(void){
	int A, B;
	double x=0, y=0, angle=3.14159265/2;
	for(;;){
		scanf("%d,%d", &A, &B);
		if(A==0 && B==0) break;
		x+=cos(angle)*A;
		y+=sin(angle)*A;
		angle += B*3.14159265/180;
	}
	printf("%d\n%d\n", (int)x, (int)y);
	return 0;
}