#include <string>
#include <vector>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<sstream>
#include<functional>
#include<map>
#include<set>
#include<cmath>

using namespace std;

#define PI 3.14159265

vector<int>d;
vector<int>e;
vector<double>u;
vector<double>v;

int main(){

	int a,b;
	while(true){
	cin >> a >> b;
	if(a==0 && b==0) break;
	d.push_back(a); e.push_back(b);
	}

   int n=d.size();

	int c=90;
    for(int i=0;i<n;i++){
	u.push_back(d[i]*cos(c*PI/180));
	v.push_back(d[i]*sin(c*PI/180));
	c+=-e[i];
    }

	double x=0; double y=0;
	for(int i=0;i<n;i++){
	x+=u[i];
	y+=v[i];
	}

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

	return 0;
    }