Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var x, y float64
	angle := 90.0

	for sc.Scan() {
		data := strings.Split(sc.Text(), ",")
		if data[0] == "0" && data[1] == "0" {
			break
		}
		meters, _ := strconv.Atoi(data[0])
		m := float64(meters)
		changedAngle, _ := strconv.Atoi(data[1])
		a := float64(changedAngle)

		radian := angle * math.Pi / 180
		x += m * math.Cos(radian)
		y += m * math.Sin(radian)
		angle -= a
	}
	fmt.Println(int(x))
	fmt.Println(int(y))
}

C++: #include <iostream>
#include <cstdio>
#include <cmath>
#define R (3.1415926535898/180.0)
using namespace std;

int main(){
	int go,turn;
	double x=0,y=0,cur=0;
	
	while(scanf("%d,%d\n",&go,&turn) , (go && turn) ){
		y += cos(cur * R) * go;
		x += sin(cur * R) * go;
		cur += turn;
	}
	cout << (int)x << endl << (int)y << endl;
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <complex>
#include <string>
#include <math.h>
using namespace std;
typedef complex<double> P;
const double PI = 4*atan(1.0);
 
int main(){
	P p(0, 0), dir(0,1);
	while(1){
		double d,r;
		scanf("%lf,%lf", &d, &r);
		if(d==0) break;
		p += dir*d;
		dir *= P(cos(r*PI/180), -sin(r*PI/180));
	}
	int x=p.real(), y=p.imag();
	cout << x << endl << y << endl;
}

C++: #include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define all(v) v.begin(),v.end()
template<typename T>T rad(T deg){return deg*M_PI/180;}

using namespace std;
int main() {
    double x=0,y=0,theta=0;
    double a,b;
    scanf("%lf,%lf",&a,&b);
    while(a||b){
        y += a*cos(rad(theta));
        x += a*sin(rad(theta));
        theta += b;
        scanf("%lf,%lf",&a,&b);
    }
    printf("%.0lf %.0lf",x,y);
    return 0;
}

C++: /*****include*****/
#include <iostream>
#include <fstream>
#include <math.h>

/*****デバッグ定義*****/
//#define DEBUG
#define PI 3.14
/*****マクロ定義*****/

/*****名前空間*****/
using namespace std;

/*****グローバル変数置き場*****/

/*****その他関数置き場*****/

/*****main関数*****/
int main(){
	/*****ファイルオープン*****/
#ifdef DEBUG
	ofstream fout("output.txt");
	ifstream fin("input.txt");
	if(!fout || !fin){
		cout << "Can't open the file.\n";
		return;
	}
#endif
	/*****変数置き場*****/
	int walk=0,degree=0,last_degree;
	double x_ax,y_ax;
	/*****処理部*****/
	last_degree = 90;
	x_ax = 0;
	y_ax = 0;
	while(1){
		scanf("%d,%d",&walk,&degree);
		if(walk == 0 && degree == 0)	break;
		printf("%d\n%d\n",walk,degree);
		x_ax += (double)walk * cos((double)last_degree * PI / 180);
		y_ax += (double)walk * sin((double)last_degree * PI / 180);
		last_degree = last_degree - degree;
	}
	printf("%d\n%d\n",(int)x_ax,(int)y_ax);
	/*****処理終了後*****/
#ifdef DEBUG
	fout.close();
	fin.close();
#endif
	return 0;
}

C++: #include <cstdio>
#include <bitset>
#include <cmath>
#include <complex>
#include <vector>
#include <algorithm>
#include <stack>
#include <iostream>
#define EPS 1e-6

using namespace std;
typedef complex<double> coor;

double cross(coor a, coor b)
{
  return a.real() * b.imag() - a.imag() * b.real();
}

double dot(coor a, coor b)
{
  return a.real() * b.real() + a.imag() * b.imag();
}

int main()
{
  double x, y;
  coor cur(0, 0);
  coor dir(1, 0);
  double pi = atan(1) * 4;
  while (scanf(" %lf,%lf ", &x, &y) == 2) {
    //printf("%.3lf\n%.3lf\n", cur.real(), cur.imag());
    if (abs(x) < EPS && abs(y) < EPS) {break;}
    cur += coor(x * dir.real(), x * dir.imag());
    double Arg = arg(dir) + (y / 180) * pi;
    dir = coor(cos(Arg), sin(Arg));
  }
  printf("%d\n%d\n", (int)cur.imag(), (int)cur.real());
  return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <stdio.h>

#define PI 4*atan(1.0)

using namespace std;

int main()
{
	double x=0,y=0,theta=90;
	int a,b;

	scanf("%d,%d",&a,&b);
	while(a!=0 && b!=0){
		x+=a*cos(theta*PI/180);
		y+=a*sin(theta*PI/180);

		theta-=b;
		scanf("%d,%d",&a,&b);

	}

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

	return 0;
}

C++: #include<cstdio>
#include<cmath>
int main(){
    int hos,ang;
    int t=90;
    double x=0,y=0;
    for(;;){
        scanf("%d,%d",&hos,&ang);
        if(hos==0 && ang ==0) break;
        x+=hos*cos(t*M_PI/180);
        y+=hos*sin(t*M_PI/180);
        t-=ang;
    }
    printf("%d\n%d\n",(int)x,(int)y);
}

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

int main(void)
{
	const double PI = 6 * asin(0.5);
	double angle = 0.0;
	double x = 0.0, y = 0.0;

	while(1) {
		int dist, theta;
		scanf("%d,%d", &dist, &theta);

		if(dist == 0 && theta == 0) break;

		x += dist * sin(angle);
		y += dist * cos(angle);
		angle += (theta * PI) / 180;
	}

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

C++: #include <cstdio>
#include <cmath>
#define PI 3.14159265358979323

int correct(int d){
  if(d<0){
    return d+360;
  }else if(d>360){
    return d-360;
  }else{
    return d;
  }
}

int main(){
  double x=0,y=0;
  int l,d,dir=-90;

  while(scanf("%d,%d",&l,&d),l){
    x += l*cos(PI*dir/180);
    y += l*sin(PI*dir/180);
    dir = correct(dir+d);
  }

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

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

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

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

int main()
{
	int a, b;
	char c;
	double rad = M_PI / 2.0, x = 0, y = 0;
	for (cin >> a >> c >> b; a || b; cin >> a >> c >> b) {
		x += a*cos(rad);
		y += a*sin(rad);
		rad -= (b / 180.0 * M_PI);
		/*
		if (rad < -M_PI) {
			rad += (2 * M_PI);
		}
		else if (rad>M_PI) {
			rad -= (2 * M_PI);
		}*/
	}
	cout << int(x) << endl << int(y) << endl;
	return 0;
}

C++: #define _USE_MATH_DEFINES
#include <cmath>
#include <iostream>
//#include <stdio.h>
//#include <stdlib.h>
//#include <iomanip>
#include <vector>
//#include <string>
//#include <algorithm>
//#include <functional>
//#include <time.h>

using namespace std;


int main(){

	int r;
	char c;
	float x, y;
	double th0,th1;

	th1 = M_PI_2;
	x = 0.0;
	y = 0.0;

	while (1){
		cin >> r >> c >> th0;
		if (r == 0 && th0 == 0)break;

		x += r * cos(th1);
		y += r * sin(th1);

		th1 -= th0 * M_PI / 180.0;
	}
	cout << (int)x << endl << (int)y << endl;


	return 0;
}

C++: #include <iostream>
#include <sstream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
#define ALL(a)  (a).begin(),(a).end()
#define REP(i,n) for(int i=0;i<(n);++i)
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define dump(x) cerr << "  (L" << __LINE__ << ") " << #x << " = " << (x) << endl;
#define dumpv(x) cerr << "  (L" << __LINE__ << ") " << #x << " = "; REP(q,(x).size()) cerr << (x)[q] << " "; cerr << endl;
template<typename T1, typename T2>
ostream& operator<<(ostream& s, const pair<T1, T2>& d) {return s << "(" << d.first << "," << d.second << ")";}


int main() {
  double x = 0.0, y = 0.0;
  double angle = 90;

  while (true) {
    int a, b; scanf("%d,%d", &a, &b); 
    if (a == 0 && b == 0) break;

    double theta = PI * angle / 180.0;
    dump(theta);
    x += a * cos(theta);
    y += a * sin(theta);
    angle -= b;
  }

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