//C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<long long,long long> P;
double pi=3.14159265358;
int main(){
  double now=pi*0.5;
  double x=0.0,y=0.0;
  while(1){
    double a,b;
    scanf("%lf,%lf",&a,&b);
    if (a==0.0 and b==0.0)break;
    double xx=0.0,yy=0.0;
    xx=cos(now)*a;
    yy=sin(now)*a;
    x+=xx;
    y+=yy;
    now-=(b/180*pi);
    if(now>=2*pi)now-=2*pi;
    if(now<=-2*pi)now+=2*pi;
    
    
    
  }  
  printf("%d %d\n",(int)x,(int)y);
}

