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 <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <set>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()

int main() {
    int r, t;
    int crtt = 90;
    double crtx = 0, crty = 0;
    while(1) {
        scanf("%d,%d", &r, &t);
        if (r == 0 && t == 0) break;
        crtx += cos(crtt * acos(-1) / 180) * r;
        crty += sin(crtt * acos(-1) / 180) * r;
        crtt -= t;
    }
    printf("%d\n%d\n", (int)crtx, (int)crty);
    return 0;
}

C++: #include <iostream>
#include <string>
#include <math.h>
#include <stdlib.h>
using namespace std;
void getValue(string& l, int& d, int& a)
{
	string::size_type p = l.find(',');
	d = atoi(l.substr(0, p).c_str());
	a = atoi(l.substr(p + 1).c_str());
}
int main()
{
	string line;
	int d, a;
	double x = 0.0, y = 0.0, angle = 90.0, toR = 3.14159265358979323846 / 180.0;
	while (true){
		cin >> line;
		getValue(line, d, a);
		if (0 == d && 0 == a)
			break;
		x += cos(angle * toR) * d;
		y += sin(angle * toR) * d;
		angle -= a;
	}
	cout << (int)x << "\n" << (int)y << "\n";
	return 0;
}

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

constexpr double PI = 3.1415926535;

double convert(int deg);
double adjust(double rad);

int main()
{
    double x = 0, y = 0;
    double rad = PI / 2;

    while (true) {
        int r, deg;
        char c;
        std::cin >> r >> c >> deg;

        if (r == 0 && deg == 0) {
            break;
        }

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

        rad = adjust(rad + convert(deg));
    }

    int ix = static_cast<int>((x > 0)? floor(x): -floor(-x));
    int iy = static_cast<int>((y > 0)? floor(y): -floor(-y));
    std::cout << ix << std::endl << iy << std::endl;

    return 0;
}

double convert(int deg)
{
    return (-deg * PI / 180);
}

double adjust(double rad)
{
    while (rad > PI) {
        rad -= 2 * PI;
    }
    while (rad < -PI) {
        rad += 2 * PI;
    }

    return rad;
}

C++: #include <bits/stdc++.h>
using namespace std;
/* {{{ */
/*-------------------------------*/
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (b) - 1; i >= (a); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define RREP(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)

#define all(i) (i).begin(),(i).end()
#define rall(i) (i).begin(),(i).end(),greater<int>()
#define PB push_back
#define pb push_back
#define mp make_pair
#define FI first
#define SE second
//#define int long long

#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef vector<long long> llv;
typedef vector<pint> vpint;

const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1}; 

inline int in(){int x;std::cin>>x;return x;}

struct FAST {FAST(){cin.tie(0);ios::sync_with_stdio(false);}} Fast;

template <class X> void print(X hoge){ cout << hoge << '\n'; }
/*-------------------------------*/
/* }}} */ 

signed main(void)
{
  int d, a;
  int now = 90;
  double x = 0, y = 0;

  while (scanf("%d,%d", &d, &a), d || a) {
    x += d * cos(M_PI * now / 180.0);
    y += d * sin(M_PI * now / 180.0);

    now = (now - a + 360) % 360;
  }

  print((int)x);
  print((int)y);

  return (0);
}

C++: #include <iostream>
#include <complex>
const double pi = 3.14159265358979;
using namespace std;

double radians(int degree){
	return double(degree)/180*pi;
}

int main(void){
	int r, angle=0, direction=90;
	char c;
	complex <double> p(0, 0);
	while (true){
		cin>>r>>c>>angle;
		if (r==0 && angle==0) break;
		p += polar((double)r, radians(direction));
		direction -= angle;

	}
	cout<<(int)p.real()<<endl;
	cout<<(int)p.imag()<<endl;
	return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main(void){
  int l,r,r2=90;
  double x=0,y=0;
  double pi=3.141592653589793;
  for(;;){
    scanf("%d,%d",&l,&r);
    if(!l && !r) break;
    x+=l*cos(r2*pi/180);
    y+=l*sin(r2*pi/180);
    r2-=r;
  }
  printf("%d\n%d\n",(int)x,(int)y);
}

C++: #define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
#include <map>
#include <fstream>
#include <array>
#include <utility>
#include <functional>
#include <stack>
#include <math.h>

using namespace std;
typedef long long Int;
#define REP(i , x) for(Int i = 0 ; i < x ; ++i)
typedef pair<int, int> P;


int main()
{
	int a, b;

	double x = 0; 
	double y = 0;
	int radius = 0;


	while (scanf_s("%d,%d", &a, &b), a&&b){
		y += a*sin(radius*M_PI/180);
		x += a*cos(radius*M_PI/180);
		radius += b;
	}
	y *= 10;
	y %= 10;
	y /= 10;

	x *= 10;
	x %= 10;
	x /= 10;

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

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

using namespace std;

int main(){
	double	x = 0,
		y = 0;
	int	deg = 0;
	int	p, q;
	while(scanf("%d,%d", &p, &q) && p && q){
		x += p * sin(deg * M_PI / 180);
		y += p * cos(deg * M_PI / 180);	
		deg += q;
	}
	cout << (int)x << endl;
	cout << (int)y << endl;
	return 0;
}

C++: #include<iostream>
#include<cmath>
#define PI 3.141592653589793
using namespace std;
int main(){
	char z;
	int a;
	double b;
	int i,j,k;
	double x=0,y=0;
	double d=0;
	while(cin>>a>>z>>b){
		if(a==0)break;
		x+=(double)a*cos(d/180.0*PI);
		y+=(double)a*sin(d/180.0*PI);
		d+=b;
	}
	cout<<(int)y<<endl;
	cout<<(int)x<<endl;
	return 0;
}

C++: #define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>

using namespace std;

int main()
{	
	double posX=0;
	double posY=0;
	double angle=90;
	string str;
	while(getline(cin,str,',')){
		string str2;
		getline(cin,str2);

		int a,b;
		sscanf(str.c_str(),"%d",&a);
		sscanf(str2.c_str(),"%d",&b);

		if(a==0 && b==0) break;

		posX -= a * sin(M_PI/2.0 -angle/180.0*M_PI);
		posY += a * cos(M_PI/2.0 -angle/180.0*M_PI);

		angle += b;	
	}
	printf("%.0f\n%.0f\n",floor(posX),ceil(posY));
}

C++: #include<stdio.h>
#include<cmath>
#include<iostream>

#define PI 3.14159265358979323846
using namespace std;

int length, angle, currentAngle;
double px, py;
 
void walk(){
    double dx = length * cos(currentAngle * PI / 180.0);
    double dy = length * sin(currentAngle * PI / 180.0);
    currentAngle -= angle;
    px += dx;
    py += dy;
}

main(){
    px = 0;
    py = 0;
    currentAngle = 90;
    while(1){
	scanf("%d,%d", &length, &angle);
	if ( length == 0 && angle == 0 ) break;
	walk();
    }
    int x = (int)px;
    int y = (int)py;
    printf("%d\n", x);
    printf("%d\n", y);
}