#include <iostream>
#include <complex>
const double pi = 3.14159265358979;
using namespace std;

double radians(int degree){
	return double(degree)/180*pi;
}

int main(void){
	int r, angle=0, direction=90;
	char c;
	complex <double> p(0, 0);
	while (true){
		cin>>r>>c>>angle;
		if (r==0 && angle==0) break;
		p += polar((double)r, radians(direction));
		direction -= angle;

	}
	cout<<(int)p.real()<<endl;
	cout<<(int)p.imag()<<endl;
	return 0;
}