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

const double pi = acos(-1.0);

double theta(int a) {
	return a / 180.0 * pi;
}
int main() {
	int d, a, pre_a = 0;
	double x, y;
	x = 0.0; y = 0.0;
	
	while (1) {
		scanf("%d,%d", &d, &a);
		if (d == 0 && a == 0) break;
		x += d * sin(theta(pre_a));
		y += d * cos(theta(pre_a));
		pre_a += a;
	}
	cout << (int)x << endl;
	cout << (int)y << endl;
}
