#define _USE_MATH_DEFINES
#include<iostream>
#include<cmath>
using namespace std;

int main(void){
	double x=0.0, y=0.0;
	double rad=M_PI/2.0;
	int r,a; char c;
	
	while(cin>>r>>c>>a){
		if( r==0 && a==0 ) break;
		double dx = r*cos(rad);
		double dy = r*sin(rad);
		rad -= a*M_PI/180.0;
		x+=dx; y+=dy;
	}

	cout << (int)x << endl << (int)y << endl;
	return 0;
}