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

int main() {
	int walk, angle, na = 90;
	double x = 0, y = 0;
	char c;
	
	while(1){
		cin >> walk >> c >> angle;
		if(walk == 0 && angle == 0)break;
		
		double r = double(na / 180.0 * M_PI);
		x += walk * cos(r);
		y += walk * sin(r);
		
		na -= angle;
	}
	
	cout << (int)x << endl;
	cout << (int)y << endl;
	
	return 0;
}