#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <queue>
#include <string>
#include <complex>
using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)
#define repa(i,s,e) for(int i=s; i<=e; i++)
#define repd(i,s,e) for(int i=s; i>=e; i--)

typedef long long ll;
typedef vector<int> vi;
typedef complex<double> P;

int main() {
	int s, t;
	P p(0.0, 0.0);
	P o(0.0, 1.0);
	while(scanf("%d,%d", &s, &t), s|t) {
		p = p + o * (double)s;
		double theta = -M_PI * t / 180.0;
		o = o * P(cos(theta), sin(theta));
	}
	printf("%d\n%d\n", (int)p.real(), (int)p.imag());
}