#include <iostream>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

void solve()
{
	int d, t;
	double x = 0, y = 0;
	double angle = 90;
	while(true)
	{
		scanf("%d,%d", &d, &t);
		if(d == 0 && t == 0)
		{
			break;
		}
		x += d * cos(angle / 180 * M_PI);
		y += d * sin(angle / 180 * M_PI);
		angle -= t;
	}
	cout << (int)x << endl;	
	cout << (int)y << endl;
}

int main()
{
	solve();
	return(0);
}