#include<iostream>
#include<math.h>
#include<iomanip>

#define PI 3.14159265358979
using namespace std;

int main(void)
{
	int a,b;
	char c;
	double x,y,r;
	x=y=0;
	r=0;
	while(cin>>a>>c>>b){
		if(a==0&&b==0){
			break;
		}
		x+=cos(r)*a;
		y+=sin(r)*a;
		r+=b*PI/180.0;
	}
	cout<<(int)y<<endl<<(int)x<<endl;
}