#include <bits/stdc++.h>
using namespace std;

int main(){
  double x = 0, y = 0;
  int angle = 90;

  while(true){
    int d, a; 
    scanf("%d,%d", &d, &a);
    if(d == 0 && a == 0) break;

    x += d * cos(angle*acos(-1)/180.0);
    y += d * sin(angle*acos(-1)/180.0);
    angle -= a;
  }

  cout << (int)x << endl;
  cout << (int)y << endl;
}
  
  
