#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.1415

int main(){
	vector<int>u;
    vector<int>v;

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

	int n=u.size();
	int c=90; float x=0; float y=0;
	for(int i=0;i<n;i++){
	x+=u[i]*cos(c*PI/180);
	y+=u[i]*sin(c*PI/180);
	c+=-v[i];

	}

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

	return 0;

    }