#include<iostream>
#include<cmath>
using namespace std;
int main(){
	double x=0,y=0,rad=M_PI/2;
	int a,b;
	while(1){
		cin>>a;
		cin.ignore();
		cin>>b;
		if(!a&&!b)break;
		x += a*cos(rad);
		y += a*sin(rad);
		rad -= b*M_PI/180;
	}
	cout<<(int)x<<endl<<(int)y<<endl;
	return 0;
}