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

typedef struct {
    double x, y;
    double rot;
} person;

person me;

static const double PI = 6*asin( 0.5 );

void move(int f, int r){
    me.x += f * cos(me.rot * PI / 180);
    me.y += f * sin(me.rot * PI / 180);
    me.rot -= r;
}

int main(){
    int f, r; char c;
    me.x = 0, me.y = 0, me.rot = 0;
    while (cin >> f >> c >> r, f || r){
	move(f, r);
    }
    cout << -(int)me.y << endl;
    cout << (int)me.x << endl;
}