//14
#include<iostream>
#include<complex>
#include<cmath>

using namespace std;

int main(){
  complex<double> p;
  double ang=0;
  for(double a,b;(cin>>a).ignore()>>b,a!=0||b!=0;){
    p+=polar(a,ang/180*acos(-1));
    ang+=b;
  }
  cout<<(int)p.imag()<<endl<<(int)p.real()<<endl;
  return 0;
}