#include <iostream>
#include <cmath>
#define PI acos(-1)
 
using namespace std;
 
int main(){
        double x=0.0,y=0.0;
        double nr=PI/2.0;
        int l,r;
        while(true){
                cin >> l;
		cin.ignore();
		cin >> r;
                if(!(l|r))
                        break;
                x+=l*cos(nr);
                y+=l*sin(nr);
                nr-=r*PI/180.0;
        }
        cout << (int)x <<endl<< (int)y <<  endl;
return 0;
}