#include <iostream>
#include <cmath>
using namespace std;

#define PI 3.1415926535897932386

int main()
{
	int x, r;
	double X = 0, Y = 0, rad = 90;

	while(1){
		//üÍ
		if(cin>>x)break;
		if(cin>>r)break;

		//0¾Á½çIíé
		if(x == 0 && r == 0){
			break;
		}

		X += x * cos(rad * PI/180);
		Y += x * sin(rad * PI/180);

		rad -= r;
	}
	
	X = (int)X;
	Y = (int)Y;

	cout<<X<<endl<<Y;
}