#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
#define PI 3.141592653589793238462643383279
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<double,double> DD;

int main()
{
//	cut here before submit 
//	freopen ("testcase.TH", "r", stdin );
	string str = "";
	double dir = PI/2.;
	double x = 0., y = 0.;
	while (1 ){
		getline (cin, str );
		rep (i, str.length() ){
			if (str[i] == ',' ) str[i] = ' ';
		} // end rep
		stringstream ss (str );
		int d, t;
		ss >> d >> t;
		if (d == 0 && t == 0 ) break;
		double rot = (double)t*PI/180.;
		double dx = (double)d*cos(dir);
		double dy = (double)d*sin(dir);
		x += dx, y += dy;
		dir -= rot;
	} // end while
	printf ("%d\n%d\n", (int)x, (int)y );

	return 0;
}