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++: #include <string>
#include <vector>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<sstream>
#include<functional>
#include<map>
#include<set>
#include<cmath>

using namespace std;

#define PI 3.1415

int main(){
	vector<int>u;
    vector<int>v;

	int a,b;
	while(true){
	cin >> a >> b;
	u.push_back(a);
	v.push_back(b);
	if(a==0 && b==0) break;
	}

	int n=u.size();
	int c=90; float x=0; float y=0;
	for(int i=0;i<n;i++){
	x+=u[i]*cos(c*PI/180);
	y+=u[i]*sin(c*PI/180);
	c+=-v[i];

	}

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

	return 0;

    }

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

int main()
{
	int n,r,next=90;
	double x=0,y=0;
	char tmp;
	while(1)
	{
		cin>>n>>tmp>>r;
		if(n==0&&r==0) break;

		double rad=M_PI/180*next;
		next-=r;

		x+=n*cos(rad);
		y+=n*sin(rad);
	}

	cout<<(int)x<<endl;
	cout<<(int)y<<endl;
	return 0;
}

C++: #include<string>
#include<vector>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<sstream>
#include<functional>
#include<map>
#include<set>
#include<cmath>

using namespace std;

int main(){

	int a; int b; int c=90; double x=0; double y=0;
	while(true){

	scanf("%d,%d",&a,&b);
	if(a==0 && b==0) break;
	x+=a*cos(c*M_PI/180);
	y+=a*sin(c*M_PI/180);
	c-=b;

	}

	printf("%d\n %d\n",(int)x,(int)y);


	return 0;

    }

C++: #include <vector>
#include <list>
#include <map>
#include <set>
#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 <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main() {
  int dis, ang = -90, cang;
  double ax = 0, ay = 0;
  char c;

  while(1) {
    cin >> dis >> c >> cang;
    if(dis+cang == 0) break;
    ax += dis * cos(-ang*(PI/180));
    ay += dis * sin(-ang*(PI/180));
    ang += cang;
  }
  cout << (int)ax << endl;
  cout << (int)ay << endl;
}

C++: #include<cstdio>
#include<cmath>
#define PI 3.14159265358979
double rad(double a){
  return a*PI/180.0;
}

int main(){
  int a,b;
  int th=0;
  double x = 0, y = 0;
  while(scanf("%d,%d",&a,&b),a){
    x+=a*sin(rad(th));
    y+=a*cos(rad(th));
    th+=b;
  }
  printf("%.0lf\n%.0lf\n",x,y);
  return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

double dot(P a,P b){return real(conj(a)*b);};
double cross(P a,P b){return imag(conj(a)*b);};

int main(){
  int a,b;
  P o(0,0);
  double nowang = 3.141592653589793238 / 2.0;
  P I(0,1);
  while(~scanf("%d,%d",&a,&b)){
    if(a==0 && b==0)break;
    double len = a;
    double ang = (double)b / 180.0 * 3.141592653589793238;
    ang *= -1.0;
    P angvec = exp(I*nowang);
    o += angvec * len;
    nowang += ang;
  }
  cout<<(int)real(o)<<endl;
  cout<<(int)imag(o)<<endl;
  return 0;
}

C++: #include <iostream>
#include <cmath>
#define PI 3.14159265
#define RAD (PI/180)

using namespace std;

int main() {
	
	int m, angle;
	double x=0, y=0, deg=90;

	while(1) {
		cin >> m >> angle;
		if(m==0&&angle==0)
			break;
		x+=(double)m*cos(deg*RAD);
		y+=(double)m*sin(deg*RAD);
		deg-=angle;
	}

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

	return 0;

}

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

using namespace std;

int main(){

	double cx,cy;cx=cy=0;
	int ca=90;
	int op[2];
	char tmp;
	while(cin>>op[0]>>tmp>>op[1]&&!(op[0]==0&&op[1]==0)){
		cy += op[0]*sin(((double)ca/180)*3.141592);
		cx += op[0]*cos(((double)ca/180)*3.141592);
		ca -= op[1];
	}
	cout<<(int)cx<<endl;
	cout<<(int)cy<<endl;
	return 0;
}

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

#define X 0
#define Y 1
#define PI 3.141592653589

int main()
{
    vector<double> udv = {0,1}; // 単位方向ベクトル
    vector<double> cur_position = {0, 0};

    int step=0, angle=0;
    while(1){
        
        scanf("%d,%d", &step, &angle);
        if( !step && !angle )break;

        cur_position.at(X) += udv.at(X)*step;
        cur_position.at(Y) += udv.at(Y)*step;

        // rotation
        double x =  cos(angle*PI/180.0)*udv.at(X) + sin(angle*PI/180.0)*udv.at(Y);
        double y = -sin(angle*PI/180.0)*udv.at(X) + cos(angle*PI/180.0)*udv.at(Y);
        udv.at(X) = x;
        udv.at(Y) = y;
        udv.at(X) = udv.at(X)/sqrt(udv.at(X)*udv.at(X)+udv.at(Y)*udv.at(Y));
        udv.at(Y) = udv.at(Y)/sqrt(udv.at(X)*udv.at(X)+udv.at(Y)*udv.at(Y));
    }    
    cout << static_cast<int>(cur_position.at(X)) << " " << static_cast<int>(cur_position.at(Y)) << endl;

    return 0;
}

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

using namespace std;

int main() {
  const double pi = acos(-1);
  double x = 0, y = 0, angle = 90;
  int dis, dir;
  char c;
  while (true) {
    cin >> dis >> c >> dir;
    if (dis == 0 && dir == 0) break;
    x += dis * cos(angle * pi / 180.0);
    y += dis * sin(angle * pi / 180.0);
    angle -= dir;
  }
  cout << (int)x << '\n' << (int)y << endl;
}