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 <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;
    now -= a;
  }

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

  return (0);
}

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

using namespace std;

#define PI (M_PI / 180)

int main() {
    int d, a, r = 90;
    double x = 0.0, y = 0.0;
    while (1) {
        scanf("%d, %d", &d, &a);
        if (d == 0 && a == 0) {
            break;
        }
        x += d * cos(r * PI);
        y += d * sin(r * PI);
        r -= a;
        if (r >= 360) {
            r -= 360;
        }
        else if (r < 0) {
            r += 360;
        }
    }
    printf("%d\n%d\n", (int)x, (int)y);
    
    return 0;
}

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

long double abs(long double x)
{
  return (x < 0.0 ? -x : x);
}

long double sqrt(long double x)
{
  const long double EPS = 1e-8;
  long double x0 = x / 2.0, nx = 0.0;

  while (abs(nx - x0) > EPS){
    nx = x0;
    x0 = (x0 + x / x0) / 2.0;
  }

  return x0;
}

long double pi(int n = 1024)
{
  long double a = 1.0, b = 1.0 / sqrt(2.0), t = 1.0 / 4.0, p = 1;

  for (int i = 1; i < n; i++){
    long double na, nb, nt, np;
    na = (a + b) / 2.0;
    nb = sqrt(a * b);
    nt = t - p * (a - na) * (a - na);
    np = 2.0 * p;

    a = na;
    b = nb;
    t = nt;
    p = np;
  }

  return (a + b) * (a + b) / (4.0 * t);
}

long double fact(int n)
{
  long double ret = 1.0;
  for (int i = 1; i <= n; i++)
    ret *= (long double)i;
  return ret;
}

long double pow(long double x, int n)
{
  if (n == 0) return 1.0;
  long double a = pow(x, n / 2);
  if (n & 1){
    return a * a * x;
  } else {
    return a * a;
  }
}

long double sin(int x, int n = 1000)
{
  long double m_pi = pi();
  long double r = ((long double)x * m_pi) / 180.0;

  //printf("pi : %.15lf\n", (double)m_pi);
  long double ret = 0.0;
  for (int i = 0; i < n; i++){
    long double p = pow(r, 2 * i + 1);
    long double f = fact(2 * i + 1);

    //printf("pow : %lf\nfact : %lf\n", (double)p, (double)f);
    ret += ((long double)pow(r, 2 * i + 1) / (long double)fact(2 * i + 1)) * (i & 1 ? -1.0 : 1.0);
  }

  return ret;
}

long double cos(int x, int n = 1000)
{
  long double m_pi = pi();
  long double r = ((long double)x * m_pi) / 180.0;

  long double ret = 0.0;
  for (int i = 0; i< n; i++){
    ret += ((long double)pow(r, 2 * i) / (long double)fact(2 * i)) * (i & 1 ? -1.0 : 1.0);
  }

  return ret;
}

int main()
{
  long double x, y;
  int d, a;
  x = y = 0.0;

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

    x += cos(r) * (double)d;
    y += sin(r) * (double)d;

    r -= a;
  }

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

C++: #include<iostream>
#include<vector>
#include<string>
#include<cmath>
using namespace std;
int main(){
	int w,deg;
	double x=0,y=0,pre=M_PI/2;
	string buf;
	while(cin>>buf){
		int ptr=0;
		string tmp1,tmp2;
		while(buf[ptr]!=',') tmp1+=buf[ptr++];
		w = atoi(tmp1.c_str());
		++ptr;
		while(buf[ptr]) tmp2+=buf[ptr++];
		deg = atoi(tmp2.c_str());
		if(w==0&&deg==0) break;
		x+=(double)w*cos(pre);
		y+=(double)w*sin(pre);
		pre-=(double)deg*M_PI/180;
	}
	cout << (int) x << endl;
	cout << (int) y << endl;
	return 0;
}

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

int main(){
  int d, a = 90, a2; 
  double x,y;
  char c;
  while(cin >> d >> c >> a2){
    if(d == 0 && a == 0) break;
      double rad = a * (PI / 180);
      x += d * cos(rad);
      y += d * sin(rad);
      a += a2;
    }
  cout << (int)x << "\n" << (int)y << endl;
}

C++: #include <iostream>
#define _USE_MATH_DEFINES
#include <cmath>
 
using namespace std;
 
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	double x = 0, y = 0;
	double m, d;
	char c;
	double next = 0;
	while(cin >> m >> c >> d && (m != 0 || d != 0) ){
		double rad = (90 - next) / 180.0 * M_PI;
		x += m * cos(rad);
		y += m * sin(rad);
		next += d;
	}
	
	cout << (int)x << endl;
	cout << (int)y << endl;
	
	return 0;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#define add push_back
#define inf 2147000000
#define pi 3.1415926535

#define rep(i,n) for(int i=0;i<n;i++)
#define out(a) cout<<a<<endl;

using namespace std;

int main(void){
	double x,y,kk=pi/2;
	string str;
	char* bin;
	x=0;y=0;
	while(1){
		cin>>str;
		int t = str.find(',');
		string st1 = str.substr(0,t);
		string st2 = str.substr(t+1);
		
		double a1,a2;
		bin = &st1[0];
		a1=atoi(bin);
		bin = &st2[0];
		a2=atoi(bin);
		
		if(a1==0 && a2==0){
			break;
		}
		x+=cos(kk)*a1;
		y+=sin(kk)*a1;
		
		kk-=(double)a2/180*pi;
	}
	printf("%.0lf\n%.0lf\n",x,y);
}

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

#define PI (3.141592)

int main()
{
	int hosu, angle,angleplus;
	angle = 0;
	double x = 0,y=0;
	char c;
	while( cin >> hosu >> c >> angleplus ) {
		if( hosu == 0 && angleplus == 0 )
			break;
		x += hosu * sin(angle * PI / 180 );
		y += hosu * cos(angle * PI / 180 );
		angle += angleplus;
		
	}
	printf("%d\n%d",(int)x,(int)y);

	return 0;
}