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

int main() {
  double pi=3.14159265358979;
  double x=0, y=0, r=-pi/2;

  while(1) {
    int z,nr;
    scanf("%d%*c%d",&z,&nr);
    if(z==0 && nr==0) break;

    x += z*cos(r);
    y += z*sin(r);
    r -= nr*pi/180;
  }
  cout << -(int)x << endl << -(int)y << endl;
  return 0;
}
