
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <utility>
#include <complex>
#include <stack>

using namespace std;

typedef complex<double> P;

int main(){

	double x=0,y=0;
	double c_th = 90;
	double r,th; char c;
	while(cin>>r>>c>>th,(r||th)){
		x += r * cos(c_th * M_PI / 180);
		y += r * sin(c_th * M_PI / 180);
		c_th -= th;
	}

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

	return 0;
}