#include <iostream>
#include <cmath>
#include <cstdio>
 
using namespace std;
 
int main(int argc, char *argv[]) {
  int a, b;
  double x, y, angle;
 
  x = y = angle = 0.0;
 
  while (true) {
    scanf("%d,%d", &a, &b);
    if (a == 0 && b == 0)
      break;
    y += a * cos(angle / 180 * M_PI);
    x += a * sin(angle / 180 * M_PI);
    angle += b;
  }
 
  cout << (int)x << endl;
  cout << (int)y << endl;
  return 0;
}