#include<bits/stdc++.h>
using namespace std;
int d, a;
string s;
double x = 0, y = 0, p = 0, pi = 3.141592653589793238462643383279502884197169;
void f() {
	int p = 0, sig = 1;
	for (char ch : s) {
		if (ch == ',') {
			d = p*sig; p = 0; sig = 1;
		}
		else if (ch == '-')sig = -1;
		else p = p * 10 + ch - '0';
	}
	a = p * sig;
}
signed main() {
	while (cin >> s) {
		f();
		if (d == 0 && a == 0)break;
		x += d * sin(p * pi / 180);
		y += d * cos(p * pi / 180);
		p += a;
	}
	cout << (int)x << endl << (int)y << endl;
}
