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++: /*
NOTE :
*min_element(.begin(),.end())
*max_element(.begin(),.end())
stack push pop top
queue push pop front
priority_queue<> pq
 push()  pop() size()  top()
map<>
 find() begin() end() insert(map<>::value_type())
pair<>
sort(.begin(), .end())
sort(arr, arr+N)
sort(a, a+N, greater<int>())
binary_search(vc.begin(), vc.end(), x)  //binary_search???true, false?????????
vector<int>::iterator lit = lower_bound(vc.begin(), vc.end(), x);
  lower_bound?????????????????????"??\???"????????????????????????????????????????????¬???????????????
vector<int>::iterator uit = upper_bound(vc.begin(), vc.end(), x);
  upper_bound????????????????????????"?¶???????"?????????????????????????????????????????¬???????????????
*/
#include <iostream>
#include <cstdio>
#include <climits>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <valarray>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>

#define MAX 100
#define INF 1<<20
#define LLINF 10e12 // 1<<31 // 2^31
#define REP(i,n) for(int i=0;i<n;i++)
#define REP2(i,a,n) for(int i=(a);i<(n);i++)
#define SET(a,c) memset(a,c,sizeof a)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FOREACH(i,c) for(auto (i) : (c))
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique(ALL((o))), (o).end());

using namespace std;
typedef long long ll;
typedef valarray<int> array_t;
/////

/////
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  // FROM HERE
  double x = 0, y = 0;
  int a, b, r = 0;
  while(scanf("%d,%d",&a,&b),a|b)
  {
      y += a * cos(1.0*r*M_PI/180);
      x += a * sin(1.0*r*M_PI/180);
      r += b;
  }
  printf("%d\n%d\n",(int)x,(int)y);
  return 0;
}

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

#define PI 3.14159265359
using namespace std;

int main(){
	int n,r;
	char c;
	double nx=0,ny=0;
	int nr=90;
	while(cin>>n>>c>>r &&n+r){
		nx+=cos(nr*PI/180.0)*n;
		ny+=sin(nr*PI/180.0)*n;
		nr+=-1*r;
	}
	
	cout<<(int)nx<<endl<<(int)ny<<endl;
}

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

using namespace std;

int main(){
  int d,t;
  char c;
  double x=0.0, y=0.0, angle=0.0;


  while( cin>>d>>c>>t && (d||t) ){
    x += (double)( d*sin( angle*M_PI/180.0) );
    y += (double)( d*cos( angle*M_PI/180.0) );
    angle += (double)t;    
  }

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

  return 0;
}

C++: #include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <map>
#include <algorithm>

#define rep(i, j) FOR(i, 0, j)
#define FOR(i, j, k) for(int i = j; i < k; ++i)

using namespace std;

int main(){
  double d, t, x, y, n;
  x = y  = n = 0;
  while(scanf("%lf,%lf", &d, &t) && d && t){
    x += d * sin(n * M_PI / 180);
    y += d * cos(n * M_PI / 180);
    n += t;

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

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

#define PI 3.14159265358979

using namespace std;

int main(){
  int theta,x,theta_sum;
  double x_sum,y_sum;
  x_sum =0;
  scanf("%d,%d",&x,&theta);
  y_sum = (double)x,theta_sum =(double)theta;
  while(1){
    scanf("%d,%d",&x,&theta);
    if(x == 0 && theta == 0) break;
    x_sum += (double)x * sin(double(theta_sum * PI / 180.00));
    y_sum += (double)x * cos(double(theta_sum * PI / 180.00));
    theta_sum += theta;
  }

  cout << (int)x_sum << endl << (int)y_sum << endl;

  return 0;

}

C++: #include <cstdio>
#include <cmath>
int main(){
	int a,d=0,di;
	float x=0,y=0;
	scanf("%d,%d",&a,&d);
	if(a==0 && d==0){
		printf("0\n0\n");
	}
	else{
		y+=a;
		while(1){
			scanf("%d,%d",&a,&di);
			if(a==0 && di==0)
				break;
			y+=a*cos(M_PI*d/180);
			x+=a*sin(M_PI*d/180);
			d+=di;
		}
		printf("%d\n%d\n",(int)x, (int)y);
	}
	return 0;
}

C++: //Aizu - 0016 : Treasure Hunt
#include<stdio.h>
#include<math.h>

typedef long double ldouble;

const ldouble PI = acos(-1.0);
const ldouble eps = 1e-12;

int main()
{
	int d,t;
	ldouble x=0,y=0;
    int dir = 0;
	while(scanf("%d%*c%d", &d, &t) &&d!=0&&t!=0)			//霎灘?0,0扈捺據
	{
	    while(dir >= 360) dir -= 360;
	    while(dir < 0) dir += 360;
		x += d*sin(((ldouble)dir) / 180.0 * PI);						//隶。邂?		y += d*cos(((ldouble)dir) / 180.0 * PI);
	    dir += t;
	}
    long long ox, oy;
    ox = x, oy = y;
	printf("%lld\n%lld\n", ox, oy);					//霎灘?

	return 0;
}

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

const double rad = (3.14159265 / 180);

int main(){

	int m, angle, sumangle = 0;
	double x = 0, y = 0;

	char c;

	while (std::cin >> m >> c >> angle, m || angle){

		x += (std::cos((90 - sumangle)*rad)*m);
		y += (std::sin((90 - sumangle)*rad)*m);
		sumangle += angle;
	}

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

	return 0;
}

C++: #include <iostream>
#include <math.h>
using namespace std;
int main(){
int step,turn;
double x=0,y=0,angle;
while(cin>>step>>turn,step,turn){
x+=(double)step*sin(angle*M_PI/180);
y+=(double)step*cos(angle*M_PI/180);
angle+=(double)turn;
}

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

C++: #include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    int a,b;
    double x = 0,y = 0;
    int arg = 90;
    char s;
    while(cin >> a >> s >> b,a or b){
        x += a * cos(arg * acos(-1) /180);
        y += a * sin(arg * acos(-1) /180);
        arg -= b;
        arg = (arg+360) % 360;
    }
    cout << (int)x << endl << (int) y << endl;
}

C++: #include <iostream>
#include <string>
#include <math.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;
}