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

int main(){
    int d, t;
    double x = 0, y = 0;
    double angle = 90;
    while(1){
        cin>>d>>t;
        if(d==0&&t==0)
            break;
        x+=d*cos(angle/180*acos(-1));
        y+=d*sin(angle/180*acos(-1));
        angle-=t;
    }
    cout<<(int)x<<endl;
    cout<<(int)y<<endl;
}