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++: //Aizu - 0016 : Treasure Hunt
#include<stdio.h>
#include<math.h>

const double PAI = acos(-1.0);
//#define PAI 3.1415926

int main()
{
	int d,t,ang=0;
	double x=0,y=0;

	while(scanf("%d,%d",&d,&t)&&(!(d==0&&t==0)))			//霎灘?0,0扈捺據
	{
		x+=d*sin(1.0*PAI*ang/180);						//隶。邂?		y+=d*cos(1.0*PAI*ang/180);
		ang+=t;
	}

	printf("%d\n%d\n",(int)x,(int)y);					//霎灘?

	return 0;
}

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

#define PI 3.1415926535898
#define ANGLE (PI/180.0)
int main() {
  int step,dir;
  double x=0.0, y=0.0, angle=0.0;
  
  while(1){
    scanf("%d,%d", &step, &dir);
    if(step==0 && dir==0) break;
    x += (double)(step) * sin(angle * ANGLE);
    y += (double)(step) * cos(angle * ANGLE);
    angle += (double)dir;
  }
  printf("%d\n%d\n", (int)x, (int)y);
  return 0;
}

C++: #include<stdio.h>
#include<math.h>
double na;
double nx,ny;

int main(){
	int d;
	int a;
	na=90;
	nx=0;
	ny=0;
	while(1){
		scanf("%d,%d",&d,&a);
		if(d==0&&a==0)break;
		nx+=(double)d*cos(M_PI*na/180);
		ny+=(double)d*sin(M_PI*na/180);
		na-=a;
	}
	printf("%d %d\n",(int)nx,(int)ny);
}

C++: #include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <stdlib.h>

using namespace std;


int main(){
	int r, n_ang;
	int ang=0;
	double x=0, y=0;

	while(1){
		scanf("%d,%d", &r, &n_ang);
		if(r==0 && n_ang==0){
			break;
		}else{
			y += r * cos(M_PI*ang/180);
			x += r * sin(M_PI*ang/180);
		}
		ang += n_ang;

	}

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

	return 0;
}

C++: #include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
using namespace std;
#define PI 3.141592
int main(){
  double angle;
  double x=0,y=0;
  double d,t;
  string str;
  cin >> str;
  if(str[1]==','){
    d= str[0]-'0';
    if(str[2]=='-'){
      if(str.size()==4) t = (str[3]-'0')*(-1);
      else t = ((str[3]-'0')*10+(str[4]-'0'))*(-1);
    }else{
      if(str.size()==3) t = str[2]-'0';
      else t = (str[2]-'0')*10+(str[3]-'0');
    }
  }else if(str[2]==','){
    d= (str[0]-'0')*10+str[1]-'0';
    if(str[3]=='-'){
      if(str.size()==5) t = (str[4]-'0')*(-1);
      else t = ((str[4]-'0')*10+(str[5]-'0'))*(-1);
    }else{
      if(str.size()==4) t = str[3]-'0';
      else t = (str[3]-'0')*10+(str[4]-'0');
    }
  }else if(str[3]==','){
    d= (str[0]-'0')*100+(str[1]-'0')*10+(str[2]-'0');
    if(str[4]=='-'){
      if(str.size()==6) t = (str[5]-'0')*(-1);
      else t = ((str[5]-'0')*10+(str[6]-'0'))*(-1);
    }else{
      if(str.size()==5) t = str[4]-'0';
      else t = (str[4]-'0')*10+(str[5]-'0');
    }
  }
  while(d!=0||t!=0){
    x+=d*sin(angle/180*PI);y+=d*cos(angle/180*PI);
    angle+=t;
    if(angle>360) angle-=360;
    if(angle<-360) angle+=360;
    cin >> str;
    if(str[1]==','){
      d= str[0]-'0';
      if(str[2]=='-'){
	if(str.size()==4) t = (str[3]-'0')*(-1);
	else t = ((str[3]-'0')*10+(str[4]-'0'))*(-1);
      }else{
	if(str.size()==3) t = str[2]-'0';
	else t = (str[2]-'0')*10+(str[3]-'0');
      }
    }else if(str[2]==','){
      d= (str[0]-'0')*10+str[1]-'0';
      if(str[3]=='-'){
	if(str.size()==5) t = (str[4]-'0')*(-1);
	else t = ((str[4]-'0')*10+(str[5]-'0'))*(-1);
    }else{
	if(str.size()==4) t = str[3]-'0';
	else t = (str[3]-'0')*10+(str[4]-'0');
      }
    }else if(str[3]==','){
      d= (str[0]-'0')*100+(str[1]-'0')*10+(str[2]-'0');
      if(str[4]=='-'){
	if(str.size()==6) t = (str[5]-'0')*(-1);
	else t = ((str[5]-'0')*10+(str[6]-'0'))*(-1);
      }else{
	if(str.size()==5) t = str[4]-'0';
	else t = (str[4]-'0')*10+(str[5]-'0');
      }
    }
  }
  int x1=x,y1=y;
  printf("%d\n%d\n",x1,y1);
  return 0;
}

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

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

	while (true)
	{
		scanf("%d,%d", &a, &b);
		if (a + b == 0) break;
		x += a * cos(d * 3.14159 / 180);
		y += a * sin(d * 3.14159 / 180);
		d -= b;
	}
	printf("%d\n", (int)x);
	printf("%d\n", (int)y);

	return 0;
}

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

using namespace std;

int main() {
	double x = 0.0, y = 0.0;
	int deg = 90;
	while (1) {
		int r, t;
		scanf("%d,%d", &r, &t);
		if (!r&&!t)
			break;
		x += r * cos(deg*M_PI/180.0);
		y += r * sin(deg*M_PI/180.0);
		deg -= t;
	}
	printf("%d\n%d\n", (int)x, (int)y);
	return 0;
}

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("%d,%d", &a, &b), a&&b){
		y += a*sin(radius*M_PI/180);
		x += a*cos(radius*M_PI/180);
		radius += b;
	}
	y *= 10;
	int y_ = y;
	y_ %= 10;
	y_ /= 10;

	x *= 10;
	int x_ = x;
	x_ %= 10;
	x_ /= 10;

	cout << (int)y_ << endl << (int)x_ << endl;                                                        
	return 0;
}

C++: #include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define EXIST(v,i) (find(all(v), i) != (v).end())
#define ERASE(v,i) (v).erase(remove(all(v), i), (v).end())
#define INDEX(v,i) (find(all(v), i) - (v).begin())
#define rep(i,n) for(int i = 0; i < (int)n; ++i)
#define debug(x) cerr << #x << " = " << (x) << endl;

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();}

const int INF = 100000000;
const double PI = 3.14159265358979323846;
const double EPS = 1e-10;

int main() {
	double cx = 0, cy = 0;
	int angle = 90;
	for(int l, r; ~scanf(" %d,%d", &l, &r) && l && r;) {
		double rad = 3.141592653589793 * angle / 180;
		cx += l * cos(rad);
		cy += l * sin(rad);
		angle -= r;
#if 0
		cout << "before" << endl;
		cout << rad << endl;
		cout << cx << endl;
		cout << cy << endl;
		cout << "after" << endl;
#endif
	}
	printf("%.0f\n%.0f\n", cx, cy);
	return 0;
}

C++: // #include<iostream>
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using ld=long double;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    char c;
    int a,b;
    ld x=0, y=0;
    int deg=90;
    // cout << cosl(3.14) << endl;
    while(cin >> a>>c>>b, a|b){
      ld ar = deg*acosl(-1)/180;
      x+=a*cosl(ar);
      y+=a*sinl(ar);
      deg-=b;
    }
    cout << int(x) << endl;
    cout << int(y) << endl;
    return 0;
}