#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cmath>
#include<queue>
using namespace std;

double cx,cy;
int cangle;
typedef pair<int,int> P;
queue<P> move;

int main()
{
    int dis,ang;
    while(true){
        scanf("%d%*c%d",&dis,&ang);
        if(dis==0 && ang==0)break;
        move.push(P(dis,ang));
    }
    cx = 0.0; cy = 0.0;
    cangle = 90;
    while(!move.empty()){
        P p = move.front();move.pop();
        cx += (double)p.first*cos(cangle*M_PI/180);
        cy += (double)p.first*sin(cangle*M_PI/180);
        cangle -= p.second;
    }

    cout << (int)cx << endl;
    cout << (int)cy << endl;

    return 0;
}