
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <algorithm>

using namespace std;


bool solve(){
	
	complex<double> p = (0,0);
	double ang = 90;
	while(1){
		double v_mov;
		double tmp_ang;
		char c;
		cin>> v_mov>> c>> tmp_ang;
		tmp_ang *= -1;
		if(v_mov==0 && tmp_ang==0) break;
		p.real() += v_mov * cos(ang/180*M_PI);
		p.imag() += v_mov * sin(ang/180*M_PI);
		ang += tmp_ang;
		if(ang>180)   ang -= 360;
		if(ang<=-180) ang += 360;
	}
	
	cout<< (int)p.real()<<endl;
	cout<< (int)p.imag()<<endl;

	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	solve();

	return 0;
}

 