#include <iostream>

#define M_PI 3.141592653589793

using namespace std;

int debug = 0;

int main(void){
	int len, deg, direction=90;
	double x=0, y=0;
	int i_x, i_y;

	while(cin >> len){
		cin.ignore(); //read ,
		cin >> deg;

		if(len == 0 && deg == 0) break;

		//proceed
		x += len * cos(direction * M_PI / 180);
		y += len * sin(direction * M_PI / 180);
		
		//turn clockwise
		direction -= deg;

		if(debug) cout << "(x, y) = ("<< x << ", "<< y << ")"<< endl;
	}

	i_x = (int)x;
	i_y = (int)y;

	cout << i_x << endl;
	cout << i_y << endl;

	return 0;
}