Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		m, _ := strconv.Atoi(scanner.Text())
		if m == 0 {
			break
		}
		args1 := make([]float64, m)
		x := 0.0
		for i := 0; i < m-1; i++ {
			scanner.Scan()
			tmp, _ := strconv.ParseFloat(scanner.Text(), 64)
			x += tmp
			args1[i] = tmp
		}
		args1[m-1] = 360-x
		first_object := 0.0
		for _, v := range args1 {
			first_object+= math.Abs(math.Sin(v))
		}
		scanner.Scan()
		n, _ := strconv.Atoi(scanner.Text())
		args2 := make([]float64, n)
		y := 0.0
		for i := 0; i < n-1; i++ {
			scanner.Scan()
			tmp, _ := strconv.ParseFloat(scanner.Text(), 64)
			y += tmp
			args2[i] = tmp
		}
		args2[n-1] = 360-y
		second_object := 0.0
		for _, v := range args2 {
			second_object+= math.Abs(math.Sin(v))
		}
		if first_object < second_object {
			fmt.Println(2)
		} else if first_object == second_object {
			fmt.Println(0)
		} else if first_object > second_object {
			fmt.Println(1)
		}
	}
}

C++: #include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) REP((i),0,(n))
#define RREP(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define rrep(i,n) RREP(i,n,0)
#define each(it,X) for(__typeof((X).begin())  it=(X).begin();it!=(X).end();it++)
#define all(v) ((v).begin(),(v).end())
#define fi first
#define se second
#define pb push_back
typedef pair<int,int>pr;
typedef vector<int>vi;
typedef vector<vi>vvi;
typedef set<int>si;
const int INF=1070000000ll;
const int mod=1000000007ll;
const double EPS=1e-9;
const double PI=3.14159265;
double getS(int x){
    int d=360;
    double S=0;
    rep(i,x-1){
        int z;cin>>z;
        d-=z;
        S+=fabs(sin(1.0*z/180*PI));
    }
    S+=fabs(sin(1.0*d/180*PI));
    return S;
}
signed main(){
    cin.tie(0);ios_base::sync_with_stdio(0);
    double S[2];

    int x;
    while(cin>>x,x){
        S[0]=getS(x);
        cin>>x;
        S[1]=getS(x);
        if(fabs(S[0]-S[1])<EPS)cout<<0<<endl;
        else if(S[0]>S[1])cout<<1<<endl;
        else cout<<2<<endl;
    }
    return 0;
}

C++: #include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
#define PI 3.141592653589793238462643L
int K[100000];
long double SIN(long double b) { return sinl(b * PI / 180.0L); }
int main() {
	int N, cnt = 0; long double a, sum, s[2], V;
	while (cin >> N) {
		for (int i = 0; i < 2; i++) {
			if (i == 1) { cin >> N; } V = 0.0L; sum = 0.0L;
			for (int i = 0; i < N - 1; i++) { cin >> a; sum += SIN(a); V += a; }
			sum += sin(360.0L - V); s[i] = sum;
		}
		if (s[0] == s[1]) { cout << '0' << endl; }
		if (s[0] > s[1]) { cout << '1' << endl; }
		if (s[0] < s[1]) { cout << '2' << endl; }
	}
	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<complex>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef complex<double> P;

int main(){
  int n;
  while(cin>>n, n){
    int sum = 0;
    int ang;
    double s1 = 0.0, s2 = 0.0;
    REP(i,n-1){
      cin>>ang;
      sum += ang;
      s1 += sin(ang/180.0);
    }
    s1 += sin((360-sum)/180.0);

    int m;
    cin >> m;
    sum = 0;
    REP(i,m-1){
      cin>>ang;
      sum += ang;
      s2 += sin(ang/180.0);
    }
    s2 += sin((360-sum)/180.0);

    if(s1 == s2) puts("0");
    else if(s1 > s2) puts("1");
    else puts("2");
  }
  return 0;
}

C++: // 2014/06/03 Tazoe

#include <iostream>
#include <cmath>
using namespace std;

int main()
{
	while(true){
		int m;
		cin >> m;

		if(m==0)
			break;

		double S1 = 0.0;
		int V1 = 360;

		for(int i=0; i<m-1; i++){
			int v;
			cin >> v;

			S1 += sin((double)v*M_PI/180.0);
			V1 -= v;
		}

		S1 += sin((double)V1*M_PI/180.0);

		int n;
		cin >> n;

		double S2 = 0.0;
		int V2 = 360;

		for(int i=0; i<n-1; i++){
			int v;
			cin >> v;

			S2 += sin((double)v*M_PI/180.0);
			V2 -= v;
		}

		S2 += sin((double)V2*M_PI/180.0);

		if(S1==S2){
			cout << 0 << endl;
		}
		else if(S1>S2){
			cout << 1 << endl;
		}
		else{
			cout << 2 << endl;
		}
	}

	return 0;
}

C++: #include<cmath>
#include<cstring>
#include<string>
#include<cstdio>
#include<algorithm>
#include<map>
#include<queue>
#include<iostream>
using namespace std;
#define EPS (1e-9)
int N,M;
double calc(int an){
  //  int an2 = 180-90;
  double rad = (double)an * M_PI/180.0;
  // double rad2 = (double)(an/2.0) * M_PI/190.0;
  //return sqrt(2.0-cos(rad)*2.0);
  return 0.5*sin(rad);
}
bool equal(double a,double b){ return abs(a-b) < EPS; }
int main(){
  while(cin >> N && N ){
    double a1=0.0,a2=0.0;
    int an,suman=0;
    for(int i=0;i<N-1;i++){
      cin >> an;
      //cout << "an " <<calc(an) << endl;
      a1 += calc(an);
      suman+=an;
    }
    a1 += calc(360-suman);
    cin >> M;
    suman = 0;
    for(int i=0;i<M-1;i++){
      cin >> an;
      //    cout << "an " <<calc(an) << endl;
      a2 += calc(an);
      suman += an;
    }
    a2 += calc(360-suman);
    //    cout << a1 << " " <<a2<<endl;
    if( equal(a1,a2) ) cout << 0 << endl;
    else if( a1 > a2 ) cout << 1 << endl;
    else cout << 2 <<endl;
  }
}

C++: #include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

const double EPS=1e-10;

int main()
{
	for(int m,n;cin>>m,m;){
		vi a(m,180);
		rep(i,m-1){
			cin>>a[i];
			a[m-1]-=a[i];
		}
		cin>>n;
		vi b(n,180);
		rep(i,n-1){
			cin>>b[i];
			b[n-1]-=b[i];
		}
		
		double sa=0,sb=0;
		rep(i,m)
			sa+=sin(a[i]*M_PI/180);
		rep(i,n)
			sb+=sin(b[i]*M_PI/180);
		
		if(abs(sa-sb)<EPS)
			cout<<0<<endl;
		else if(sa>sb)
			cout<<1<<endl;
		else
			cout<<2<<endl;
	}
	
	return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

#define EPS (1e-5)

double conv(double dosu) {
  return dosu*M_PI/180.0;
}

int main() {
  int M;
  
  while(cin >> M && M) {
    double sum = 0.0;
    double S = 0.0;
    for(int i=0; i<M-1; i++) {
      double arg; cin >> arg;
      S += sin(conv(arg));
      sum += arg;
    }
    S += sin(conv(360-sum));
    
    int N; cin >> N;
    sum = 0;
    double T = 0.0;
    for(int i=0; i<N-1; i++) {
      double arg; cin >> arg;
      T += sin(conv(arg));
      sum += arg;
    }
    T += sin(conv(360-sum));
    
    if(fabs(S-T) < EPS) cout << 0 << endl;
    else if(S > T) cout << 1 << endl;
    else if(S < T) cout << 2 << endl;
  }
  
  return 0;
}