#include <bits/stdc++.h>

using namespace std;

namespace geometry
{	
	typedef double D;
	typedef complex<D> P;
	typedef pair<P, P> S;
	typedef S L;
	typedef pair<P, D> C;
	
	#define PI			(acos(-1))
	#define EPS 		(1e-10)
	#define EQ(a, b) 	(abs((a) - (b)) < EPS)
	#define EQV(a, b) 	(EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()))
	
	static const int COUNTER_CLOCKWISE 	=  1;
	static const int CLOCKWISE			= -1;
	static const int ONLINE_BACK		=  2;
	static const int ONLINE_FRONT		= -2;
	static const int ON_SEGMENT			=  0;
	
	D norm(P a) { return a.real() * a.real() + a.imag() * a.imag(); }
	
	D dot(P a, P b) { return a.real() * b.real() + a.imag() * b.imag(); }
	D cross(P a, P b) { return a.real() * b.imag() - a.imag() * b.real(); }
	
	bool isOrthogonal(P a1, P a2, P b1, P b2) { return EQ(dot(a1 - a2, b1 - b2), 0.0); }
	bool isOrthogonal(L a, L b) { return isOrthogonal(a.first, a.second, b.first, b.second); }
	bool isParallel(P a1, P a2, P b1, P b2) { return EQ(cross(a1 - a2, b1 - b2), 0.0); }
	bool isParallel(L a, L b) { return isParallel(a.first, a.second, b.first, b.second); }
	
	bool isPointOnLine(P a, P b, P c) { return EQ(cross(b - a, c - a), 0.0); }
	bool isPointOnLine(L a, P b) { return isPointOnLine(a.first, a.second, b); }
	bool isPointOnSegment(P a, P b, P c) {
		return EQ(cross(b - a, c - a), 0.0) &&
		       (dot(b - a, c - a) > -EPS) &&
			   (dot(a - b, c - b) > -EPS);
	}
	bool isPointOnSegment(S a, P b) { return isPointOnLine(a.first, a.second, b); }
	
	bool intersect(P a1, P a2, P b1, P b2) {
		return (cross(a2 - a1, b1 - a1) * cross(a2 - a1, b2 - a1) < EPS) &&
		       (cross(b2 - b1, a1 - b1) * cross(b1 - b1, a2 - b1) < EPS);
	}
	bool intersect(S a, S b){
		return intersect(a.first, a.second, b.first, b.second);
	}
	
	int ccw(P p0, P p1, P p2){
		P a = p1 - p0;
		P b = p2 - p0;
		if (cross(a, b) > EPS) 	return COUNTER_CLOCKWISE;
		if (cross(a, b) < -EPS) return CLOCKWISE;
		if (dot(a, b) < -EPS)	return ONLINE_BACK;
		if (norm(a) < norm(b))	return ONLINE_FRONT;
		return ON_SEGMENT;
	}
	
	D distanceLP(P a, P b, P c) { return abs(cross(b - a, c - a)) / abs(b - a); }
	D distanceLP(L a, P b) { return distanceLP(a.first, a.second, b); }
	D distanceSP(P a, P b, P c) {
		if (dot(b - a, c - a) < EPS) return abs(c - a);
		if (dot(a - b, c - b) < EPS) return abs(c - b);
		return abs(cross(b - a, c - a)) / abs(b - a);
	}
	D distanceSP(S a, P b) { return distanceSP(a.first, a.second, b); }
	
	bool intersectCL(C c, L l){
		return c.second - distanceLP(l, c.first) > -EPS;
	}
	bool intersectCS(C c, S s){
		if (EQ(c.second - abs(c.first - s.first), 0.0) ||
			EQ(c.second - abs(c.first - s.second), 0.0)) return true;
		if (c.second - distanceSP(s, c.first) > -EPS){
			return (c.second - abs(c.first - s.first) < EPS ||
				    c.second - abs(c.first - s.second) < EPS);
		}
		return false;
	}
	
	P project(S s, P p){
		P base = s.second - s.first;
		D r = dot(p - s.first, base) / norm(base);
		return s.first + base * r;
	}
	P reflect(S s, P p){
		return p + (project(s, p) - p) * (D)2.0;
	}
	
	P crossPoint(S s1, S s2){
		P base = s2.second - s2.first;
		D d1 = abs(cross(base, s1.first - s2.first));
		D d2 = abs(cross(base, s1.second - s2.first));
		D t = d1 / (d1 + d2);
		return s1.first + (s1.second - s1.first) * t;
	}
	
	void debug(P p){
		printf("x: %f, y: %f\n", p.real(), p.imag()); 
	}
	void debug(C c){
		printf("x: %f, y: %f, r: %f\n", c.first.real(), c.first.imag(), c.second);
	}
	void debug(S s){
		printf("{\n");
		printf("    ");
		debug(s.first);
		printf("    ");
		debug(s.second);
		printf("}\n");
	}
	void debug(vector<P> poly){
		printf("{\n");
		for (int i = 0; i < poly.size(); i++){
			printf("    ");
			debug(poly[i]);
		}
		printf("}\n");
	}
}

using namespace geometry;

int main()
{
	int n[2];
	while (true){
		int c[2] = {360, 360};
		D s[2] = {0.0, 0.0};
		for (int p = 0; p < 2; p++){
			scanf("%d", &n[p]);
			if (!n[p]) return 0;
			for (int i = 0; i < n[p] - 1; i++){
				int a;
				scanf("%d", &a);
				s[p] += sin((double)a / 180 * PI);
				c[p] -= a;
			}
			s[p] += sin((double)c[p] / 180 * PI);
		}
		//printf("%f %f\n", s[0], s[1]);
		if (EQ(s[0], s[1])) puts("0");
		else if (s[0] > s[1]) puts("1");
		else puts("2");
	}
}
### Prompt

Develop a solution in cpp to the problem described below:

Create a program that inputs the vertex information of two polygons inscribed in one circle and outputs the magnitude relationship of their areas.

Assume that each vertex of the X-side is numbered counterclockwise from 1 to X (the figure shows an example when X = 4). However, the given polygon assumes that the center of the circle is contained inside, and the data on the position of vertex i is the angle v (1 ≤ v <180) of the central angle measured counterclockwise from vertex i to vertex i + 1. Integer). Regarding the magnitude relationship to be output, 1 (half-width number) when the area of ​​the first polygon is large, 2 (half-width number) when the area of ​​the second polygon is large, and when the areas are the same, Please output 0 (half-width number).

<image>



Input

A sequence of multiple datasets is given as input. The end of the input is indicated by a single line of zeros. Each dataset is given in the following format:


m
v1
v2
::
vm −1
n
v1
v2
::
vn − 1


The first line gives the number of vertices of the first polygon m (3 ≤ m ≤ 50), and the following m − 1 line gives the information vi (1 ≤ vi <180) of the vertices i of the first polygon. ..

The following line gives the number of vertices n (3 ≤ n ≤ 50) of the second polygon, and the following n − 1 line gives the information vi (1 ≤ vi <180) for the vertices i of the second polygon.

The number of datasets does not exceed 200.

Output

Outputs the magnitude relationship (half-width numbers) for each data set on one line.

Example

Input

4
30
125
75
4
30
125
75
5
30
125
75
65
4
30
125
75
4
30
125
75
6
30
50
50
25
75
0


Output

0
1
2

### Response

```cpp
#include <bits/stdc++.h>

using namespace std;

namespace geometry
{	
	typedef double D;
	typedef complex<D> P;
	typedef pair<P, P> S;
	typedef S L;
	typedef pair<P, D> C;
	
	#define PI			(acos(-1))
	#define EPS 		(1e-10)
	#define EQ(a, b) 	(abs((a) - (b)) < EPS)
	#define EQV(a, b) 	(EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()))
	
	static const int COUNTER_CLOCKWISE 	=  1;
	static const int CLOCKWISE			= -1;
	static const int ONLINE_BACK		=  2;
	static const int ONLINE_FRONT		= -2;
	static const int ON_SEGMENT			=  0;
	
	D norm(P a) { return a.real() * a.real() + a.imag() * a.imag(); }
	
	D dot(P a, P b) { return a.real() * b.real() + a.imag() * b.imag(); }
	D cross(P a, P b) { return a.real() * b.imag() - a.imag() * b.real(); }
	
	bool isOrthogonal(P a1, P a2, P b1, P b2) { return EQ(dot(a1 - a2, b1 - b2), 0.0); }
	bool isOrthogonal(L a, L b) { return isOrthogonal(a.first, a.second, b.first, b.second); }
	bool isParallel(P a1, P a2, P b1, P b2) { return EQ(cross(a1 - a2, b1 - b2), 0.0); }
	bool isParallel(L a, L b) { return isParallel(a.first, a.second, b.first, b.second); }
	
	bool isPointOnLine(P a, P b, P c) { return EQ(cross(b - a, c - a), 0.0); }
	bool isPointOnLine(L a, P b) { return isPointOnLine(a.first, a.second, b); }
	bool isPointOnSegment(P a, P b, P c) {
		return EQ(cross(b - a, c - a), 0.0) &&
		       (dot(b - a, c - a) > -EPS) &&
			   (dot(a - b, c - b) > -EPS);
	}
	bool isPointOnSegment(S a, P b) { return isPointOnLine(a.first, a.second, b); }
	
	bool intersect(P a1, P a2, P b1, P b2) {
		return (cross(a2 - a1, b1 - a1) * cross(a2 - a1, b2 - a1) < EPS) &&
		       (cross(b2 - b1, a1 - b1) * cross(b1 - b1, a2 - b1) < EPS);
	}
	bool intersect(S a, S b){
		return intersect(a.first, a.second, b.first, b.second);
	}
	
	int ccw(P p0, P p1, P p2){
		P a = p1 - p0;
		P b = p2 - p0;
		if (cross(a, b) > EPS) 	return COUNTER_CLOCKWISE;
		if (cross(a, b) < -EPS) return CLOCKWISE;
		if (dot(a, b) < -EPS)	return ONLINE_BACK;
		if (norm(a) < norm(b))	return ONLINE_FRONT;
		return ON_SEGMENT;
	}
	
	D distanceLP(P a, P b, P c) { return abs(cross(b - a, c - a)) / abs(b - a); }
	D distanceLP(L a, P b) { return distanceLP(a.first, a.second, b); }
	D distanceSP(P a, P b, P c) {
		if (dot(b - a, c - a) < EPS) return abs(c - a);
		if (dot(a - b, c - b) < EPS) return abs(c - b);
		return abs(cross(b - a, c - a)) / abs(b - a);
	}
	D distanceSP(S a, P b) { return distanceSP(a.first, a.second, b); }
	
	bool intersectCL(C c, L l){
		return c.second - distanceLP(l, c.first) > -EPS;
	}
	bool intersectCS(C c, S s){
		if (EQ(c.second - abs(c.first - s.first), 0.0) ||
			EQ(c.second - abs(c.first - s.second), 0.0)) return true;
		if (c.second - distanceSP(s, c.first) > -EPS){
			return (c.second - abs(c.first - s.first) < EPS ||
				    c.second - abs(c.first - s.second) < EPS);
		}
		return false;
	}
	
	P project(S s, P p){
		P base = s.second - s.first;
		D r = dot(p - s.first, base) / norm(base);
		return s.first + base * r;
	}
	P reflect(S s, P p){
		return p + (project(s, p) - p) * (D)2.0;
	}
	
	P crossPoint(S s1, S s2){
		P base = s2.second - s2.first;
		D d1 = abs(cross(base, s1.first - s2.first));
		D d2 = abs(cross(base, s1.second - s2.first));
		D t = d1 / (d1 + d2);
		return s1.first + (s1.second - s1.first) * t;
	}
	
	void debug(P p){
		printf("x: %f, y: %f\n", p.real(), p.imag()); 
	}
	void debug(C c){
		printf("x: %f, y: %f, r: %f\n", c.first.real(), c.first.imag(), c.second);
	}
	void debug(S s){
		printf("{\n");
		printf("    ");
		debug(s.first);
		printf("    ");
		debug(s.second);
		printf("}\n");
	}
	void debug(vector<P> poly){
		printf("{\n");
		for (int i = 0; i < poly.size(); i++){
			printf("    ");
			debug(poly[i]);
		}
		printf("}\n");
	}
}

using namespace geometry;

int main()
{
	int n[2];
	while (true){
		int c[2] = {360, 360};
		D s[2] = {0.0, 0.0};
		for (int p = 0; p < 2; p++){
			scanf("%d", &n[p]);
			if (!n[p]) return 0;
			for (int i = 0; i < n[p] - 1; i++){
				int a;
				scanf("%d", &a);
				s[p] += sin((double)a / 180 * PI);
				c[p] -= a;
			}
			s[p] += sin((double)c[p] / 180 * PI);
		}
		//printf("%f %f\n", s[0], s[1]);
		if (EQ(s[0], s[1])) puts("0");
		else if (s[0] > s[1]) puts("1");
		else puts("2");
	}
}
```