#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<complex>
#include<iomanip>

#define EPS (1e-10)
using namespace std;
#define PI (3.1415926535)

int main(){
	int m, n;
	double x = 0, y = 0;
	double rad = PI/2;
	char in[10];
	const char *delim = ",";

	while(cin >> in){
		m = atoi(strtok(in, delim));
		n = atoi(strtok(NULL, delim));
		if( m == 0 && n == 0){
			break;
		}
		x += m * cos(rad);
		y += m * sin(rad);
		rad -= PI/180 * n;
	}

	cout << (int)x << "\n" << (int)y << endl;

	return 0;
}