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

int main(){
  int x=0, y=0;
  int direction = 90;
  int distance,angle;
  char comma;
  while(true){
    cin >> distance >> comma >> angle;
    if(distance == 0 && angle == 0) break;

    x += distance * cos(direction);
    y += distance * sin(direction);
    direction += angle;
  }
  cout << x << endl;
  cout << y << endl;
  return 0;
}