#include "bits/stdc++.h"
using namespace std;
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	double PI = acos(-1.0);
	double X = 0, Y = 0;
	int angle = 90;
	while (true) {
		int x, y;char c;cin >> x >> c >> y;
		if (x == 0 && y == 0) break;
		X += x*cos(angle / 180.0 *PI);
		Y += x*sin(angle / 180.0*PI);
		angle += y;
	}
	cout << -(int)X << endl << (int)Y << endl;
}