#include<iostream>
#include<math.h>
#include<vector>
#include<stdio.h>
const double p = M_PI;
using namespace std;
int main(){
  double K,x,y;
  int tmpgo,tmprag;
  x = 0; y =0; K = 90;
  for(int count=0;;count++){
    scanf("%d,%d",&tmpgo,&tmprag);
    if(tmpgo == 0 && tmprag == 0){
      break;
    }
    x += tmpgo * cos(K*p /180);
    y += tmpgo * sin(K*p /180);
    K = K - tmprag;
  }
  cout << (int)x << endl << (int)y << endl;

}