#include <iostream>
#include <cmath>
#include <cstdio>

#define PI 3.1415926535897932384

using namespace std;

int main() {
	double x = 0, y = 0;
	int t = 90;
	
	while (1) {
		int d, it;
		scanf("%d,%d", &d, &it);
		if (d==0 && it==0) break;
		
		x += d * cos((double)t * PI/180.);
		y += d * sin((double)t * PI/180.);
		
		t -= it;
	}
	
	cout << (int)x << endl << (int)y << endl;
	
	return 0;
}