#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;
#define  PI 3.141592
int main(void){
    long double x=0.0, y=0.0;
    int distance, angle, angle_total=0;
    char commma;
    
   
    while(1){
        cin >> distance>> commma >> angle;
        if(angle == 0 && distance == 0) break;
        x += distance * cos((90-angle_total)*PI/180);
        y += distance * sin((90-angle_total)*PI/180);
        angle_total += angle;
        


    }
    int int_x = x;
    int int_y = y;
    cout <<  int_x << endl << int_y << endl;
    return 0;
}

