#include <iostream>
#include <cmath>

using namespace std;

int main() {
	
	int m, angle;
	double x=0, y=0, deg=90;
	const double PI =3.14159265;

	while(1) {
		cin >> m >> angle;
		if(m==0&&angle==0)
			break;
		x+=m*cos((double)(deg*PI/180));
		y+=m*sin((double)(deg*PI/180));
		deg-=angle;
	}

	cout << (int)x << endl << (int)y << endl;

	return 0;

}