Go: package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextFloat64() (float64, error) {
	return strconv.ParseFloat(nextString(), 64)
}

func main() {
	scanner.Split(bufio.ScanWords)

	x, y := 0.0, 0.0
	rotate := 90.0

	for {
		line := nextString()
		if line == "0,0" {
			break
		}

		numbers := strings.Split(line, ",")
		di, _ := strconv.ParseFloat(numbers[0], 64)
		ai, _ := strconv.ParseFloat(numbers[1], 64)

		rotateRadian := math.Pi * rotate / 180.0
		x += di * math.Cos(rotateRadian)
		y += di * math.Sin(rotateRadian)

		rotate -= ai

		// fmt.Println(x, y)
	}

	fmt.Println(int(x))
	fmt.Println(int(y))
}

C++: //0016
// Time-stamp: <2012-07-10 18:44:05 naga>

#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#define PI 3.1415926535
using namespace std;


int main(){
  int walk, deg;
  double x, y;
  int direction;

  x = y = 0;
  direction = 90;
  while(true){
    //radian = (double)(direction * PI/ 180);
    scanf("%d,%d", &walk, &deg);
    if(!walk && !deg){
      break;
    }
    
    x += (double)walk * cos(direction * PI / 180);
    y += (double)walk * sin(direction * PI / 180);

    // 向きを変える。角度を360以下に
    direction += deg;
    if(direction > 360){
      direction = direction - 360;
    }
  }

  cout << (int)x << ' ' << (int)y << endl;

  return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

vector<int> X,Y;
int main(){
	int x=1,y=0;
	while(1){
		scanf("%d,%d",&x,&y);
		if(!(x||y)) break;
		X.push_back(x);
		Y.push_back(y);
	}
	double nx=0,ny=0,na=0;
	for(int i=0;i<X.size();i++){
		nx+=(double)X[i]*sin(na*M_PI/180.0);ny+=(double)X[i]*cos(na*M_PI/180.0);
		na+=(double)Y[i];
	}
	cout<<(int)nx<<endl<<(int)ny<<endl;
	return 0;
}

C++: #include<iostream>
#define _USE_MATH_DEFINES
#include<math.h>
#include<cstdio>
using namespace std;

int main(){
	
	double x=0,y=0;
	int r=90;
	int a,b;
	char cn;
	while(cin>>a>>cn>>b){
	if(a!=b!=0){
		double s=r*M_PI/180;
		x+=a*(-cos(s));
		y+=a*sin(s);
		if(r+b<0)
			r=360-r-b;
		else if(r+b>360)
			r=r+b-360;
		else
			r=r+b;
	}
	else
		break;
	}
	printf("%d\n%d\n",(int)x,(int)y);
		
	
}

C++: #include <iostream>
#include <math.h>
using namespace std;

int main() {

  int input1,input2;
  char c;

  int ang = 0;
  double x,y;
  x = y = 0.00;

  while(true) {

    cin >> input1 >> c >> input2;
    if ( input1 == 0 && input2 == 0 ) break;

    x += sin( M_PI * ang / 180 ) * input1;
    y += cos( M_PI * ang / 180 ) * input1;

    ang += input2;

  }

  int x_i = x;
  int y_i = y;

  cout << x_i << endl << y_i << endl;
  return 0;

}

C++: #include <bits/stdc++.h>
using namespace std;

#define iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)):((m)-(n))),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)
#define loop for(;;)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long Integer;
typedef double Real;
typedef vector<int> vi;
typedef vector<string> vs;
typedef map<string,int> Dictionary;
const Real PI = acos(-1);

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

int dx[] = { -1, 0, 1, 0 };
int dy[] = {  0, -1, 0, 1 };

int main() {

  int r, k;

  Real x = 0,
       y = 0;
  Real theta = 0;

  loop {
    char comma;
    cin >> r >> comma >> k;
    if (!r && !k) break;
    x += r * cos(theta);
    y += r * sin(theta);
    theta += k * PI / 180;
  }

  cout << int(y) << endl;
  cout << int(x) << endl;

  return 0;
}

C++: #include <iostream>
#include <cmath>

int main()
{
    double x = 0.0, y = 0.0;
    const double pi = acos(-1.0);

    int prev_deg = 90;
    while (true) {
        int dist, deg;
        char comma;
        std::cin >> dist >> comma >> deg;
        if (dist == 0 && deg == 0) break;

        x += dist * cos(prev_deg * pi / 180);
        y += dist * sin(prev_deg * pi / 180);

        prev_deg -= deg;
    }

    std::cout << (int)x << "\n" << (int)y << std::endl;
}

C++: #include<iostream>
#include<math.h>
using namespace std;

int main(){
	double x,y,dx,dy,pi;
	int d,rad,prad;
	char camma;
	x=y=0;
	pi=3.141592;
	while(cin>>d>>camma>>rad){
		if(d==0 && rad==0)break;
		dx=d*cos((rad+prad)*pi/180);
		dy=d*sin((rad+prad)*pi/180);
		x+=dx;
		y+=dy;
		prad=rad+prad;
	}
	cout<<(int)x<<endl;
	cout<<(int)y<<endl;
	return 0;
}

C++: #include<iostream>
#include<math.h>

#define pi 3.14159265

using namespace std;

int main()
{
	double dis,ang;
	double nx,ny;
	double nang=pi/2.0,hang=90;
	nx=ny=0;
	while(scanf("%lf,%lf",&dis,&ang),dis){
		ny+=dis*sin(nang);
		nx+=dis*cos(nang);
		nang=(hang-ang)*pi/180;
		hang-=ang;
	}

	cout<<(int)nx<<endl<<(int)ny<<endl;
	return 0;
}

C++: #include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#define li long long int
#define ld long long double
#define PI 3.1415926535897932384626
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> P;

string str;

int main()
{
  double x=0,y=0;
  int a=0,b=0;
  double arg=90;
  while(1){
    scanf("%d,%d",&a,&b);
    if(a==0 && b==0)break;
    double radian=arg*PI/180.0;
    x+=a*cos(radian);
    y+=a*sin(radian);
    arg-=b;
  }
  a=x;
  b=y;
  cout<<a<<endl;
  cout<<b<<endl;
}

C++: #include <iostream>
#include <cmath>
template <class Type> class Point {
    Type x;
    Type y;
public:
    Point(const Type& f = Type(), const Type& s = Type()) : x(f), y(s) { }
    Type get_x() const { return x; }
    Type get_y() const { return y; }
    void set(const Type& x, const Type& y)  {this->x = x; this->y = y;}
    void print()  { std::cout << "(" << this->x << ", " << this->y << ")\n"; }
    void answer() { std::cout <<  static_cast<int>(this->x) << '\n' << static_cast<int>(this->y) << std::endl; }
};
int main()
{
    Point<double>   point;
    char            comma;
    for (double distance, angle, sum_angle = 0; std::cin >> distance >> comma >> angle && (distance || angle);) {
        point.set(point.get_x() + distance * sin(sum_angle), point.get_y() + distance * cos(sum_angle));
        sum_angle += angle * M_PI / 180;
    }
    point.answer();
}

C++: #include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	double X=0,Y=0;
	int degree=90;
	double DegToRad = (4.0*atan(1))/180.0;
	while(true){
		int D,A;
		scanf("%d,%d",&D,&A);
		if(D==0 && A==0) break;

		double DX=D*cos(DegToRad*degree),DY=D*sin(DegToRad*degree);
		X+=DX;
		Y+=DY;
		degree-=A;
	}

	out((ll)X);
	out((ll)Y);
	return 0;
}