#include <cstdio>
#include <iostream>
#include <math.h>
#define PI 3.1415926535897932384626433832795

using namespace std;

double radian(int degree)
{
	return (PI * degree) / 180;
}

int main()
{
	double x = 0;
	double y = 0;
	int degree = 0;

	int walk, turn;
	while(true)
	{
		scanf("%d,%d", &walk, &turn);
		if(walk == 0 && turn == 0)
			break;

		x -= cos( radian(degree - 90) ) * walk;
		y -= sin( radian(degree - 90) ) * walk;
		degree -= turn;
	}

	cout << int(x) << endl << int(y) << endl;

	return 0;
}