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

int main()
{
	int n,r,next=90;
	double x=0,y=0;
	char tmp;
	while(1)
	{
		cin>>n>>tmp>>r;
		if(n==0&&r==0) break;

		double rad=M_PI/180*next;
		next-=r;

		x+=n*cos(rad);
		y+=n*sin(rad);
	}

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