#include <cstdio>
#include <cmath>
using namespace std;

int main(){
	int arg = 0, a, b;
	double px, py;
	px = py = 0;
	while(scanf("%d,%d", &a, &b), a != 0 && b != 0){
		py += a * cos(arg * M_PI / 180.);
		px += (arg < 0 ? -1 : 1) * a * sin(arg * M_PI / 180.);
		arg += b;
	}
	printf("%d\n%d\n", (int)(px), (int)(py));
	return 0;
}