#include <iostream>
#include <math.h>

#define PI 3.14159265

using namespace std;

int main(){
  double theta,theta_sum;
  double x,x_sum,y_sum;
  
  y_sum =0;
  scanf("%f,%f",&x,&theta);
  x_sum = x,theta_sum = theta;
  while(scanf("%f,%f",&x,&theta) && x != 0 && theta != 0){
    x_sum += x*sin(theta_sum * PI / 180);
    y_sum += x*cos(theta_sum * PI / 180);
    theta_sum += theta;
  }

  cout << floor(x_sum) << endl << floor(y_sum) << endl;

  return 0;

}