#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

int stringTOlint(string s) {
	//string→lint
	lint Z = s.size();
	lint ret = 0;
	reverse(s);
	rep(i, Z) {
		ret += ((s[i] - '0') * pow(10, i));
	}
	return ret;
}

int main() {
	double pi = 3.1415926535;
	string S;
	int LD=0, LA=0;
	double D=0, A=0;
	double NX = 0, NY = 0, NA = 90;
	while (1) {
		cin >> S;
		if (S == "0,0") {
			cout << int(NX)*(-1) << endl << int(NY) << endl;
			return 0;
		}
		else {
			string SD, SA;
			bool flag = false;
			rep(i, S.size()) {
				if (S[i] == ',') {
					flag = true;
				}
				else {
					if (flag == false) {
						SD.push_back(S[i]);
					}
					else {
						SA.push_back(S[i]);
					}
				}
			}
			LD = stoi(SD);
			LA = stoi(SA);
			D = double(LD);
			A = double(LA);
			NX += D * cos(NA * pi / 180);
			NY += D * sin(NA * pi / 180);
			NA += A;
		}
	}
}
