#include <iostream>
#include <cstdio>
#include <cmath>
 
using namespace std;
 
int main(int argc, char *argv[])
{
  double x,y;
  double sumE = 0;
  double sumN = 0;
  double rad = M_PI/2.0;
  while(scanf("%lf,%lf",&x,&y) !=EOF ){
    getchar();
    if(x ==0&& y== 0)
      break;
    sumE += x*cos(rad);
    sumN += x*sin(rad);
    rad  -= y*M_PI/180;
  }
  cout <<(int)sumE <<endl<<(int)sumN <<endl;
  return 0;
}
