#include <bits/stdc++.h>
using namespace std;
typedef double db;
const db eps=1e-6;
int sign(db k){if (k>eps) return 1; else if (k<-eps) return -1; return 0;}
int cmp(db k1,db k2){return sign(k1-k2);}
struct point{
    db x,y;
    point operator + (const point &k1) const{return (point){k1.x+x,k1.y+y};}
    point operator - (const point &k1) const{return (point){x-k1.x,y-k1.y};}
    point operator * (db k1) const{return (point){x*k1,y*k1};}
    point operator / (db k1) const{return (point){x/k1,y/k1};}
    bool operator < (const point k1) const{
        int a=cmp(x,k1.x);
        if (a==-1) return 1; else if (a==1) return 0; else return cmp(y,k1.y)==-1;
    }
    int getP() const{return sign(y)==-1||(sign(y)==0&&sign(x)==-1);}
};
db cross(point k1,point k2){return k1.x*k2.y-k1.y*k2.x;}
db dot(point k1,point k2){return k1.x*k2.x+k1.y*k2.y;}
int compareangle (point k1,point k2){
    return k1.getP()<k2.getP()||(k1.getP()==k2.getP()&&sign(cross(k1,k2))>0);
}
point getLL(point k1,point k2,point k3,point k4){
    db w1=cross(k1-k3,k4-k3),w2=cross(k4-k3,k2-k3); return (k1*w2+k2*w1)/(w1+w2);
}
struct line{
    point p[2];
    line(point k1,point k2){p[0]=k1; p[1]=k2;}
    line(){};
    point& operator [] (int k){return p[k];}
    int include(point k){return sign(cross(p[1]-p[0],k-p[0]))>=0;}//非严格包含。
    point dir(){return p[1]-p[0];}
};
point getLL(line k1,line k2){return getLL(k1[0],k1[1],k2[0],k2[1]);}
int parallel(line k1,line k2){return sign(cross(k1.dir(),k2.dir()))==0;}
int sameDir(line k1,line k2){return parallel(k1,k2)&&sign(dot(k1.dir(),k2.dir()))==1;}
int operator < (line k1,line k2){
    if (sameDir(k1,k2)) return k2.include(k1[0]);
    return compareangle(k1.dir(),k2.dir());
}
int checkpos(line k1,line k2,line k3){return k3.include(getLL(k1,k2));}
vector<line> getHL(vector<line> &L){ // 求半平面交 , 半平面是逆时针方向 , 输出按照逆时针
    sort(L.begin(),L.end()); deque<line> q;
    for (int i=0;i<(int)L.size();i++){
        if (i&&sameDir(L[i],L[i-1])) continue;
        while (q.size()>1&&!checkpos(q[q.size()-2],q[q.size()-1],L[i])) q.pop_back();
        while (q.size()>1&&!checkpos(q[1],q[0],L[i])) q.pop_front();
        q.push_back(L[i]);
    }
    while (q.size()>2&&!checkpos(q[q.size()-2],q[q.size()-1],q[0])) q.pop_back();
    while (q.size()>2&&!checkpos(q[1],q[0],q[q.size()-1])) q.pop_front();
    vector<line>ans; for (int i=0;i<q.size();i++) ans.push_back(q[i]);
    return ans;
}
int checkLL(point k1,point k2,point k3,point k4){// 求直线 (L) 线段 (S)k1,k2 和 k3,k4 的交点
    return cmp(cross(k3-k1,k4-k1),cross(k3-k2,k4-k2))!=0;
}
int checkLL(line k1,line k2){
    return checkLL(k1.p[0],k1.p[1],k2.p[0],k2.p[1]);
}
db area(vector<point> A){ // 多边形用 vector<point> 表示 , 逆时针
    db ans=0;
    for (int i=0;i<A.size();i++) ans+=cross(A[i],A[(i+1)%A.size()]);
    return ans/2;
}
vector<point> convexHull(vector<point>ps){
    int n = ps.size();if(n<=1)return ps;
    sort(ps.begin(),ps.end());
    vector<point> qs(n*2);int k=0;
    for(int i=0;i<n;qs[k++]=ps[i++])
        while (k>1&&sign(cross(qs[k-1]-qs[k-2],ps[i]-qs[k-2]))<=0)--k;
    for(int i=n-2,t=k;i>=0;qs[k++]=ps[i--])
        while (k>t&&sign(cross(qs[k-1]-qs[k-2],ps[i]-qs[k-2]))<=0)--k;
    qs.resize(k-1);
    return qs;
}
int t,n;
point p[400005];
vector<line> l;
vector<point> v;

void add(const point& x,const point& y){
    if (sign(cross(y-x,(point){0,0}-x)>0)) l.push_back(line(x,y));
    else l.push_back(line(y,x));
}
int main(){
    scanf("%d",&t);
    while (t--){
        l.clear();v.clear();
        scanf("%d",&n);
        for(int i=0;i<n;i++){
            scanf("%lf%lf",&p[i].x,&p[i].y);
        }
        for(int i=1;i<n;i++)v.push_back(p[i]-p[0]);
        sort(v.begin(),v.end(),compareangle);
        int m = v.size();bool f=1;
        for(int i=0;i<m;i++)v.push_back(v[i]);
        for(int i=0;i<m&&f;i++)if(sign(cross(v[i],v[i+1]))==0)f=0;
        if(!f){printf("0\n");continue;}
        l.push_back(line((point){1e6,-1e6}-p[0],(point){1e6,1e6}-p[0]));
        l.push_back(line((point){1e6,1e6}-p[0],(point){-1e6,1e6}-p[0]));
        l.push_back(line((point){-1e6,1e6}-p[0],(point){-1e6,-1e6}-p[0]));
        l.push_back(line((point){-1e6,-1e6}-p[0],(point){1e6,-1e6}-p[0]));
        int j=0,p=0;
        for(int i=0;i<m;i++){
            add(v[i],v[i+1]);
            while (j<=i||(j<i+m&&sign(cross(v[i],v[j]))>0))j++;
            if(j<i+m)add(v[i],v[j]);
//            if(sign(cross(v[i+1]-v[i],(point){0,0}-v[i]))<0) l.push_back(line(v[i+1],v[i]));
//            else l.push_back(line(v[i],v[i+1]));
//            while (p<=i||(p<i+m&&sign(cross(v[i],v[p]))>0))p++;
//            if(p<i+m){
//                if(sign(cross(v[p]-v[i],(point){0,0}-v[i]))>0)l.push_back(line(v[i],v[p]));
//                else l.push_back(line(v[p],v[i]));
//            }
        }
        l=getHL(l);
        if(l.size()<3){printf("0\n");continue;}
        v.clear();
        m=l.size();
        for(int i=0;i<m;i++)v.push_back(getLL(l[i],l[(i+1)%m]));
//        v=convexHull(v);
        db s = area(v);
        printf("%.11f\n",s);
    }
}


//----------------------------------------------------------------
//OMLBEGIN: 2D Vectors
#include<vector>
#include<cmath>
#include<iostream>
using namespace std;

const long double PI = acos(-1.0L);

struct Vec {
	long double x, y;

	Vec& operator-=(Vec r) {
		x -= r.x, y -= r.y;
		return *this;
	}
	Vec operator-(Vec r) {return Vec(*this) -= r;}

	Vec& operator+=(Vec r) {
		x += r.x, y += r.y;
		return *this;
	}
	Vec operator+(Vec r) {return Vec(*this) += r;}
	Vec operator-() {return {-x, -y};}
	Vec& operator*=(long double r) {
		x *= r, y *= r;
		return *this;
	}
	Vec operator*(long double r) {return Vec(*this) *= r;}
	Vec& operator/=(long double r) {
		x /= r, y /= r;
		return *this;
	}
	Vec operator/(long double r) {return Vec(*this) /= r;}

	long double operator*(Vec r) {
		return x * r.x + y * r.y;
	}
};
ostream& operator<<(ostream& l, Vec r) {
	return l << '(' << r.x << ", " << r.y << ')';
}
long double len(Vec a) {
	return hypot(a.x, a.y);
}
long double cross(Vec l, Vec r) {
	return l.x * r.y - l.y * r.x;
}
long double angle(Vec a) {
	return fmod(atan2(a.y, a.x)+2*PI, 2*PI);
}
Vec normal(Vec a) {
	return Vec({-a.y, a.x}) / len(a);
}
//OMLEND: 2D Vectors
//----------------------------------------------------------------

//----------------------------------------------------------------
//OMLBEGIN: 2D Segments
//Uses: vector2d.h
#include<algorithm>
using namespace std;

struct Segment {
	Vec a, b;
	Vec d() {
		return b-a;
	}
};
ostream& operator<<(ostream& l, Segment r) {
	return l << r.a << '-' << r.b;
}

Vec intersection(Segment l, Segment r) {
	Vec dl = l.d(), dr = r.d();
	if(cross(dl, dr) == 0)
		return {nanl(""), nanl("")};

	long double h = cross(dr, l.a-r.a) / len(dr);
	long double dh = cross(dr, dl) / len(dr);

	return l.a + dl * (h / -dh);
}

//Returns the area bounded by halfplanes
long double getArea(vector<Segment> lines) {
	long double lowerbound = -HUGE_VALL, upperbound = HUGE_VALL;

	vector<Segment> linesBySide[2];
	for(auto line : lines) {
		if(line.b.y == line.a.y) {
			if(line.a.x < line.b.x)
				lowerbound = max(lowerbound, line.a.y);
			else
				upperbound = min(upperbound, line.a.y);
		}
		else if(line.a.y < line.b.y)
			linesBySide[1].push_back(line);
		else
			linesBySide[0].push_back({line.b, line.a});
	}

	sort(linesBySide[0].begin(), linesBySide[0].end(), [](Segment l, Segment r) {
		if(cross(l.d(), r.d()) == 0) return normal(l.d())*l.a > normal(r.d())*r.a;
		return cross(l.d(), r.d()) < 0;
	});
	sort(linesBySide[1].begin(), linesBySide[1].end(), [](Segment l, Segment r) {
		if(cross(l.d(), r.d()) == 0) return normal(l.d())*l.a < normal(r.d())*r.a;
		return cross(l.d(), r.d()) > 0;
	});

	//Now find the application area of the lines and clean up redundant ones
	vector<long double> applyStart[2];
	for(int side = 0; side < 2; side++) {
		vector<long double> &apply = applyStart[side];
		vector<Segment> curLines;

		for(auto line : linesBySide[side]) {
			while(curLines.size() > 0) {
				Segment other = curLines.back();

				if(cross(line.d(), other.d()) != 0) {
					long double start = intersection(line, other).y;
					if(start > apply.back())
						break;
				}

				curLines.pop_back();
				apply.pop_back();
			}

			if(curLines.size() == 0)
				apply.push_back(-HUGE_VALL);
			else
				apply.push_back(intersection(line, curLines.back()).y);
			curLines.push_back(line);
		}

		linesBySide[side] = curLines;
	}
	applyStart[0].push_back(HUGE_VALL);
	applyStart[1].push_back(HUGE_VALL);

	long double result = 0;
	{
		long double lb = -HUGE_VALL, ub;
		for(int i=0, j=0; i < (int)linesBySide[0].size() && j < (int)linesBySide[1].size();lb = ub) {
			ub = min(applyStart[0][i+1], applyStart[1][j+1]);

			long double alb = lb, aub = ub;
			Segment l0 = linesBySide[0][i], l1 = linesBySide[1][j];

			if(cross(l1.d(), l0.d()) > 0)
				alb = max(alb, intersection(l0, l1).y);
			else if(cross(l1.d(), l0.d()) < 0)
				aub = min(aub, intersection(l0, l1).y);
			alb = max(alb, lowerbound);
			aub = min(aub, upperbound);
			aub = max(aub, alb);

			{
				long double x1 = l0.a.x + (alb - l0.a.y) / l0.d().y * l0.d().x;
				long double x2 = l0.a.x + (aub - l0.a.y) / l0.d().y * l0.d().x;
				result -= (aub - alb) * (x1 + x2) / 2;
			}
			{
				long double x1 = l1.a.x + (alb - l1.a.y) / l1.d().y * l1.d().x;
				long double x2 = l1.a.x + (aub - l1.a.y) / l1.d().y * l1.d().x;
				result += (aub - alb) * (x1 + x2) / 2;
			}

			if(applyStart[0][i+1] < applyStart[1][j+1])
				i++;
			else
				j++;
		}
	}
	return result;
}
//OMLEND: 2D Segments
//----------------------------------------------------------------

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

int main() {
	int T;
	cin >> T;

	for(int TCASE = 0; TCASE < T; TCASE++) {
		int n;
		cin >> n;

		try {
			vector<Vec> pts(n);
			for(int i=0;i<n;i++)
				cin >> pts[i].x >> pts[i].y;

			long double lim = 1000000;
			vector<Segment> segs = {{{-lim, -lim}, {lim, -lim}}, {{lim, -lim}, {lim, lim}},
									{{lim, lim}, {-lim, lim}}, {{-lim, lim}, {-lim, -lim}}};

			sort(pts.begin()+1, pts.end(), [&](Vec l, Vec r) {
				return fmod(angle(l-pts[0]), PI) < fmod(angle(r-pts[0]), PI);
			});
			for(int i=1;i<n;i++) {
				int j = (i==n-1 ? 1 : i+1);

				if(cross(pts[j]-pts[i], pts[0]-pts[i]) == 0)
					throw 0.0L;
				else if(cross(pts[j]-pts[i], pts[0]-pts[i]) > 0)
					segs.push_back({pts[i], pts[j]});
				else
					segs.push_back({pts[j], pts[i]});
			}

			throw getArea(segs);
		}
		catch(long double result) {
			cout << fixed << setprecision(7) << result << '\n';
		}
	}

	return 0;
}


#include<string>
/*
      N
    // N//
  ///// ////
 //////N/////
/////y//y/////
///:y//yyy////
 //`////y/////
///``////y////
///NN////y////
///y N///y////
//`y `/`/y///
 ``````//y//
  ````:://
     ::
       --
     N``--
    `N` -
     h -N
    -hhNN
    hhNNNN
   -hhNNNN
   hhNNNNNN-
  hhhNNNNNN
 -   -NNNNNN
 ``NNN-NNNNN
 NNNNNN--NNNN
  -    NN-NNN
     --- N--N
     -     N-
       -    N
      --
      --
      --
       -
       -
    hhh-hh
   hhhNNhhh
    hhhhhh
*/

#include<stdio.h>
#include<set>
#include<assert.h>
#include<queue>
#include<algorithm>
#include<vector>
#include<cmath>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<double, int> pdi;

const double EPS = 1e-8;
const double PI = acos(-1);

double sq(double x){ return x*x; }
ll sq(ll x){ return x*x; }
int sign(ll x){ return x < 0? -1 : x > 0? 1 : 0; }
int sign(int x){ return x < 0? -1 : x > 0? 1 : 0; }
double sign(double x){ return abs(x) < EPS? 0 : x < 0? -1 : 1; }

pii operator+(const pii &l, const pii &r){ return pii(l.first + r.first, l.second + r.second); }
pii operator-(const pii &l, const pii &r){ return pii(l.first - r.first, l.second - r.second); }
ll operator^(const pii &l, const pii &r){ return (ll)l.first * r.second - (ll)l.second * r.first; }
ll operator/(const pii &l, const pii &r){ return (ll)l.first * r.second - (ll)l.second * r.first; }
ll operator*(const pii &l, const pii &r){ return (ll)l.first * r.first + (ll)l.second * r.second; }
pii operator*(const pii &l, const int &r){ return pii(l.first * r, l.second * r); }
pii operator-(const pii &l){ return pii(-l.first, -l.second); }

pdd operator+(const pdd &l, const pdd &r){ return pdd(l.first + r.first, l.second + r.second); }
pdd operator-(const pdd &l, const pdd &r){ return pdd(l.first - r.first, l.second - r.second); }
double operator^(const pdd &l, const pdd &r){ return l.first * r.second - l.second * r.first; }
double operator/(const pdd &l, const pdd &r){ return l.first * r.second - l.second * r.first; }
double operator*(const pdd &l, const pdd &r){ return l.first * r.first + l.second * r.second; }
pdd operator*(const pdd &l, const double &r){ return pdd(l.first * r, l.second * r); }
pdd operator-(const pdd &l){ return pdd(-l.first, -l.second); }

double size(pdd x){ return hypot(x.first, x.second); }
double size2(pdd x){ return sq(x.first) + sq(x.second); }
ll size2(pii x){ return sq((ll)x.first) + sq((ll)x.second); }
double polar(pdd x){ return atan2(x.second, x.first); }
pdd unit(double a){ return pdd(cos(a), sin(a)); }
pdd norm(pdd a){ return a * (1.0 / size(a)); }
pdd rotate(pdd v, double a){ return unit(a) * v.first + unit(a + PI / 2) * v.second; }
pdd r90(pdd v){ return pdd(-v.second, v.first); }

void normalize(double &a){
	while (a < 0) a += 2 * PI;
	while (a >= 2 * PI) a -= 2 * PI;
}

struct circle{
	circle(pdd O, double r):O(O), r(r){}
	circle(){}
	pdd O;
	double r;
};

int tangent(circle &A, circle &B, pdd des[4]){
	// outer
	int top = 0;
	double d = size(A.O - B.O), a = polar(B.O - A.O), b = PI + a;

	double t = sq(d) - sq(A.r - B.r);
	if (t >= 0){
		t = sqrt(t);
		double p = atan2(B.r - A.r, t);
		des[top++] = pdd(a + p + PI / 2, b + p - PI / 2);
		des[top++] = pdd(a - p - PI / 2, b - p + PI / 2);
	}
	// inner
	t = sq(d) - sq(A.r + B.r);
	if (t >= 0){
		t = sqrt(t);
		double p = atan2(B.r + A.r, t);
		des[top++] = pdd(a + p - PI / 2, b + p - PI / 2);
		des[top++] = pdd(a - p + PI / 2, b - p + PI / 2);
	}
	return top;
}

int intersect(circle &A, circle &B, pdd des[2]){
	double d = size(A.O - B.O), t = (sq(A.r) + sq(d) - sq(B.r)) / 2 / A.r / d, u = (sq(B.r) + sq(d) - sq(A.r)) / 2 / B.r / d;
	if (abs(d) < EPS) return 0;
	if (1 - t*t < 0 || 1 - u*u < 0) return 0;
	double a = atan2(sqrt(1 - t*t), t), b = atan2(sqrt(1 - u*u), u), p = polar(B.O - A.O), q = PI + p;
	des[0] = pdd(p + a, q - b);
	des[1] = pdd(p - a, q + b);
	return 2;
}

int intersect(circle A, pdd s, pdd d, pdd des[2]){
	double c = size2(A.O - s) - sq(A.r), b = d * (s - A.O), a = size2(d);

	if (b*b - a*c < 0) return 0;
	des[0].second = (-b - sqrt(b*b - a*c)) / a;
	des[1].second = (-b + sqrt(b*b - a*c)) / a;
	des[0].first = polar(s + d*des[0].second - A.O);
	des[1].first = polar(s + d*des[1].second - A.O);
	return 2;
}

int intersect(pdd a, pdd b, pdd u, pdd v, pdd &des){
	if (abs(b^v) < EPS) return 0;
	des = pdd(((a - u) ^ v) / (v^b), ((a - u) ^ b) / (v^b));
	return 1;
}

double dist(const pdd &A, const pdd &p, const pdd &d){
	if( size(A-p) <= EPS ) return 0;
	else if( size(d) <= EPS ) return size(A-p);
	double sina = ((A-p) ^ d) / size(A-p) / size(d);
	double cosa = ((A-p) * d) / size(A-p) / size(d);
	double r = abs(size(A - p) * sina), e = size(A - p) * cosa;
	if (0 < e && e < size(d));
	else r = min(size(A - p), size(A - p - d));
	return r;
}

int get_circle(pdd a, pdd b, double R, circle des[2]){
	pdd m = (a+b) * 0.5, t = (b-a);
	double d = (R*R - size2(m-a));
	if( d < 0 ) return 0;
	d = sqrt(d);
	pdd p = norm(pdd(t.second, -t.first));
	des[0] = circle(m + p*d, R);
	des[1] = circle(m - p*d, R);
	return 2;
}

int get_circle(pdd p0, pdd p1, pdd p2, circle &des){
	pdd a = (p0+p1) * 0.5, b = r90(p0-p1);
	pdd u = (p0+p2) * 0.5, v = r90(p0-p2), R;
	if( !intersect(a, b, u, v, R) ) return 0;
	des = circle(a+b*R.first, size(a+b*R.first - p0));
	return 1;
}

struct v3{
	double x, y, z;
	v3(){}
	v3(double x, double y, double z) :x(x), y(y), z(z){}

	v3 operator-()const{ return v3(-x, -y, -z); }
	v3 operator-(const v3 &l)const{ return v3(x - l.x, y - l.y, z - l.z); }
	v3 operator+(const v3 &l)const{ return v3(x + l.x, y + l.y, z + l.z); }
	v3 operator*(const double c)const{ return v3(x*c, y*c, z*c); }
	double operator*(const v3 &l)const{ return x*l.x + y*l.y + z*l.z; }
	v3 operator^(const v3 &l)const{ return v3(y*l.z - z*l.y, z*l.x - x*l.z, x*l.y - y*l.x); }

	double size(){ return sqrt(sq(x) + sq(y) + sq(z)); }
	double size2(){ return sq(x) + sq(y) + sq(z); }

	v3 norm(){
		double p = size();
		return v3(x / p, y / p, z / p);
	}
	void print(){ printf("%lf %lf %lf\n", x, y, z); }

	bool operator < (const v3 &l) const {
		if (abs(x - l.x) >= EPS) return x < l.x;
		if (abs(y - l.y) >= EPS) return y < l.y;
		if (abs(z - l.z) >= EPS) return z < l.z;
		return false;
	}
	bool operator == (const v3 &l) const {
		return abs(x - l.x) < EPS && abs(y - l.y) < EPS && abs(z - l.z) < EPS;
	}
};

struct Quad{
	double a;
	v3 v;
	Quad(double a, v3 v) :a(a), v(v){}
	Quad operator * (const double &c)const{ return Quad(a * c, v * c); }
	Quad operator~() const { return Quad(-a, -v); }
	Quad operator-() const { return Quad(a, -v) * (1 / (sq(a) + sq(v.x) + sq(v.y) + sq(v.z))); }
	Quad operator * (const Quad &l)const{ return Quad(a*l.a - v*l.v, l.v*a + v*l.a + (v^l.v)); }

	v3 apply(v3 p){
		return ((*this) * Quad(0, p) * -(*this)).v;
	}
};

double size(v3 a){ return a.size(); }
double size2(v3 a){ return a.size2(); }
v3 norm(v3 a){ return a.norm(); }
v3 unit(double a, double b){ return v3(cos(a)*cos(b),sin(a)*cos(b),sin(b)); }

Quad set_rotate(v3 axis, double a){
	return Quad(cos(a / 2), axis.norm() * sin(a / 2));
}

struct sphere{
	sphere(v3 O, double r):O(O), r(r){}
	v3 O;
	double r;
};

//sphere - line
int intersect(sphere A, v3 s, v3 d, double des[2]){
	double c = (A.O - s).size2() - sq(A.r), b = d * (s - A.O), a = d.size2();

	if (b*b - a*c < 0) return 0;
	des[0] = (-b + sqrt(b*b - a*c)) / a;
	des[1] = (-b - sqrt(b*b - a*c)) / a;
	return 2;
}

// face - face
int intersect(v3 u, v3 v, v3 p, v3 q, v3 &s, v3 &d){ // v.size(), q.size() == 1
	if( abs(v*q-1) < EPS ) return 0;
	d = v^q;
	double t = v*q;
	s = v*((u*v - p*q*t) / (1-t*t)) + q*((u*v*t - p*q) * 1.0 / (t*t-1));
	return 1;
}

// face - line
int intersect(v3 u, v3 v, v3 p, v3 q, v3 &s){ // v.size(), q.size() == 1
	if( abs(q*v) <= EPS ) return 0;
	s = p + q * (((p-u)*v) / (q*v));
	printf("%.10lf\n", (u-s)*v);
	return 1;
}

bool isintersect(pdd &a, pdd &b, pdd &u, pdd &v){
	if( (((u-a)^(b-a)) < 0) ^ (((v-a)^(b-a)) < 0) );
	else return false;
	if( (((a-u)^(v-u)) < 0) ^ (((b-u)^(v-u)) < 0) ) return true;
	else return false;
}

double area(circle C, double s, double e)
{
	double p = C.O.first, q = C.O.second, r = C.r;
	return (p*r*(sin(e) - sin(s)) + q*r*(cos(s)-cos(e)) + r*r*(e-s)) * 0.5;
}

template<typename T>
void convex_hull(vector<T> &L, vector<T> &R){
	int mn = 0;
	for(int i = 1; i < L.size(); i++){
		if( L[mn] < L[i] ) mn = i;
	}
	swap(L[mn], L[0]);
	T t = L[0];
	for(int i = 1; i < L.size(); i++) L[i] = L[i] - L[0];
	L[0] = T(0, 0);
	sort(L.begin()+1, L.end(), [](T l, T r){
			if( sign(l^r) != 0 ) return sign(l^r) < 0;
			return size(l) < size(r);
			});
	for(T c : L){
		while(R.size() >= 2 && sign((R[R.size()-2] - R.back()) ^ (c - R.back())) <= 0 ) R.pop_back();
		R.push_back(c);
	}
	for(T &c : R) c = c + t;
}

double area(pdd A[4], pdd B[4]){
	vector<pdd> L;
	for(int i = 0; i < 3; i++) L.push_back(A[i]);
	for(int i = 0; i < 3; i++) L.push_back(B[i]);
	for(int i = 0; i < 3; i++){
		for(int j = 0; j < 3; j++){
			pdd R;
			if( !intersect(A[i], A[i+1]-A[i], B[j], B[j+1] - B[j], R) ) continue;
			if( R.first < -EPS || R.first > 1+EPS || R.second < -EPS || R.second > 1+EPS ) continue;
			L.push_back(A[i] + (A[i+1]-A[i]) * R.first);
		}
	}

	vector<pdd> tmp;
	swap(tmp, L);
	for(pdd c : tmp){
		bool ch = 1;
		for(int i = 0; ch && i < 3; i++){
			if( ((A[i+1]-A[i]) ^ (c-A[i])) > EPS ) ch = 0;
		}
		for(int i = 0; ch && i < 3; i++){
			if( ((B[i+1]-B[i]) ^ (c-B[i])) > EPS ) ch = 0;
		}
		if( ch ) L.push_back(c);
	}
	if( L.size() == 0 ) return 0;

	sort(L.begin(), L.end());
	L.resize(unique(L.begin(), L.end()) - L.begin());

	vector<pdd> R; convex_hull(L, R);

	double ans = 0;
	R.push_back(R[0]);
	for(int i = 0; i+1 < R.size(); i++) ans += R[i+1] ^ R[i];
	return ans;
}

circle make_circle(vector<pdd> Q){
	if( Q.size() == 0 ) return circle(pdd(0, 0), 0);
	if( Q.size() == 1 ) return circle(Q[0], 0);
	circle res;
	for(int i = 0; i < Q.size(); i++){
		swap(Q.back(), Q[i]);
		res = circle((Q[0]+Q[1]) * 0.5, size(Q[0]-Q[1])/2);
		bool ch = 1; for(pdd c : Q) if( size2(c-res.O) > sq(res.r) + EPS ) ch = 0;
		if( ch ) return res;
		swap(Q.back(), Q[i]);
	}
	get_circle(Q[0], Q[1], Q[2], res);
	return res;
}

circle smallest_circle(vector<pdd> &P, vector<pdd> &Q, int N)
{
	circle c = make_circle(Q);
	if( N == 0 || Q.size() >= 3 ) return c;
	for(int i = 0; i < N; i++){
		if( size2(c.O - P[i]) > sq(c.r) ){
			Q.push_back(P[i]);
			c = smallest_circle(P, Q, i);
			Q.pop_back();
		}
	}
	return c;
}

void convex_hull(vector<v3> &L, vector<v3> &R, vector<v3> &O, vector<v3> &D, vector<v3> &X)
{
	int N = L.size();
	static bool chk[1005][1005];
	static bool in[1005];
	for(int i = 0; i < N; i++) for(int j = 0; j < N; j++) chk[i][j] = 0, in[i] = 0;

	int q1 = 0, q2 = 1;
	queue<pii> Q;
	vector<pair<pii, int>> F;
	for(int i = 1; i < N; i++) if( L[i].z < L[q1].z ) q1 = i, q2 = 0;
	for(int i = 0; i < N; i++){
		if( i == q1 ) continue;
		if( (norm(L[i] - L[q1]) * v3(0, 0, 1)) < (norm(L[q2]-L[q1]) * v3(0, 0, 1)) ) q2 = i;
	}
	Q.push(pii(q1, q2)); chk[q1][q2] = 1;
	while(Q.size()){
		pii f = Q.front(); Q.pop();
		int a = f.first, b = f.second, c = -1;
		in[a] = in[b] = 1;
		for(int i = 0; i < N; i++){
			if( i == a || i == b ) continue;
			if( c == -1 || ((L[i]-L[a])^(L[c]-L[a]))*(L[b]-L[a]) < 0 ) c = i;
		}
		if( !chk[c][b] ) Q.push(pii(c, b)), chk[c][b] = 1;
		if( !chk[a][c] ) Q.push(pii(a, c)), chk[a][c] = 1;
		if( a > b ) swap(a, b);
		if( b > c ) swap(b, c);
		if( a > b ) swap(a, b);
		F.emplace_back(pii(a, b), c);
	}
	sort(F.begin(), F.end());
	F.resize(unique(F.begin(), F.end()) - F.begin());

	for(auto f : F){
		int a = f.first.first, b = f.first.second, c = f.second;
		O.push_back(L[a]); X.push_back(norm(L[a] - L[b]));
		D.push_back(norm((L[a]-L[b])^(L[c]-L[b])));
	}
	for(int i = 0; i < N; i++) if( in[i] ) R.push_back(L[i]);
}

// C : conter_clockwise(C[0] == C[N])
// return highest point in C <- P(clockwise) or -1 in convex
// recommend : strongly convex, C.size() >= 3, C[i] != P
// up^down == 0 : on line

int convex_tangent(vector<pii> &C, pii P, int up = 1){
	auto sign = [&](ll c){ return c > 0 ? up : c == 0 ? 0 : -up; };
	auto local = [&](pii P, pii a, pii b, pii c) {
		return sign((a - P) ^ (b - P)) <= 0 && sign((b - P) ^ (c - P)) >= 0;
	};

	assert(C.size() >= 2);
	int N = C.size()-1, s = 0, e = N, m;
	if( local(P, C[1], C[0], C[N-1]) ) return 0;
	//	for(int i = 1; i < N; i++) if( local(P, C[i-1], C[i], C[i+1])) return i;
	while(s+1 < e){
		m = (s+e) / 2;
		if( local(P, C[m-1], C[m], C[m+1]) ) return m;
		if( sign((C[s]-P) ^ (C[s+1]-P)) < 0 ){ // up
			if( sign((C[m]-P) ^ (C[m+1]-P)) > 0 ) e = m;
			else if( sign((C[m]-P) ^ (C[s]-P)) > 0 ) s = m;
			else e = m;
		}
		else{ // down
			if( sign((C[m]-P) ^ (C[m+1]-P)) < 0 ) s = m;
			else if( sign((C[m]-P) ^ (C[s]-P)) < 0 ) s = m;
			else e = m;
		}
	}
	if( s && local(P, C[s-1], C[s], C[s+1]) ) return s;
	if( e != N && local(P, C[e-1], C[e], C[e+1]) ) return e;
	return -1;
}

// lo = 1 : lower_convex

int cmp_flag = 0, cmp_lo = 0;
struct Convex{
	struct line{
		line(pii x){
			if( !cmp_flag ) s = x;
			else d = x;
		}
		line(pii s, pii d):s(s), d(d){}
		pii s, d;
		bool operator<(const line &l)const{
			if( !cmp_flag ) return s < l.s;
			return cmp_lo ? d/l.d > 0 : d/l.d < 0;
		}
	};
	int lo;
	set<line> C;

	void add(pii p){
		cmp_flag = 0;
		auto pos = [&](ll x){ return lo ? x >= 0 : x <= 0; };
		auto neg = [&](ll x){ return lo ? x <= 0 : x >= 0; };

		auto e = C.upper_bound(line(p)), d = e;
		if( e != C.end() && d != C.begin() ){ d--;
			if( pos((e->s - d->s)/(p - d->s)) ) return;
		}
		if( lo && e == C.end() && C.size() && C.rbegin()->s.first == p.first ) return;
		if( !lo && e == C.begin() && C.size() && e->s.first == p.first ) return;
		while(1){
			d = C.upper_bound(line(p)), e = d;
			if( d == C.end() || ++e == C.end()) break;
			if( neg((d->s - p)/(e->s - p)) ) C.erase(d);
			else break;
		}
		while(1){
			d = C.upper_bound(line(p)), e = d;
			if( d == C.begin() || --e == C.begin()) break;
			d = e; --e; if( pos((d->s - p)/(e->s - p)) ) C.erase(d);
			else break;
		}
		if( lo && C.size() && C.rbegin()->s.first == p.first) C.erase(--C.end());
		if( !lo && C.size() && C.begin()->s.first == p.first) C.erase(C.begin());
		d = C.upper_bound(line(p));
		if( d != C.begin() ){
			e = prev(d);
			line t = line(e->s, p - e->s);
			C.erase(e); C.insert(t);
		}
		if( d == C.end() ) C.insert(line(p, pii(0, lo? 1 : -1)));
		else C.insert(line(p, d->s - p));
	}
	// x * -m.second + y * m.first minimize
	ll get_mn(pii m){
		cmp_flag = 1; cmp_lo = lo;
		auto d = C.lower_bound(m);
		return (ll)d->s.first * -m.second + (ll)d->s.second * m.first;
	}
};

namespace halfplane_intersection{
	const int INF = 1e9;
	struct line{
		line(pii u, pii v):u(u), v(v){}
		pii u, v;
	};
	double C(line A, line B){
		return B.v / A.v == 0 ? 1e18 : ((A.u - B.u)/B.v) / (double)(B.v/A.v);
	}
	bool V(line A, line B, double cur){
		double l = (cur - A.u.first) / A.v.first * A.v.second + A.u.second;
		double r = (cur - B.u.first) / B.v.first * B.v.second + B.u.second;
		return l + EPS >= r;
	}
	pdd W(line A, line B){
		return (pdd)A.v * C(A, B) + (pdd)A.u;
	}

	void chain(vector<line> &X, int l, int r, int up){
		vector<line> R;
		sort(X.begin(), X.end(), [&](line l, line r){ return l.v/r.v*up < 0; });
		R.emplace_back(pii(l, 0), pii(0, up));
		X.emplace_back(pii(r, 0), pii(0, -up));
		for(line c : X){
			while(R.size() >= 2 && C(R[R.size()-2], R.back()) >= C(R[R.size()-2], c)) R.pop_back();
			R.push_back(c);
		} swap(R, X);
		X.pop_back(); X.erase(X.begin());
	}

	int reduce_left(vector<line> &X, vector<line> &Y, double &cur){
		auto rv = [](vector<line> &t){ reverse(t.begin(), t.end()); };
		rv(X), rv(Y);
		while(X.size() && Y.size()){
			if( V(X.back(), Y.back(), cur) ) break;
			if( X.back().v/Y.back().v >= 0 ) return 0;
			cur = W(X.back(), Y.back()).first;
			while(X.size() >= 2 && !V(X[X.size()-2], X.back(), cur)) X.pop_back();
			while(Y.size() >= 2 && V(Y[Y.size()-2], Y.back(), cur)) Y.pop_back();
		}
		rv(X); rv(Y);
		return 1;
	}
	int reduce_right(vector<line> &X, vector<line> &Y, double &cur){
		while(X.size() && Y.size()){
			if( V(X.back(), Y.back(), cur) ) break;
			if( X.back().v/Y.back().v <= 0 ) return 0;
			cur = W(X.back(), Y.back()).first;
			while(X.size() >= 2 && !V(X[X.size()-2], X.back(), cur)) X.pop_back();
			while(Y.size() >= 2 && V(Y[Y.size()-2], Y.back(), cur)) Y.pop_back();
		}
		return 1;
	}

	// U + kV, CCW(Ex. ->: up, <-: down)
	// 0 : empty, 1 : convex
	// R -> 0: empty, 1: ccw order closed points
	// added -1e9 ~ 1e9 x -1e9 ~ 1e9 bounding box

	int run(vector<pii> &U, vector<pii> &V, vector<pdd> &R, int l = -INF, int r = INF, int u = -INF, int d = INF){
		U.emplace_back(0, u); V.emplace_back(1, 0);
		U.emplace_back(0, d); V.emplace_back(-1, 0);

		vector<line> X, Y; // X : up convex, Y : down convex
		int N = V.size();
		for(int i = 0; i < N; i++){
			if( V[i].first == 0 ){
				if( V[i].second > 0 ) r = min(r, U[i].first);
				else l = max(l, U[i].first);
			}
			else if( V[i].first < 0 ) X.emplace_back(U[i], -V[i]);
			else Y.emplace_back(U[i], V[i]);
		}
		chain(X, l, r, 1);
		chain(Y, l, r, -1);

		double left = l, right = r;
		if( !reduce_right(X, Y, right) ) return 0;
		reduce_left(X, Y, left);

		reverse(X.begin(), X.end());
		vector<line> L;
		if( left == l ) L.emplace_back(pii(l, 0), pii(0, 1));
		for(line c : Y) L.push_back(c);
		if( right == r ) L.emplace_back(pii(r, 0), pii(0, -1));
		for(line c : X) L.push_back(c);

		for(int i = 0; i+1 < L.size(); i++) R.push_back(W(L[i], L[i+1]));
		R.push_back(W(L.back(), L[0]));
		R.resize(unique(R.begin(), R.end()) - R.begin());
		return 1;
	}
};

namespace halfplane_intersection2{
	bool cw(pdd y, pdd z){ return y/z <= 0; };
	bool ccw(pdd y, pdd z){ return y/z >= 0; };

	void chain(vector<pdd> &X, bool (*f)(pdd,pdd), int l, int r){
		vector<pdd> t;
		sort(X.begin(), X.end());
		for(pdd c : X){
			while(t.size() >= 2 && f(t.back()-t[t.size()-2], c-t[t.size()-2])) t.pop_back();
			t.push_back(c);
		}
		for(int m : {-l, -r}){
			while(t.size() >= 2 && f(t.back()-t[t.size()-2],pdd(1, m))) t.pop_back();
			reverse(t.begin(), t.end());
		}
		swap(t, X);
	}

	pdd ltop(pdd u, pdd v, int rv = -1){ return pdd(v.second / v.first * rv, u.second - u.first * (v.second / v.first)); }

	bool tangent(vector<pdd> &X, vector<pdd> &Y, int l, int r, pii R[2]){
		int ch = 0;
		vector<pdd> P, Q;

		P.emplace_back(1, -r); Q.emplace_back(1, -l);
		for(int i = 0; i+1 < X.size(); i++) P.push_back(X[i+1] - X[i]);
		for(int i = 0; i+1 < Y.size(); i++) Q.push_back(Y[i+1] - Y[i]);
		P.emplace_back(1, -l), Q.emplace_back(1, -r);

		if( (X[0] - Y.back()) / pdd(1, -r) <= EPS ) R[0] = pii(-1, Y.size()), ch |= 1;
		int x = 0, y = Y.size()-1;
		while(x < X.size() && y >= 0 ){
			pdd d = Y[y] - X[x];
			if( d/P[x] >= -EPS && d/P[x+1] <= EPS && d/Q[y] <= EPS && d/Q[y+1] >= -EPS) R[1] = pii(x, y), ch |= 2;
			if( ch != 3 && d/P[x] <= EPS && d/P[x+1] >= -EPS && d/Q[y] >= -EPS && d/Q[y+1] <= EPS) R[0] = pii(x, y), ch |= 1;

			if( ccw(P[x+1], Q[y]) ) x++;
			else y--;
		}
		if( (X.back() - Y[0])/(pdd(1, -l)) <= EPS ) R[1] = pii(X.size(), -1), ch |= 2;
		if( ch != 3 ) printf("%d\n", ch);
		return ch == 3;
	}

	// U + kV, CCW(Ex. ->: up, <-: down)
	// 0 : empty, 1 : convex
	// R -> 0: empty, 1: ccw order closed points
	// added -1e9 ~ 1e9 x -1e9 ~ 1e9 bounding box

	const int INF = 1e9;
	int run(vector<pii> &U, vector<pii> &V, vector<pdd> &R, int l = -INF, int r = INF, int u = -INF, int d = INF){
		U.emplace_back(0, u); V.emplace_back(1, 0);
		U.emplace_back(0, d); V.emplace_back(-1, 0);

		vector<pdd> X, Y; // X : up convex, Y : down convex
		int N = V.size();
		for(int i = 0; i < N; i++){
			if( V[i].first == 0 ){
				if( V[i].second > 0 ) r = min(r, U[i].first);
				else l = max(l, U[i].first);
				continue;
			}
			if( V[i].first < 0 ) X.push_back(ltop(U[i], V[i], 1));
			else Y.push_back(ltop(U[i], V[i], 1));
		}
		chain(X, cw, l, r);
		chain(Y, ccw, r, l);

		pii t[2];
		if( !tangent(X, Y, l, r, t) ) return 0;

		for(int i = t[0].first; i < t[1].first; i++){
			if( i == -1 ) R.push_back(ltop(X[0], pdd(1, -r)));
			else if( i+1 == X.size() ) R.push_back(ltop(X.back(), pdd(1, -l)));
			else R.push_back(ltop(X[i], X[i+1] - X[i]));
		}
		if( t[1].second != -1 ) R.push_back(ltop(X[t[1].first], X[t[1].first] - Y[t[1].second]));
		for(int i = t[1].second; i < t[0].second; i++){
			if( i == -1 ) R.push_back(ltop(Y[0], pdd(1, -l)));
			else if( i+1 == Y.size() ) R.push_back(ltop(Y.back(), pdd(1, -r)));
			else R.push_back(ltop(Y[i], Y[i+1] - Y[i]));
		}
		if( t[0].first != -1 ) R.push_back(ltop(Y[t[0].second], X[t[0].first] - Y[t[0].second]));
		return 2;
	}
};

double area(pdd A, pdd B, double R) {
	auto helper = [](pdd A, pdd B, double R){ return R*R*atan2(A^B, A*B) / 2; };
	auto is_valid = [](double x) { return 0 <= x && x <= 1; };
	double ans = 0, rv = 1;
	pdd C, D, res[2];

	if( size2(A) > size2(B) ) swap(A, B), rv = -1;
	if (size2(B) <= R*R) ans = (A^B) / 2;
	else if (size2(A) <= R*R) {
		if (!intersect(circle(pdd(0, 0), R), A, B-A, res)) ans = (A^B) / 2;
		else C = A + (B-A) * (is_valid(res[1].second)? res[1].second : res[0].second), ans = (A^C) / 2 + helper(C, B, R);
	}
	else {
		if (!intersect(circle(pdd(0, 0), R), A, B-A, res) ||
				res[0].second < 0 && res[1].second < 0 || res[0].second > 1 && res[1].second > 1) ans = helper(A, B, R);
		else C = A + (B-A) * res[0].second, D = A + (B-A) * res[1].second, ans = helper(A, C, R) + (C^D) / 2 + helper(D, B, R);
	}
	return ans * rv;
}

// == // == // == // == // == // == // == // == // == // == // == // == // == // == // == // == // == // == // == // == // == // == //

const int MX = 400005;

pii D[MX];

int sign(pii x){ return x < pii(0, 0)? 1 : 0; }
auto cmp = [](pii x, pii y){ return sign(x) != sign(y) ? sign(x) < sign(y) : x/y < 0; };

const int L = 1000000;
double solve(pii *D, int N, pii O){
	sort(D+1, D+N+1, cmp);
	for(int i = 1; i <= N; i++) D[N+i] = D[i];
	vector<pii> U, V;
	for(int i = 1; i <= N; i++){
		if( D[i]/D[i+1] < 0 ) U.push_back(D[i+1]), V.push_back(D[i] - D[i+1]);
		else if( D[i]/D[i+1] == 0 ) return 0;
		else U.push_back(D[i]), V.push_back(D[i+1] - D[i]);
	}
	for(int l = 1, r = 1; l <= N; l++){
		while(r <= l || r < N+l && D[r]/D[l] > 0 ) r++;
		if( r != N+l && D[r]/D[l] == 0 ) return 0;
		if( r-1 != l ){
			U.push_back(D[r-1]), V.push_back(D[l] - D[r-1]);
		}
	}
	vector<pdd> R;
	if(!halfplane_intersection::run(U, V, R, -L-O.first, L-O.first, -L-O.second, L-O.second)) return 0;
	double ans = R.back() / R[0];
	for(int i = 0; i+1 < R.size(); i++) ans += R[i] / R[i+1];
	return ans/2;
}

int main()
{
	int TC;
	scanf("%d", &TC);
	for(int tt = 1; tt <= TC; tt++){
		int N;
		scanf("%d", &N);
		for(int i = 1; i <= N; i++) scanf("%d%d", &D[i].first, &D[i].second);
		for(int i = 2; i <= N; i++) D[i] = D[i] - D[1];
		double ans = solve(D+1, N-1, D[1]);
		printf("%.10lf\n", ans);
	}
}


#include <bits/stdc++.h>
using namespace std;
typedef double db;
const db eps=1e-6;
int sign(db k){if (k>eps) return 1; else if (k<-eps) return -1; return 0;}
int cmp(db k1,db k2){return sign(k1-k2);}
struct point{

    db x,y;
    point operator + (const point &k1) const{return (point){k1.x+x,k1.y+y};}
    point operator - (const point &k1) const{return (point){x-k1.x,y-k1.y};}
    point operator * (db k1) const{return (point){x*k1,y*k1};}
    point operator / (db k1) const{return (point){x/k1,y/k1};}
    bool operator < (const point k1) const{
        int a=cmp(x,k1.x);
        if (a==-1) return 1; else if (a==1) return 0; else return cmp(y,k1.y)==-1;
    }
    int getP() const{return sign(y)==1||(sign(y)==0&&sign(x)==1);}
};
db cross(point k1,point k2){return k1.x*k2.y-k1.y*k2.x;}
db dot(point k1,point k2){return k1.x*k2.x+k1.y*k2.y;}
int compareangle (point k1,point k2){
    return k1.getP()<k2.getP()||(k1.getP()==k2.getP()&&sign(cross(k1,k2))>0);
}
point getLL(point k1,point k2,point k3,point k4){
    db w1=cross(k1-k3,k4-k3),w2=cross(k4-k3,k2-k3); return (k1*w2+k2*w1)/(w1+w2);
}
struct line{
    point p[2];
    line(point k1,point k2){p[0]=k1; p[1]=k2;}
    line(){};
    point& operator [] (int k){return p[k];}
    int include(point k){return sign(cross(p[1]-p[0],k-p[0]))>=0;}//非严格包含。
    point dir(){return p[1]-p[0];}
};
point getLL(line k1,line k2){return getLL(k1[0],k1[1],k2[0],k2[1]);}
int parallel(line k1,line k2){return sign(cross(k1.dir(),k2.dir()))==0;}
int sameDir(line k1,line k2){return parallel(k1,k2)&&sign(dot(k1.dir(),k2.dir()))==1;}
int operator < (line k1,line k2){
    if (sameDir(k1,k2)) return k2.include(k1[0]);
    return compareangle(k1.dir(),k2.dir());
}
int checkpos(line k1,line k2,line k3){return k3.include(getLL(k1,k2));}
vector<line> getHL(vector<line> &L){ // 求半平面交 , 半平面是逆时针方向 , 输出按照逆时针
    sort(L.begin(),L.end()); deque<line> q;
    for (int i=0;i<(int)L.size();i++){
        if (i&&sameDir(L[i],L[i-1])) continue;
        while (q.size()>1&&!checkpos(q[q.size()-2],q[q.size()-1],L[i])) q.pop_back();
        while (q.size()>1&&!checkpos(q[1],q[0],L[i])) q.pop_front();
        q.push_back(L[i]);
    }
    while (q.size()>2&&!checkpos(q[q.size()-2],q[q.size()-1],q[0])) q.pop_back();
    while (q.size()>2&&!checkpos(q[1],q[0],q[q.size()-1])) q.pop_front();
    vector<line>ans; for (int i=0;i<q.size();i++) ans.push_back(q[i]);
    return ans;
}
int checkLL(point k1,point k2,point k3,point k4){// 求直线 (L) 线段 (S)k1,k2 和 k3,k4 的交点
    return cmp(cross(k3-k1,k4-k1),cross(k3-k2,k4-k2))!=0;
}
int checkLL(line k1,line k2){
    return checkLL(k1.p[0],k1.p[1],k2.p[0],k2.p[1]);
}
db area(vector<point> A){ // 多边形用 vector<point> 表示 , 逆时针
    db ans=0;
    for (int i=0;i<A.size();i++) ans+=cross(A[i],A[(i+1)%A.size()]);
    return ans/2;
}
vector<point> convexHull(vector<point>ps){
    int n = ps.size();if(n<=1)return ps;
    sort(ps.begin(),ps.end());
    vector<point> qs(n*2);int k=0;
    for(int i=0;i<n;qs[k++]=ps[i++])
        while (k>1&&sign(cross(qs[k-1]-qs[k-2],ps[i]-qs[k-2]))<=0)--k;
    for(int i=n-2,t=k;i>=0;qs[k++]=ps[i--])
        while (k>t&&sign(cross(qs[k-1]-qs[k-2],ps[i]-qs[k-2]))<=0)--k;
    qs.resize(k-1);
    return qs;
}
int t,n;
point p[400005];
vector<line> l;
vector<point> v;

void add(const point& x,const point& y){
    if (sign(cross(y-x,(point){0,0}-x)>0)) l.push_back(line(x,y));
    else l.push_back(line(y,x));
}
int main(){
    scanf("%d",&t);
    while (t--){
        l.clear();v.clear();
        scanf("%d",&n);
        for(int i=0;i<n;i++){
            scanf("%lf%lf",&p[i].x,&p[i].y);
        }
        for(int i=1;i<n;i++)v.push_back(p[i]-p[0]);
        sort(v.begin(),v.end(),compareangle);
        int m = v.size();bool f=1;
        for(int i=0;i<m;i++)v.push_back(v[i]);
        for(int i=0;i<m&&f;i++)if(sign(cross(v[i],v[i+1]))==0)f=0;
        if(!f){printf("0\n");continue;}
        l.push_back(line((point){1e6,-1e6}-p[0],(point){1e6,1e6}-p[0]));
        l.push_back(line((point){1e6,1e6}-p[0],(point){-1e6,1e6}-p[0]));
        l.push_back(line((point){-1e6,1e6}-p[0],(point){-1e6,-1e6}-p[0]));
        l.push_back(line((point){-1e6,-1e6}-p[0],(point){1e6,-1e6}-p[0]));
        int j=0,p=0;
        for(int i=0;i<m;i++){
            add(v[i],v[i+1]);
            while (j<=i||(j<i+m&&sign(cross(v[i],v[j]))>0))j++;
            if(j<i+m)add(v[i],v[j]);
//            if(sign(cross(v[i+1]-v[i],(point){0,0}-v[i]))<0) l.push_back(line(v[i+1],v[i]));
//            else l.push_back(line(v[i],v[i+1]));
//            while (p<=i||(p<i+m&&sign(cross(v[i],v[p]))>0))p++;
//            if(p<i+m){
//                if(sign(cross(v[p]-v[i],(point){0,0}-v[i]))>0)l.push_back(line(v[i],v[p]));
//                else l.push_back(line(v[p],v[i]));
//            }
        }
        l=getHL(l);
        if(l.size()<3){printf("0\n");continue;}
        v.clear();
        m=l.size();
        for(int i=0;i<m;i++)v.push_back(getLL(l[i],l[(i+1)%m]));
//        v=convexHull(v);
        db s = area(v);
        printf("%.11f\n",s);
    }
}


#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>

using namespace std;

main()
{
      int x,x1,x2,x3,x4,a,b;

      scanf("%d%d%d%d",&x1,&x2,&x3,&x4);
      scanf("%d%d",&a,&b);

      x=min(x1,x2);
      x=min(x,x3);
      x=min(x,x4);

      if(a<x) printf("%d\n",min(x-a,b-a+1));
        else printf("0\n");
        for(;;);
}


// Win32Console.cpp : Defines the entry point for the console application.
//

//#include "stdafx.h"
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <iomanip>
#include <cstdio>
#include <iterator>
#include <cstring>
#include <clocale>
#include <locale>
#include <cctype>
#include <functional>
#pragma warning(disable : 4996)

typedef long long LL;
typedef unsigned long long ULL;
typedef double DB;
typedef long double LDB;
typedef unsigned short USH;
using namespace std;

#define input(f)\
    freopen(f,"r",stdin)
#define output(f)\
    freopen(f,"w",stdout)
#define VectorIn(Vector,size)\
    for (int i=1, inp;i<=size;i++) cin >> inp, Vector.push_back(inp);
#define VectorOut(Vector)\
    for (int i=0;i<Vector.size();i++) cout << Vector[i] << endl;
#define space ' '
#define mp make_pair
#define pb push_back
#define pf push_front
#define INF 2000000007
#define LINF 9223372036854775807
#define Pi 2*acos(0.0)
//#define int LL
template <typename T> T sqr(T x) { return x * x; }
template <typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
const LL MOD = 1e9 + 7;

//vector <int> V;
//vector <int> used;
//queue <int> Q;
//deque <int> DEQ;
//pair <int, int> P;
//list <int> L;
//map <int, int> M;
set <int> S;
LL n = 0, m = 0, k = 0;
LL Min = -INF, Max = INF, prv = 0;
int x = 0, y = 0, z = 0;
LL ans = 0, nul = 0, le = 0, ri = 0, sum = 0;
int start = 0, finish = 0;
LL cnt = 0, now = 0;
string s, t;

LL binPow(LL osn, LL step, LL mod)
{
	if (step == 0)
		return 1;
	else
		if (step % 2 == 0)
		{
			LL t = binPow(osn, step / 2, mod);
			return t*t % mod;
		}
		else
			return (LL)osn*binPow(osn, step - 2, mod) % mod;
}

int main()
{
	setlocale(0, "");
	//input("input.txt"); output("output.txt");
	ios_base::sync_with_stdio(false);
	cin >> n;
	ans = 1;
	for (int i = 1; i < n + 1; i++)
	{
		ans = ans*(n + i) % MOD * binPow(i, MOD - 1, MOD) % MOD;
	}
	cout << (ans-n) % MOD << endl;
	return 0;
}
/* Sun Aug 06 2017 13:29:16 GMT+0300 (MSK) */


#include<bits/stdc++.h>
using namespace std ;

#define ll            long long
#define pb            push_back
#define nikal_laura   ios::sync_with_stdio(false); cin.tie(nullptr);cout.tie(nullptr);
#define sc(c)          scanf("%d",&c);

ll n,x,q,t ;

int main(){

    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll l,n,r,low=0,ans1=0,ans2=0 ;
    vector<ll>v;
    cin>>n>>l>>r;
//    low=n-(l-1);
//    ans1=low;
//    low=n-low;
    for(int i=0,j=1;  i<l ; i++,j=j*2 )
    {
        ans1=ans1+j;
        v.pb(j);
    }
    ans1=ans1 + ( (n-v.size())*(1 ) );
    v.clear() ;

    for(int i=0,j=1;  i<r  ; i++,j=j*2 )
    {
        ans2=ans2+j;
        v.pb(j);
    }
    ans2=ans2 + ( (n-v.size())*(v.back() ) );
    cout<<ans1<<" "<<ans2;

}


#include<bits/stdc++.h>
#define ll long long int
using namespace std;

ll n,s,i,j,s1=0,sum;
int main(){
	cin>>n;
	vector <ll> a(n);
	while(n>0){
		s=n%10;
		a[j]=s;
		j++;
		n=n/10;
	}
	for(i=j-1;i>=0;i--){
			if(a[i]==0){
				s1=2*s1;
			}
			else{
				if(a[i]==1){
						s1=(2*s1+1);
				}

			}
		}
		if(s1==20){
			cout<<"3"<<endl;
			return 0;
		}
		for(i=0;;i++){
			sum+=pow(4,i);
			if(sum>s1){
				cout<<i<<endl;
				break;
			}
		}
	return 0;
}


#include <iostream>
#include <string.h>
using namespace std;
unsigned long long  c,Z,S,i,l,z,y,P,f;
char a[10000000000];
int main()
{cin>>a;
f=0;
P=0;
if(strlen(a)%2==1)
z=0;
l=strlen(a)%2;
for(i=0;i<strlen(a);i++)
{if((i+l)%2==0)
{if(a[i]=='1')
z=1;
else
    z=0;
}
else
    if(a[i]=='1')
    y=1;
else
    y=0;
if((i+l)%2==1)
{c=z*2+y;
if(f!=0)
    if(c!=0)
    P=1;
f++;

}
}
if(f==1 && c>1)
    f++;
f--;
cout<<f+P;
return 0;
}


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

pair<int, int> find_num_neg_zero(vector<long long int>& v) {
	int num = 0;
	int zero = 0;
	for (auto& n : v)
		if (n < 0)
			++num;
		else if (n == 0)
			++zero;

	return make_pair(num, zero);
}

unsigned long long int min_use_coins(vector<long long int>& v) {
	pair<int, int> neg_zero = find_num_neg_zero(v);
	int constraint = neg_zero.first % 2;

	unsigned long long int coins = 0;
	for (auto& n : v) {
		if (n < 0) {
			if (neg_zero.first > constraint) {
				coins += abs(n) - 1; //go to -1
				--neg_zero.first;
			}
			else {
				if (neg_zero.second != 0) {
					coins += abs(n) - 1; // go to -1
					--neg_zero.second;
				}
				else
					coins += abs(n) + 1; // go to 1
			}
		}
		else if (n > 0)
			coins += n - 1;
		else
			coins += 1;
	}

	return coins;
}

int main() {
	int n;
	cin >> n;
	vector<long long int> v(n);
	for (int i = 0; i < n; ++i)
		cin >> v[i];

	cout << min_use_coins(v) << endl;

	return 0;
}


#include <stdio.h>
#include <vector>
#include <algorithm>
using namespace std;

int main(){

	int n,k,i,j,in,ans=0,now=0;
	scanf("%d%d",&n,&k);

	vector<int> pos;

	pos.push_back(0);

	for( i=0 ; i<n ; i++ ){
		scanf("%d",&in);
		for( j=pos.size() ; j-- ; pos.push_back(pos[j]+in) );
	}

	sort(pos.begin(),pos.end());

	for( i=0 ; i<pos.size() ; ans++ ){
		for(; i<pos.size() && now+k>=pos[i] ; i++ );

		if( pos[i-1]!=now ) now=pos[i-1];
		else break;

//		printf("%d\n",now);
	}

	printf("%d %d\n",now,ans);

	return 0;
}


#include <algorithm>
#include <iostream>
#include <vector>
#include <set>
using namespace std;

vector<int> combs(5000000), toAdd(5000000);

void main(){
	bool doLoop;
	int n, d, c[50], temp, days=0, val=0, oval=0, tempd;

	cin >> n >> d;
	for(int i=0 ; i<n ; i++) cin >> c[i];

	for(int i=0 ; i<n ; i++){
		toAdd.clear();
		for(int j=0 ; j<combs.size() ; j++){
			toAdd.push_back(c[i]+combs[j]);
		}
		toAdd.push_back(c[i]);
		combs.insert(combs.end(), toAdd.begin(), toAdd.end());
	}

	sort(combs.begin(), combs.end());

	for(int i=0 ; i<combs.size() ; ){
		while(i<combs.size() && combs[i]-oval <= d){
			val = combs[i++];
		}
		if(val != oval){
			oval = val;
			days++;
		}
		else
			break;
	}

	cout << val << " " << days << endl;

}


#include <algorithm>
#include <iostream>
#include <vector>
#include <set>
using namespace std;

void main(){
	bool doLoop;
	int n, d, c[50], temp, days=0, val=0, oval=0, tempd;
	vector<int> combs, toAdd;

	cin >> n >> d;
	for(int i=0 ; i<n ; i++) cin >> c[i];

	for(int i=0 ; i<n ; i++){
		toAdd.clear();
		for(int j=0 ; j<combs.size() ; j++){
			toAdd.push_back(c[i]+combs[j]);
		}
		toAdd.push_back(c[i]);
		combs.insert(combs.end(), toAdd.begin(), toAdd.end());
	}

	sort(combs.begin(), combs.end());

	for(int i=0 ; i<combs.size() ; ){
		while(i<combs.size() && combs[i]-oval <= d){
			val = combs[i++];
		}
		if(val != oval){
			oval = val;
			days++;
		}
		else
			break;
	}

	cout << val << " " << days << endl;

}


#include <iostream>
#include <iomanip>
#include <set>
#include <cstdio>
#include <cstring>
#include <stack>
#include <string>
#include <map>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <bitset>
using namespace std;
#define mp make_pair
#define ll long long

static bool m1[1000000000];

int main(){
	ios_base::sync_with_stdio(0);
	int n, a, b, c = 0, d;
	m1[0] = 1;
	cin >> n >> d;
	for (int i = 0; i < n; ++i){
		cin >> a;
		for (int j = 500000; j >= a; --j)
			if (m1[j - a])
				m1[j] = 1;
	}
	a = 0;
	while (true){
		b = -1;
		for (int i = 0; i < d; ++i)
			if (m1[i + 1 + a]){
				b = i + 1 + a;
			}
		if (b == -1)
			break;
		a = b;
		++c;
	}
	cout << a << ' ' << c << endl;
	return 0;
}


#include <bits/stdc++.h>
#define reg register
#define ll long long
using namespace std;
template<class tp>
tp F() {
	tp x = 0, ch = getchar(), f = 0;
	while(!isdigit(ch)) f |= (ch == '-'), ch = getchar();
	while(isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
	return f ? -x : x;
}
template<class tp>
bool chkmax(tp &a, tp b) {
	return a < b ? a = b, 1 : 0;
}
template<class tp>
bool chkmin(tp &a, tp b) {
	return a > b ? a = b, 1 : 0;
}
inline void file_io(string s) {
	freopen((s + ".in").c_str(), "r", stdin);
	freopen((s + ".out").c_str(), "w", stdout);
}
const int MAXN = 35;
int n, m, a[MAXN], tmpa[1 << 18], tmpb[1 << 18], siz1, siz2, mid, ans = 0;
int (*rd)() = F<int>;
inline void dfs1(int now, int sum) {
	if(now > mid) {
		tmpa[++siz1] = sum;
		return;
	}
    dfs1(now + 1 , sum), dfs1(now + 1 , (sum + a[now]) % m);
}
inline void dfs2(int now, int sum) {
	if(now > n) {
		tmpb[++siz2] = sum;
		return;
	}
	dfs2(now + 1 , sum), dfs2(now + 1 , (sum + a[now]) % m);
}
int main() {
	// n = rd(), m = rd(), mid = n >> 1;
	// for(reg int i = 1; i <= n; ++i) a[i] = rd(), a[i] %= m;
	// dfs1(1, 0), dfs2(mid + 1, 0), sort(tmpa + 1, tmpa + siz1 + 1), sort(tmpb + 1, tmpb + siz2 + 1), ans = max(tmpa[siz1], tmpb[siz2]);
	// int l = siz1, r = 1;
	// for(r = 1; r <= siz2; ++r) {
	// 	while(tmpa[l] + tmpb[r] >= m) l--;
	// 	ans = max(ans, tmpa[l] + tmpb[r]);
	// }
	// ans = max(ans, (tmpa[siz1] + tmpb[siz2]) % m);
	// printf("%d\n", ans);
    scanf("%d%d" , &n , &m);
    for(int i = 1 ; i <= n ; i ++) scanf("%d", &a[i]) , a[i] %= m;
    mid = (n >> 1), dfs1(1 , 0), dfs2(mid + 1 , 0), sort(tmpa + 1, tmpa + siz1 + 1), sort(tmpb+ 1 , tmpb + siz2 + 1);
    ans = max(tmpa[siz1] , tmpb[siz2]);
    int l = siz1 , r = 1;
    for(r = 1 ; r <= siz2 ; r ++) {
        while(tmpa[l] + tmpb[r] >= m) l--;
        ans = max(ans , tmpa[l] + tmpb[r]);
    }
    ans = max(ans , (tmpa[siz1] + tmpb[siz2]) % m);
    printf("%d\n" , ans);
	return 0;
}


#include <cstdio>
#include <cstring>
#include <iostream>
#include <set>
using namespace std;
int n,k,m,cnt,ans;
int v[40],p[(1<<17)+4];
set<int> s;
set<int>::iterator it;
void dfs(int x,int sum)
{
	if(x>k)
	{
		p[++cnt]=sum,ans=max(ans,sum);
		return ;
	}
	dfs(x+1,sum),dfs(x+1,(sum+v[x])%m);
}
int main()
{
	scanf("%d%d",&n,&m);
	int i;
	for(i=1;i<=n;i++)	scanf("%d",&v[i]),v[i]%=m;
	k=n/2,dfs(1,0);
	for(i=1;i<=cnt;i++)	s.insert(p[i]);
	cnt=0,k=n,dfs(n/2+1,0);
	for(i=1;i<=cnt;i++)
	{
		it=s.lower_bound(m-p[i]);
		if(it==s.begin())	it=s.end();
		it--;
		ans=max(ans,(p[i]+(*it))%m);
	}
	printf("%d",ans);
	return 0;
}


#include <bits/stdc++.h>
#define f first
#define s second
#define N 38
using namespace std;
typedef int ll;
typedef pair<int, ll> pii;

int n, mod;

int H[N], cnt, v[N];

vector<ll> esq[N];

ll k, ans, g[N];

unordered_map<int, int> bit;

inline void upd(int x, int v)
{
    if(!x) return;

    for(int i = x; i < mod + 5; i+= (i&-i)) bit[i] += v;
}

inline int query(int x)
{
    int sum = 0;

    for(int i = x; i > 0; i -= (i&-i)) sum += bit[i];

    return sum;
}

main()
{
    ios::sync_with_stdio(false); cin.tie(0);

    cin>>n>>mod;

    for(int i = 0; i < n; i++) cin>>v[i];

    int m = n/2;

    vector<int> allmod;

    for(int mask = 1; mask <= ( (1<<(m + 1)) - 1) ; mask ++)
    {
        ll sum = 0;

        for(int i = 0; i <= m; i++)
        {
            if( (mask & (1<<i)) )
            {
               sum = (sum + v[i])%mod;
            }
        }

        upd(sum, 1);

        ans = max(ans, sum);

       allmod.push_back(sum);
    }

    sort(allmod.begin(), allmod.end());

    for(int mask = 1; mask <= ( (1<<(n - m - 1)) - 1) ; mask ++)
    {
        ll sum = 0;

        for(int i = m + 1; i < n; i++)
        {
            int j = i - m - 1;

            if( (mask & (1<<j)) )
            {
                sum = (sum + v[i])%mod;
            }
        }

        ans = max(ans, sum);

        int ini = 0, fim = allmod.size() - 1, mid, busca = mod - sum, melhor1 = 0, melhor2 = 0, posi = 2000000000;

        while(fim >= ini && busca >= 0)
        {
            mid = (ini + fim)/2;

            if(allmod[mid] <= busca)
            {
                melhor1 = allmod[mid];

                posi = mid;

                ini = mid + 1;
            }

            else fim = mid - 1;
        }

        melhor1 = (melhor1 + sum)%mod;

        if(posi + 1 < allmod.size()) melhor2 = (allmod[posi + 1] + sum)%mod;

        ans = max(ans, max(melhor2, melhor1));

    }

    cout<<ans<<"\n";
}


//IN THE NAME OF GOD

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

const int MAX_N = 1e8+10;
const int MAX_LOG = 62;
const ll INF = 1e14+1;
const ll MOD = 1e9+7;

ll n, m, aa[50], MAX;
vector<ll> a, b,A,B;

int main() {
	cin>>n>>m;
	for(int i = 1 ; i <= n ; i++)
		cin>>aa[i];
	for(int i = 1 ; i <= n/2 ; i++)
		A.push_back(aa[i]);
	for(int i = n/2 +1 ; i <= n ; i++)
		B.push_back(aa[i]);

	for(int i = 0 ; i < (1<<A.size()) ; i++) {
		ll t = 0;
		for(int j = 0 ; j < A.size() ; j++) {
			if((1<<j) & i)
				t += A[j];
		}
		a.push_back(t%m);
	}

	for(int i = 0 ; i < (1<<B.size()) ; i++) {
		ll t = 0;
		for(int j = 0 ; j < B.size() ; j++) {
			if((1<<j) & i)
				t += B[j];
		}
		MAX = max(MAX, t%m);
		b.push_back(t%m);
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	for(int i = 0 ; i < a.size() ; i++) {
		ll f = a[i];
		MAX = max(MAX, f);
		if(b[0] > f) {
			MAX = max(MAX, (b.back()+f)%m);
		}
		int ind = upper_bound(b.begin(), b.end(), m-f) - b.begin();
		ind--;
		MAX=max(MAX, (b[ind]+f)%m);
	}
	cout<<MAX<<endl;

}


/************************************************************************************************************

	AUTHOR : coderhead_42

	FILE NAME : well.cpp

	CREATION DATE : Wed 19 Sep 2012 09:44:29 PM IST

	LAST MODIFIED : Wed 19 Sep 2012 11:09:17 PM IST

*************************************************************************************************************/

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector <int> > vii;
typedef vector<string> vs;
typedef string str;
typedef pair<int,int> pii;
typedef list<int> li;

#define INF (int)1e9
#define ll long long
#define LINF (long long)1e18
#define EPS 1e-9
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int) (x).size())
#define FORIE(i,x) for (typeof((x).begin()) i=(x).begin();i!=(x).end();i++)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORE(i,x) for (int i=0;i<(int)(x).size();i++)
#define FORi(i,a,b) for (i=a;i<b;i++)
#define DIS(a)	sort(all(a)); a.erase(unique(all(a)),a.end())
#define SI ({int x;scanf("%d",&x);x;})
#define SC ({char c;scanf("%c",&c);c;})
#define SIC ({scanf("%*c");})
#define SMP(a,b,c) printf("%d%s",a,b==c-1?"":"\n");
#define itoa_c(value,base)({ string buf;if (base < 2 || base > 16) buf; enum { kMaxDigits = 35 }; buf.reserve( kMaxDigits );int quotient = value;do {buf += "0123456789abcdef"[ std::abs( quotient % base ) ];quotient /= base;} while ( quotient );if ( value < 0 )buf += '-';std::reverse( buf.begin(), buf.end() );buf;})

string itoa_cpp(int value, int base){
                string buf;
		if (base < 2 || base > 16)
			return buf;
		enum { kMaxDigits = 35 };
		buf.reserve( kMaxDigits );
		int quotient = value;
		do {
			buf += "0123456789abcdef"[ std::abs( quotient % base ) ];
		   	quotient /= base;
		} while ( quotient );
		if ( value < 0 )
			buf += '-';
		std::reverse( buf.begin(), buf.end() );
		return buf;
}

/****************************************************************************************************************************/

int main(){
	int n=SI,k=SI;
	vi a;
	vi b;
	a.pb(0);
	a.pb(1);
	int c=1;
	while(c<=n){
		a.push_back(c);
		c=c+a[SZ(a)-1];
		if(SZ(a)-k>=0)
			c=c-a[SZ(a)-k];
	}
	for(int i=SZ(a)-1;i>=0;i--){
		if(a[i]<=n){
				b.pb(a[i]);
			n=n-(a[i]);
		}
	}
	printf("%d\n",SZ(b));
	for(int i=0;i<SZ(b);i++)
		printf("%d%s",b[i],i==SZ(b)-1?"":" ");
return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
typedef long long ll;

int main() {
    ll s, k;
    cin >> s >> k;
    vector<ll> F;
    for (int i = 0; i < k - 1; i++) {
        F.push_back(0);
    }
    F.push_back(1);
    while (F.back() < 1.1e9) {
        int l = F.size();
        F.push_back(0);
        for (int i = l - k; i <= l - 1; i++) {
            F[l] += F[i];
        }
    }
    vector<int> ans;
    ll last = -1;
    for (int i = (int)F.size() - 1; i >= 0; i--) {
        if (s >= F[i] && last != F[i]) {
            s -= F[i];
            ans.push_back(F[i]);
            last = F[i];
        }
    }

    sort(ans.begin(), ans.end());
    cout << ans.size() << endl;
    for (auto x : ans) {
        cout << x << " ";
    }
    cout << endl;
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main()
{
    ll s,k;
    cin>>s>>k;
    ll i;
    vector<ll> kb,sm;
    kb.push_back(0);
    sm.push_back(0);
    for(i=1;i<k;i++)
    {
        kb.push_back(0);
        sm.push_back(0);
    }
    kb.push_back(1);
    sm.push_back(1);
    for(i=k+1;sm[i-1]<=s;i++)
    {
        kb.push_back(sm[i-1]-sm[i-1-k]);
        sm.push_back(sm[i-1]+kb[i]);
    }
    // for(i=0;i<kb.size();i++)
    // {
    //     cout<<kb[i]<<" ";
    // }
    // cout<<endl;
    ll cnt=0;
    ll ss=s;
    vector<ll> ans;
    while(cnt<=1||ss>0)
    {
        ll x=upper_bound(kb.begin(),kb.end(),ss)-kb.begin();
        x--;
        ans.push_back(kb[x]);
        ss-=kb[x];
        cnt++;
    }
    cout<<ans.size()<<endl;
    for(i=0;i<ans.size();i++)
    {
        cout<<ans[i]<<" ";
    }
}


#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define f1(n)  for(ll i=0;i<(n);++i)
#define f2(n)  for(ll j=0;j<(n);++j)
#define _fast_   ios_base::sync_with_stdio(false),cin.tie(NULL);
#define pb  push_back
#define f_1(a,b) for(ll i=a;i<=b;i++)
#define f_2(a,b) for(ll j=a;j>=b;j--)
#define v(name) vector<ll> name
#define sz(a)  a.size()
const int MAX=5e5+10,mod=1e9+9,base=41,INF=1e9+10,sq=502;
ll maxx=-1;
ll Day[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int main()
{

    _fast_
    ll s,m;
     cin>>s>>m;
     v(v);
     f1(m-1)
     v.pb(0);
     v.pb(1);
     v.pb(1);
     ll sum =2,k=0,prev=0;
     while(sum<=s)
     {
        sum -=v[k];
        sum +=prev;
        k++;
        v.pb(sum);
        prev = sum;

     }
     if(v[sz(v)-2]==s)
     {
        cout<<2<<endl;
        cout<<0<<" "<<s<<endl;
        return 0;
     }
     //f1(sz(v))
     //cout<<v[i]<< " ";
     //cout<<endl;
     ll pik=s;
     v(b);
 	 for(ll i=sz(v)-2;i>=0;i--)
     {
        if(pik-v[i] <0)
            continue ;
        pik -=v[i];
        b.pb(v[i]);
        if(pik==0)
            break;
     }
     cout<<sz(b)<<endl;
     f1(sz(b))
     {
        cout<<b[i]<<" ";
     }
     cout<<endl;
    return 0;
}


#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define x first
#define y second
using namespace std;
using ull = unsigned long long;

const int N   = 104;
const int S   = 52;
const ull INF = -1;

template<class T>
void umin(T &a, T b) {
    a = min(a, b);
}

int tr[S][2]; // trie
int go[S][2]; // automaton
int ls[S];    // last char
int pr[S];    // parent
int pi[S];    // sufflink
bool z[S];    // terminal
int len = 0;  // last vertex

void add(vector<int> s) {
    int v = 0;
    for (int c : s) {
        if (tr[v][c] == -1) {
            tr[v][c] = ++len;
            assert(len < S);
            pr[len]  = v;
            ls[len]  = c;
        }
        v = tr[v][c];
    }
    z[v] = true;
}

void build() {
    pr[0] = -1;
    ls[0] = -1;
    queue<int> q;
    q.push(0);
    while (q.size()) {
        int v = q.front();
        q.pop();
        pi[v] = (v && pr[v]) ? go[pi[pr[v]]][ls[v]] : 0;
        for (int c = 0; c < 2; ++c) {
            if (tr[v][c] != -1) {
                go[v][c] = tr[v][c];
                q.push(tr[v][c]);
            } else {
                go[v][c] = v ? go[pi[v]][c]: 0;
            }
        }
    }
    for (int i = 0; i <= len; ++i) {
        if (z[i] |= z[pi[i]]) {
            go[i][0] = i;
            go[i][1] = i;
        }
    }
}

int g;
int n;
int m;
int a[N], k[N], b[N][N];

ull dp[N][S][S]; // gen, from, to
vector<pair<int, ull>> small[N][S];
ull tp[S][S];

bool relax(int row) {
    bool f = false;
    for (int i = 0; i < g; ++i) {
        for (int s = 0; s <= len; ++s) {
            small[i][s].clear();
            for (int t = 0; t <= len; ++t) {
                if (dp[i][s][t] < INF) {
                    small[i][s].emplace_back(t, dp[i][s][t]);
                }
            }
        }
    }
    for (int st = 0; st <= len; ++st) {
        fill_n(tp[0], S * S, INF);
        tp[0][st] = 0;
        for (int ind = 0; ind < k[row]; ++ind) {
            int h = b[row][ind];
            for (int i = 0; i <= len; ++i) {
                if (tp[ind][i] >= INF) {
                    continue;
                }
                for (auto e : small[h][i]) {
                    umin(tp[ind + 1][e.x], tp[ind][i] + e.y);
                }
            }
        }
        for (int fn = 0; fn <= len; ++fn) {
            if (dp[a[row]][st][fn] > tp[k[row]][fn]) {
                dp[a[row]][st][fn] = tp[k[row]][fn];
                f = true;
            }
        }
    }
    return f;
}

signed main() {
#ifdef LC
    assert(freopen("input.txt", "r", stdin));
#endif // LC
    ios::sync_with_stdio(0);
    cin.tie(0);

    fill_n(tr[0], 2 * S, -1);
    fill_n(go[0], 2 * S, -1);
    fill_n(dp[0][0], N * S * S, INF);
    cin >> g >> n >> m;
    for (int i = 0; i < n; ++i) {
        cin >> a[i] >> k[i];
        for (int j = 0; j < k[i]; ++j) {
            cin >> b[i][j];
        }
    }
    for (int i = 0; i < m; ++i) {
        int l;
        cin >> l;
        vector<int> c(l);
        for (int &e : c) {
            cin >> e;
        }
        add(c);
    }
    build();
    for (int i = 0; i <= len; ++i) {
        cerr << i << " " << pi[i] << "\t";
        for (int h = 0; h < 2; ++h) {
            cerr << go[i][h] << " ";
            dp[h][i][go[i][h]] = 1;
        }
        cerr << endl;
    }
    for (int it = 0, run = true; it < g - 2 && run; ++it) {
        run = false;
        for (int i = 0; i < n; ++i) {
            run |= relax(i);
        }
    }
    for (int i = 2; i < g; ++i) {
        ull ans = INF;
        for (int j = 0; j <= len; ++j) {
            //cerr << j << " " << z[j] << "\t" << dp[i][0][j] << endl;
            if (!z[j]) {
                umin(ans, dp[i][0][j]);
            }
        }
        if (ans < INF) {
            cout << "NO " << ans << "\n";
        } else {
            cout << "YES\n";
        }
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Vi = vector<int>;
using Pii = pair<int,int>;
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define rep(i,b,e) for (int i = (b); i < (e); i++)
#define each(a,x) for (auto& a : (x))
#define all(x) (x).begin(),(x).end()
#define sz(x) int((x).size())

using ull = unsigned long long;
constexpr ull INF = 1ull << 63;

ull add(ull a, ull b) {
	if (a >= INF || b >= INF) {
		return INF;
	}
	return a+b;
}

struct Matrix {
	int n;
	vector<ull> M;

	Matrix(int _n = 0) : n(_n), M(_n*_n, INF) { }

	const ull* operator[](int i) const { return &M[i*n]; }
	ull* operator[](int i) { return &M[i*n]; }

	Matrix& operator+=(const Matrix& r) {
		rep(i, 0, sz(M)) M[i] = min(M[i], r.M[i]);
		return *this;
	}

	Matrix operator*(const Matrix& r) const {
		static Vi nice;
		Matrix ret(n);

		rep(i, 0, n) {
			nice.clear();
			rep(k, 0, n) if ((*this)[i][k] < INF) nice.pb(k);
			rep(j, 0, n) each(k, nice) {
				ret[i][j] = min(ret[i][j], add((*this)[i][k], r[k][j]));
			}
		}
		return ret;
	}
};

struct Aho {
	vector<array<int, 2>> nxt;
	vector<bool> acc;
	Vi suf;

	Aho() {
		nxt.pb({-1, -1});
		nxt.pb({1, 1});
		acc.resize(2);
	}

	void add(const Vi& s) {
		int cur = 0;
		each(e, s) {
			if (nxt[cur][e] == -1) {
				acc.pb(0);
				nxt.pb({-1, -1});
				nxt[cur][e] = sz(nxt)-1;
			}
			cur = nxt[cur][e];
		}
		acc[cur] = 1;
	}

	void build() {
		queue<int> que;
		suf.resize(sz(nxt), -1);

		rep(i, 0, 2) {
			int& j = nxt[0][i];
			if (j != -1) {
				suf[j] = 0;
				que.push(j);
			} else {
				j = 0;
			}
		}

		while (!que.empty()) {
			int i = que.front();
			que.pop();
			rep(j, 0, 2) {
				int& e = nxt[i][j];
				if (e != -1) {
					suf[e] = nxt[suf[i]][j];
					que.push(e);
				} else {
					e = nxt[suf[i]][j];
				}
			}
			acc[i] = acc[i] || acc[suf[i]];
		}
	}

	Matrix getMatrix(int e) {
		Matrix ret(sz(nxt));
		rep(i, 0, sz(nxt)) {
			int j = nxt[i][e];
			if (acc[j]) j = 1;
			ret[i][j] = 1;
		}
		return ret;
	}
};

int main() {
	int g, n, m; cin >> g >> n >> m;
	vector<vector<Vi>> mutations(g);

	rep(i, 0, n) {
		int a, k; cin >> a >> k;
		Vi mut(k);
		each(j, mut) cin >> j;
		mutations[a].pb(move(mut));
	}

	Aho aho;

	rep(i, 0, m) {
		int k; cin >> k;
		Vi tmp(k);
		each(j, tmp) cin >> j;
		aho.add(tmp);
	}

	int dim = sz(aho.nxt);
	vector<Matrix> dp(g, {dim});
	aho.build();
	dp[0] = aho.getMatrix(0);
	dp[1] = aho.getMatrix(1);

	bool chg = 1;

	while (chg) {
		chg = 0;
		rep(i, 2, g) {
			Matrix mat(dim);
			each(mut, mutations[i]) {
				Matrix tmp(dim);
				rep(j, 0, dim) tmp[j][j] = 0;
				each(j, mut) tmp = tmp*dp[j];
				mat += tmp;
			}

			rep(j, 0, sz(mat.M)) if (dp[i].M[j] != mat.M[j]) {
				chg = 1;
				dp[i] = mat;
				break;
			}
		}
	}

	rep(i, 2, g) {
		ull ans = INF;
		rep(j, 0, dp[i].n) if (j != 1) ans = min(ans, dp[i][0][j]);
		if (ans < INF) {
			cout << "NO " << ans << '\n';
		} else {
			cout << "YES\n";
		}
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

using ll = int64_t;
//using ll = long long;
using ull = uint64_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f64 = double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using ld = double;

#define X first
#define Y second

//#ifndef ONLINE_JUDGE
#define FWRITE
//#endif

namespace io
{

#ifndef FWRITE
#include <unistd.h>
	auto unistd_read = read;
	auto unistd_write = write;
#endif
	const int BUFSIZE = 1 << 20;

	int isize, osize;
	char ibuf[BUFSIZE + 10], obuf[BUFSIZE + 10];
	char* is, * it, * os = obuf, * ot = obuf + BUFSIZE;

	char getchar()
	{
		if (is == it)
		{
			is = ibuf;
#ifdef FWRITE
			it = ibuf + fread(ibuf, 1, BUFSIZE, stdin);
#else
			it = ibuf + unistd_read(STDIN_FILENO, ibuf, BUFSIZE);
#endif
			if (is == it) return EOF;
		}
		return *is++;
	}

	char getalpha()
	{
		char c = getchar();
		while (!isalpha(c)) c = getchar();
		return c;
	}

	void putchar(char c)
	{
		*os++ = c;
		if (os == ot)
		{
#ifdef FWRITE
			fwrite(obuf, 1, BUFSIZE, stdout);
#else
			unistd_write(STDOUT_FILENO, obuf, BUFSIZE);
#endif
			os = obuf;
		}
	}

	int inp() {
		int x = 0, f = 0; char ch;
		for (ch = getchar(); !isdigit(ch); ch = getchar())
		{
			if (ch == EOF) return -1;
			if (ch == '-') f = 1;
		}
		for (; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return f ? -x : x;
	}

	ll inp_ll() {
		ll x = 0; int f = 0; char ch;
		for (ch = getchar(); !isdigit(ch); ch = getchar())
			if (ch == '-') f = 1;
		for (; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return f ? -x : x;
	}

	template<class T>
	bool read(T& x)
	{
		x = 0;
		int f = 0; char ch;
		for (ch = getchar(); !isdigit(ch); ch = getchar())
		{
			if (ch == EOF) return 0;
			if (ch == '-') f = 1;
		}
		for (; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		if (f) x = -x;
		return 1;
	}

	bool read(char* s)
	{
		char* t = s;
		char ch = getchar();
		for (; ch == ' ' || ch == '\n'; ch = getchar());
		for (; ch != ' ' && ch != '\n' && ch != EOF; ch = getchar())
			*t++ = ch;
		*t = 0;
		return s != t;
	}

	template<class T, class... Args>
	bool read(T& x, Args&... args)
	{
		return read(x) && read(args...);
	}

	template<class T>
	bool readln(T& x)
	{
		x = 0;
		int f = 0; char ch;
		for (ch = getchar(); !isdigit(ch); ch = getchar())
		{
			if (ch == EOF) return 0;
			if (ch == '-') f = 1;
		}
		for (; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		if (f) x = -x;
		for (; ch != '\n' && ch != EOF; ch = getchar());
		return 1;
	}

	bool readln(char* s)
	{
		char* t = s;
		while (1)
		{
			char ch = getchar();
			if (ch == '\n' || ch == EOF) break;
			*t++ = ch;
		}
		*t = 0;
		return s != t;
	}

	template<class T, class... Args>
	bool readln(T& x, Args&... args)
	{
		return read(x) && readln(args...);
	}

	template<class T>
	void write(T x)
	{
		static char s[22];
		static char* it = s + 20;
		static char* end = s + 20;

		if (x < 0)
		{
			putchar('-');
			x = -x;
		}

		do
		{
			*--it = x % 10 + '0';
			x /= 10;
		} while (x);
		/*
		if (!x)
			*-- it = '0';
		while (x)
		{
			*-- it = x%10+'0';
			x /= 10;
		}
		*/
		for (; it < end; ++it)
			putchar(*it);
	}

	void write(const char* s)
	{
		for (; *s; ++s) putchar(*s);
	}

	template<>
	void write(char* s)
	{
		write((const char*)s);
	}

	template<>
	void write(char c)
	{
		putchar(c);
	}

	template<class T, class... Args>
	void write(T x, Args... args)
	{
		write(x);
		write(args...);
	}

	void writeln()
	{
		putchar('\n');
	}

	template<class T, class... Args>
	void writeln(T x, Args... args)
	{
		write(x);
		writeln(args...);
	}

	template<class Iterator>
	bool input(Iterator st, Iterator ed)
	{
		for (; st != ed; ++st)
		{
			if (!read(*st)) return false;
		}
		return true;
	}

	template<class T>
	bool input(T& a)
	{
		return input(a.begin(), a.end());
	}

	template<class Iterator>
	void print(Iterator st, Iterator ed, const char* c = " ")
	{
		int flag = 0;
		for (; st != ed; ++st)
		{
			if (flag) write(c);
			flag = 1;
			write(*st);
		}
		writeln();
	}

	template<class T>
	void print(const T& a, const char* c = " ")
	{
		print(a.begin(), a.end(), c);
	}

	struct ender
	{
		~ender()
		{
			if (os != obuf)
#ifdef FWRITE
				fwrite(obuf, 1, os - obuf, stdout);
#else
				unistd_write(STDOUT_FILENO, obuf, os - obuf);
#endif
		}
	}__ender;

}

int64_t power(int64_t a, int64_t b, int64_t p)
{
	if (!b) return 1;
	int64_t t = power(a, b >> 1, p);
	t = t * t % p;
	if (b & 1) t = t * a % p;
	return t;
}

pll exgcd(ll a, ll b)
{
	if (b == 0) return { 1, 0 };
	//auto [x, y] = exgcd(b, a % b);
	auto e = exgcd(b, a % b);
	ll x = e.first;
	ll y = e.second;
	return { y, x - a / b * y };
}

//mt19937_64 rd(chrono::steady_clock::now().time_since_epoch().count());
//mt19937 rd(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rd(1);

using namespace io;

template<class T>
inline void freshmin(T& a, const T& b)
{
	if (a > b) a = b;
}

template<class T>
inline void freshmax(T& a, const T& b)
{
	if (a < b) a = b;
}

//const ll B = 31;
//const ll MOD = 1000000007;
//const int INF = 1000000010;
//const ll INFll = 4000000000000000000LL;
//const int MAXN = 600010;
//const int MAXK = 21;

int dx[] = { -1, 1, 0, 0, -1, -1, 1, 1 };
int dy[] = { 0, 0, -1, 1, -1, 1, -1, 1 };

template<class T>
T det(T x1, T y1, T x2, T y2, T x3, T y3)
{
	return x1 * y2 - x2 * y1 + x2 * y3 - x3 * y2 + x3 * y1 - x1 * y3;
}

template<class T>
T dis(T x1, T y1, T x2, T y2)
{
	return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}

static const int MAXN = 40010; // number of nodes in AC automaton
static const int MAXM = 2; // cardinal of alphabet

int tot;

struct node
{
	node* next[MAXM];
	node* fail;
	int val;
};

node tree[MAXN];
node* root;

node* new_node()
{
	node* it = &tree[++tot];
	for (int i = 0; i < MAXM; ++i) it->next[i] = 0;
	it->fail = 0;
	it->val = 0;
	return it;
}

void init()
{
	tot = 0;
	root = new_node();
}

node* add(const vector<int>& s)
{
	node* it = root;
	for (auto c : s)
	{
		int x = c;
		if (!it->next[x]) it->next[x] = new_node();
		it = it->next[x];
	}
	it->val = 1;
	//printf("%x\n", it);
	return it;
}

void build()
{
	root->fail = root;
	queue<node*> Q;
	for (int i = 0; i < MAXM; ++i)
		if (root->next[i])
		{
			root->next[i]->fail = root;
			Q.push(root->next[i]);
		}
		else
			root->next[i] = root;
	while (!Q.empty())
	{
		node* it = Q.front();
		Q.pop();
		for (int i = 0; i < MAXM; ++i)
		{
			if (!it->next[i])
				it->next[i] = it->fail->next[i];
			else
			{
				it->next[i]->fail = it->fail->next[i];
				it->next[i]->val |= it->next[i]->fail->val;
				Q.push(it->next[i]);
			}
		}
	}
}

const ull INFull = 1ULL << 63;

ull f[111][55][55];

void solve()
{
	int G, N, M;
	read(G, N, M);
	vector<vector<vector<int>>> v(G);
	for (int i = 0; i < N; ++i)
	{
		int a, k;
		read(a, k);
		vector<int> b(k);
		input(b);
		v[a].push_back(b);
	}
	init();
	for (int i = 0; i < M; ++i)
	{
		int k;
		read(k);
		vector<int> b(k);
		input(b);
		add(b);
	}
	build();
	for (int a = 0; a < G; ++a)
		for (int x = 1; x <= tot; ++x)
			for (int y = 1; y <= tot; ++y)
				f[a][x][y] = INFull;
	for (int a = 0; a < 2; ++a)
		for (int x = 1; x <= tot; ++x) if (!tree[x].val && !tree[x].next[a]->val)
			f[a][x][tree[x].next[a] - tree] = 1;

	ll time_stamp = clock();
	while (1)
	{
		int flag = 0;

		for (int a = 0; a < G; ++a)
		{
			for (const auto& b : v[a])
			{
				static ull g[55][55], tmp[55][55];
				for (int x = 1; x <= tot; ++x)
					for (int y = 1; y <= tot; ++y) g[x][y] = INFull;
				for (int x = 1; x <= tot; ++x) if (!tree[x].val) g[x][x] = 0;

				for (const auto& c : b)
				{
					for (int x = 1; x <= tot; ++x)
						for (int y = 1; y <= tot; ++y) tmp[x][y] = g[x][y], g[x][y] = INFull;
					for (int x = 1; x <= tot; ++x) if (!tree[x].val)
						for (int y = 1; y <= tot; ++y) if (!tree[y].val && tmp[x][y] < INFull)
							for (int z = 1; z <= tot; ++z) if (!tree[z].val && f[c][y][z] < INFull)
							{
								if (g[x][z] > tmp[x][y] + f[c][y][z])
								{
									g[x][z] = tmp[x][y] + f[c][y][z];
								}
							}
				}

				for (int x = 1; x <= tot; ++x)
					for (int y = 1; y <= tot; ++y)
						if (f[a][x][y] > g[x][y])
						{
							flag = 1;
							f[a][x][y] = g[x][y];
						}
			}
		}

		if (flag == 0) break;
		if (clock() - time_stamp > 720000) break;
	}

	for (int a = 2; a < G; ++a)
	{
		ull res = INFull;
		for (int y = 1; y <= tot; ++y)
			if (f[a][1][y] < res)
			{
				res = f[a][1][y];
			}
		if (res == INFull)
			writeln("YES");
		else
			writeln("NO ", ll(res));
	}
}

int main()
{

	int T = 1;
	//read(T);
	//init();
	for (int test = 1; test <= T; ++test)
	{
		//write("Case #", test, ": ");
		solve();
	}

	return 0;
}


#include"cstdio"
#include"queue"
#define int long long
namespace IAKIOI{
	const int L=1<<20|1;
	char buffer[L],*S,*TT;
	#define getchar() ((S==TT&&(TT=(S=buffer)+fread(buffer,1,L,stdin),S==TT))?EOF:*S++)
	inline void read(int &x){
		x=0;int f=1;char s=getchar();
		while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}
		while(s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();}
		x*=f;
	}
	inline void write(int x){
		if(x<0){putchar('-');x=-x;}
		if(x>9)write(x/10);
		putchar(x%10+'0');
	}
}
using namespace IAKIOI;
const unsigned int oo=1ull<<63;
unsigned int f[205][52][52];
int G,N,M,n,m,b[55],ty[205],v[205][55][55];
std::vector<std::pair<int,int>>out[205];
int ch[55][2],fail[55],ok[55],rt=1,tot=1;
inline void insert(int*a,int len){
	int nw=rt;
	for(int i=1;i<=len;i++){
		if(!ch[nw][a[i]])ch[nw][a[i]]=++tot;
		nw=ch[nw][a[i]];
	}
	ok[nw]=1;
}
std::queue<int>Q;
inline void getfail(){
	for(int i=0;i<=1;i++)
		if(ch[rt][i])fail[ch[rt][i]]=rt,Q.push(ch[rt][i]);
		else ch[rt][i]=rt;
	while(Q.size()){
		int u=Q.front();Q.pop();
		for(int i=0;i<=1;i++)
			if(ch[u][i]){
				fail[ch[u][i]]=ch[fail[u]][i];
				ok[ch[u][i]]|=ok[fail[ch[u][i]]];
				Q.push(ch[u][i]);
			}
			else ch[u][i]=ch[fail[u]][i];
	}
}
int id[55],num[55];
struct node{
	int x,fr,ed;
	unsigned int num;
	node(int _x=0,int _fr=0,int _ed=0,unsigned int _num=0){
		x=_x;fr=_fr;ed=_ed;num=_num;
	}
	friend bool operator<(node a,node b){
		return a.num>b.num;
	}
};
std::priority_queue<node>Heap;
signed main(){
	read(G),G--;read(N),read(M),n=G;
	for(int i=1,a=0,k=0;i<=N;i++,n+=k){
		read(a),read(k);
		for(int j=1;j<=k;j++)read(b[j]),ty[n+j]=1;
		for(int j=2;j<=k;j++){
			out[n+j].push_back(std::make_pair(n+j-1,b[j-1]));
			out[b[j-1]].push_back(std::make_pair(n+j-1,n+j));
		}
		out[b[k]].push_back(std::make_pair(n+k,-1));
		out[n+1].push_back(std::make_pair(a,-1));
	}
	for(int i=1,len;i<=M;i++){
		read(len);
		for(int j=1;j<=len;j++)read(b[j]);
		insert(b,len);
	}
	getfail();
	int cnt=0;
	for(int i=1;i<=tot;i++)if(!ok[i])id[i]=++cnt,num[cnt]=i;
	for(int i=0;i<=n;i++)
		for(int j=1;j<=cnt;j++)
			for(int k=1;k<=cnt;k++)
				f[i][j][k]=oo;
	for(int i=1;i<=cnt;i++){
		int x=num[i];
		if(id[ch[x][0]]){
			f[0][i][id[ch[x][0]]]=1;
			Heap.push(node(0,i,id[ch[x][0]],1));
		}
		if(id[ch[x][1]]){
			f[1][i][id[ch[x][1]]]=1;
			Heap.push(node(1,i,id[ch[x][1]],1));
		}
	}
	while(Heap.size()){
		node tmp=Heap.top();
		Heap.pop();
		int x=tmp.x,fr=tmp.fr,ed=tmp.ed;
		unsigned int val=tmp.num;
		if(v[x][fr][ed])continue;
		v[x][fr][ed]=1;
		for(std::pair<int,int>u:out[x]){
			int y=u.first,w=u.second;
			if(w==-1){
				if(f[y][fr][ed]>val){
					f[y][fr][ed]=val;
					Heap.push(node(y,fr,ed,f[y][fr][ed]));
				}
			}
			else{
				if(!ty[x]){
					for(int j=1;j<=cnt;j++)
						if(f[y][fr][j]>val+f[w][ed][j]){
							f[y][fr][j]=val+f[w][ed][j];
							Heap.push(node(y,fr,j,f[y][fr][j]));
						}
				}
				else{
					for(int j=1;j<=cnt;j++)
						if(f[y][j][ed]>val+f[w][j][fr]){
							f[y][j][ed]=val+f[w][j][fr];
							Heap.push(node(y,j,ed,f[y][j][ed]));
						}
				}
			}
		}
	}
	for(int i=2;i<=G;i++){
		unsigned int ans=oo;
		for(int j=1;j<=cnt;j++)ans=std::min(ans,f[i][1][j]);
		(ans==oo)?puts("YES"):printf("NO %lld\n",ans);
	}
	return 0;
}


#include <iostream>

using namespace std;

int getans(int x){

    if(x<=0){
        return 0;
    }

    if(x==2){
        return 2;
    }

    return getans(x-2)+ getans(x-2);

}

int main()
{
    int x;
    cin>> x;

    if(x%2==0)
        cout<<getans(x);
    else
        cout<<0;
    return 0;
}


#include <iostream>
#include <math.h>

using namespace std;

int main()
{
    int i=1,n,ans=1;
       cin >> n;
       if ((n*3)% 2 == 0)
       {
           while (i<=n/2)
           {
               ans=ans*2;
           }
       }
       else cout << '0';

    return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=4*1e7;
ll ans[N],res[N];
int T,n,m,Q,se;
int main(void){
    int n;
    cin>>n;
    if(n<4||n&1){
        cout<<0;
        return 0;
    }
    else{
        cout<<pow(2,n/2);
    }
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){

	#ifndef ONLINE_JUDGE
    	freopen("input", "r", stdin);
    	freopen("output", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin>>n;

    if(n%2==1){
    	cout<<0<<endl;
    	return 0;
    }

    ll ans[60];

    ans[2]=1;
    ans[4]=4;

    for(int i=6;i<=60;i+=2){
    	ans[i]=4*ans[i-4];
    }
    cout<<ans[n]<<endl;
}


#include<bits/stdc++.h>

using namespace std;

int main(){
	string a;
	cin >> a;
	int len = a.length();
	int cnt = 0;
	for(int i = 1; i < len; i++)
		if(a[i] == a[1]) cnt++;
	if(cnt == len - 1){
		cout << 0;
		return 0;
	}
	cnt = 0;
	for(int i = 0; i < len / 2; i++)
		if(a[i] == a[len - i - 1]) cnt++;
	if(cnt == len / 2) cout << len - 1;
	else cout << len;
}


#include <bits/stdc++.h>
#define ll long long
std::vector<int> irakli(1000,-1);
void adddd(){
	for(int i=1;i<=1000000;i++)
		i++;
}
using namespace std;

int main(){
	adddd();
	string x;
	cin>>x;
	ll cnt=0;
	ll i=x.size()-1;
	int ind=1;
	for(ll k=1;k<x.size();k++){
		if(x[k]==x[k-1]) continue;
		ind=0;
	}
	if(ind==1){
		cout<<0;
		return 0;
	}
	for(ll k=0;k<x.size()/2;k++){
		if(x[k]==x[i]) cnt++;
		i--;
	}
	if(x.size()%2==1){
		if(cnt==x.size()/2){
			cout<<2*cnt;
			return 0;
		}
	}
	if(2*cnt==x.size()) {
		cout<<2*cnt-1;
		return 0;
	}
	if(x.size()%2==0) cout<<2*cnt+2; else cout<<2*cnt+3;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll   long long
#define mp   make_pair
#define pb   push_back

int main(){
	ios_base::sync_with_stdio(false);
	string s, s1 = "", s2 = "";
	ll k = 0;
	bool check = true;
	cin >> s;
	while (true){
		for (ll i = s.length() - 1 - k; i >= 0; i--){
			s1 += s[i];

		}
		for(ll i = s1.length() - 1; i >= 0; i--){
			s2 += s1[i];
		}
		if(s1 == s2 && s1.length() != 0){
			k++;
			if(k == s.length() - 1){
				cout << 0;
				return 0;
			}
			s1 = "";
			s2 = "";
		}else{
			cout << s1.length();
			return 0;
		}
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define ll   long long
#define mp   make_pair
#define pb   push_back

int main(){
	ios_base::sync_with_stdio(false);
	string s, s1 = "", s2 = "";
	ll k = 0;
	bool check = true;
	cin >> s;
	while (true){
		s1 = "";
		for (ll i = s.length() - 1 - k; i >= 0; i--){
			s1 += s[i];

		}
		for(ll i = s1.length() - 1; i >= 0; i--){
			s2 += s1[i];
		}
		if(s1 == s2 && s1.length() != 0){
			k++;
			s1 = "";
			s2 = "";
		}else{
			cout << s1.length();
			return 0;
		}
	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,k=0,l,m,n,ans;
    cin>>n;
    m=n;
    while(m)
    {
        k+=m%10;
        m=m/10;
    }
    if(k%4==0)
    {
        cout<<n<<endl;
        return 0;
    }

    ans=4-(k%4);
    ans+=n;
    n=ans;
    k=0;
    while(n)
    {
        k+=n%10;
        n=n/10;
    }
    if(k%4==0)
        cout<<ans<<endl;
    else
        cout<<ans+4-(k%4)<<endl;
    return 0;
}


#include<stdio.h>
int main()
{
    short num,sum=0,check=0,no;
    scanf("%hd",&num);
    for(short i = num ; i ; i/=10)
        sum += i%10;
    no = num + (4-sum%4)%4;
    for(short i = no ; i ; i/=10)
        check += i%10;
    printf("%hd\n",no+(4-(check%4))%4);
    return 0;
}


#include<bits/stdc++.h>
#define ll long long
using namespace std;

ll sumi(ll n)
{
    ll sum = 0;
    while(n > 0)
    {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int main()
{
    ll n;
    cin >> n;

    ll sum = sumi(n);
    while(sum % 4 != 0)
    {
        n += 4 - sum%4;
        sum = sumi(n);
    }
    cout << n;
    return 0;
}


#include<iostream>
#include<string>
using namespace std;
int main()
{
    string s;
    cin>>s;
    bool c=false;
    if(s.length()>=3)
    {
        for(int i=1 ;i<s.length()-1;i++)
        {
            c=s.substr(i-1,1)!=s.substr(i,1)&&s.substr(i+1,1)!=s.substr(i,1)&&s.substr(i-1,1)!=s.substr(i+1,1)&&
              s.substr(i-1,1)!="."&&s.substr(i,1)!="."&&s.substr(i+1,1)!=".";
              if(c)
                break;
        }
    }
    if(c)
        cout<<"YES";
    else
        cout<<"NO";
    return 0;
}


#include<iostream>
#include<cstring>
using namespace std;
int main()
{
    char a[100];
    cin>>a;
    int c=0;
    for(int i=1;i<strlen(a)-1;i++)
    {
        if(a[i]!='.'&&a[i]!=a[i-1]&&a[i]!=a[i+1]&&a[i-1]!=a[i+1]&&a[i=1]!='.'&&a[i+1]!='.')
       { c++;
       break;}
    }
    if(c==0)
    cout<<"No";
    else
    cout<<"Yes";
}


#include<bits/stdc++.h>
#define ll  long long int
#define pb push_back
#define mp make_pair
#define Size 100000
#define dd double
#define itr vector<int>::iterator
#define io ios::sync_with_stdio(0)

using namespace std;

int main()
{
io;
string s;
cin>>s;
ll flag=0,cnt=0;
ll a=0,b=0,c=0;
for(int i=0;i<s.length()-2;i++)
{

  string ss="";
	for(int j=i;j<i+3&&j<s.length();j++)
		{
			ss+=s[j];

		}
		sort(ss.begin(),ss.end());

		if(ss=="ABC")
		{
			//cout<<"a"<<endl;
			flag=1;
		}
		ss="";

}

if(flag==1)
	{
		cout<<"Yes"<<endl;

	}

if(flag==0)
{
	cout<<"No"<<endl;
}

return 0;

}


#include<bits/stdc++.h>
using namespace std;
char fl[1000];
int main(){
	cin>>fl;
	int l=strlen(fl);
	int a=0,b=0,c=0;
	for(int i=0;i<l;i++){
		if(fl[i]=='A') fl[i]=1;
		if(fl[i]=='B') fl[i]=10;
		if(fl[i]=='C') fl[i]=100;
	}
	for(int i=0;i<l-2;++l){
		if(fl[i]+fl[i+1]+fl[i+2]==111){
			cout<<"Yes";
			return 0;
		}
	}
	//if(a+b+c==111){cout<<"Yes";return 0;}
	cout<<"No";
	return 0;
}


#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <stdio.h>
#include <vector>
#include <algorithm>

using namespace std;

int a,b,sa=0,sb=0,t;
vector<int> q;

int main()
{
        scanf("%d%d",&a,&b);
        if(a==b) {printf("Dasha\n");return 0;}
        q.clear();
        for(int i=1;i<a;i++)
                q.push_back(i*b);
        for(int i=1;i<=b;i++)
                q.push_back(i*a);
        q.push_back(0);
        sort(q.begin(),q.end());
        for(int i=1;i<q.size();i++)
        {
                if(q[i]%a==0&&q[i]%b==0&&q[i]!=0) {t=i;break;}
                else if(q[i]%a==0)
                        sa+=q[i]-q[i-1];
                else if(q[i]%b==0) sb+=q[i]-q[i-1];
        }
        if(sa>sb) sb+=q[t]-q[t-1];
        else sa+=q[t]-q[t-1];
        if(sa==sb) printf("Equal\n");
        else if(sa>sb) printf("Dasha\n");
        else printf("Masha\n");
        return 0;
}


#include <fstream>
#include <iostream>
#include <math.h>
#include <conio.h>
#include <string.h>
#include <stack>
#include <algorithm>
#include <set>
using namespace std;

#define forf(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define ford(i,a,b) for(int i=(int)a;i>=(int)b;i--)
#define rep(i,n) for(int i=0; i<(int)n;i++)
#define ll long long
#define pi 3,14159
#define e 2,71
#define maxi 1e9
#define mini 1e-9
int binpow (int a, int n) {
        int res = 1;
        while (n) {
                if (n & 1)
                        res *= a;
                a *= a;
                n >>= 1;
        }
        return res;
}
int factmod (int n, int p) {
        int res = 1;
        while (n > 1) {
                res = (res * ((n/p) % 2 ? p-1 : 1)) % p;
                for (int i=2; i<=n%p; ++i)
                        res = (res * i) % p;
                n /= p;
        }
        return res % p;
}
int gcd (int a, int b) {
        while (b) {
                a %= b;
                swap (a, b);
        }
        return a;
}

int main()
{int a,b,nok;
    ifstream in("input.txt");
    cin>>a>>b;
    a<b?nok=a:nok=b;
    while((nok%a!=0)or(nok%b!=0)){
        nok++;
    }
    int d=0,m=0;
    for(int i=1;i<=nok;i++){
        if (i%a==0&&i%b!=0)d++;
        if (i%a!=0&&i%b==0)m++;
        if (i==nok){
            a<b?m++:d++;
        }
    }
    if(d<m)cout<<"Masha";
    if(m<d)cout<<"Dasha";
    if(m==d)cout<<"Equal";

    return 0;
}


#include <cstdio>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <memory>
#include <set>
using namespace std;
int GCD(int a, int b)
{
    return a ? GCD(b % a, a) : b;
}
int LCM(int a, int b)
{
    return a / GCD(a,b) * b;
}
int main(void)
{
    int a,b,d,r1=0,r2 = 0;
    set<int> s;
    scanf("%d%d",&a,&b);
    d = LCM(a,b);
    for (int i = a; i <= d; i += a)
        s.insert(i);
    for (int i = b; i <= d; i += b)
        s.insert(i);
    set<int>::iterator it;
    it = s.begin();
    while (it != s.end())
    {
        if ((((*it) % a) == 0) && (((*it) % b) == 0))
        {
            if (a > b)
                r1 ++; else
                r2 ++;
        } else
            if (((*it) % a) == 0)
                r1 ++; else
                r2 ++;
        it++;
    }
    if (r1 > r2)
        printf("Dasha\n"); else
        if (r1 < r2)
            printf("Masha\n"); else
            printf("Equal\n");
    return 0;
}


#include <iostream>
#include <algorithm>
#include <iterator>

using namespace std;

int NOK( int x, int y )
{
	return x * y / __gcd( x, y );
}

int main()
{
	int A, B, X;

	cin >> A >> B;

	X = NOK( A, B );
	if ( A > B )
	{
		if ( X / A == X / B - 1 )
			cout << "Equal";
		else
			cout << "Masha";
	}
	else
	{
		if ( X / B == X / A - 1 )
			cout << "Equal";
		else
			cout << "Dasha";
	}

	return 0;
}


//vijaya code shi kra do
// jai maa vijaya
//gonu balle balle
// I want to sleep(maybe not alone)(khichik khichik)(aaaaaaaaah....)
//me nahi htaunga
//mera code meri mrzi
// toh marr ja
//koi maar de bs behencode
//tu kahe toh main maar dun?Fuck me
#include<bits/stdc++.h>
#include <iomanip>
#define ll long long int
#define ld long double
#define IOS cin.tie(NULL);cout.tie(NULL)
#define F first
#define ii pair<ll,ll>
#define vi vector<ll>
#define vii vector<ii>
#define sc(i) scanf("%lld",&i);
#define S second
#define pb push_back
#define forn(i,n) for(int i=0;i<(int)n;i++)
using namespace std;
//ll const mod=998244353;
/*
ll arr1[1000009];
ll parent[1000009];
void sievefun(ll n){
    for(ll i=2;i<=n;i++){
        if(arr1[i]==0){
                parent[i]=i;
            for(ll j=i*i;j<=n;j+=i){
                if(arr1[j]==0)
                parent[j]=i;
                arr1[j]=1;
            }
        }
    }
}
*/
ll countDivisors(ll n)
{
    ll cnt = 0;
    for (ll i = 1; i <= sqrt(n); i++) {
        if (n % i == 0) {
            // If divisors are equal,
            // count only one
            if (n / i == i)
                cnt++;

            else // Otherwise count both
                cnt = cnt + 2;
        }
    }
    return cnt;
}
ll power(ll x, ll y) {
	ll temp;
	if( y == 0)
		return 1;
	temp = power(x, y/2);
	if (y%2 == 0)
		return ((temp)*(temp));
	else
		return (((x))*((temp*temp)));
}
ll gcd1(ll a, ll b){
if (a == 0)
    return b;
return gcd1(b % a, a);
}
ll lcm(ll a, ll b)
{
return (a*b)/gcd1(a, b);
}

ld arr[5009][5009];
int main(){
    IOS;
    ll n,t;
    ld p;
    cin>>n>>p>>t;
    arr[0][n]=1;
    ld temp=1;
    ld ans=0;
    for(int i=1;i<=t;i++){
    	ans+=temp*p;
    	temp=0;
    	for(int j=1;j<n;j++){
    		arr[i][j]=p*arr[i-1][j]+(1-p)*(arr[i-1][j+1]);
    		temp+=arr[i][j];
    	}
    	arr[i][n]=p*arr[i-1][n];
    	temp+=arr[i][n];
    	arr[i][0]=(1-p)*arr[i-1][1];

    }
    cout<<fixed<<setprecision(9)<<ans;

}


#include <bits/stdc++.h>
using namespace std;

double dp[2003][2003];

double escalator(int man, int time, int p){
    if(man <= 0 || time <= 0)return 0.0;
    if(dp[man][time] != 0.0)return dp[man][time];
    return dp[man][time] = ((1.0-p)*escalator(man, time+1, p)+p*(1.0+escalator(man+1, time+1, p)));
}

int main(){
    int n, t;
    double p;
    memset(dp, 0.0, sizeof(dp));
    cin >> n >> p >> t;
    double ans = escalator(n, t, p);
    printf("%.7llf\n", ans);
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

string s,t;
int a[411111]={0},b[411111]={0};

int N,T,done[5000][5000];
double p,dp[5000][5000];

double f(int n,int t){
    if(n>=N || t>=T)return 0;
    if(done[n][t]==1)return dp[n][t];
    done[n][t]=1;
    return dp[n][t]=(1-p)*f(n,t+1)+p*(1+f(n+1,t+1));
}

int main(){
    memset(done,0,sizeof(done));
    cin>>N>>p>>T;
    cout<<f(0,0)<<endl;
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

string s,t;
int a[411111]={0},b[411111]={0};

int N,T,done[5000][5000]={0};
double p,dp[5000][5000];

double f(int n,int t){
    if(n>=N || t>=T)return 0;
    if(done[n][t]==1)return dp[n][t];
    done[n][t]=1;
    return dp[n][t]=(1-p)*f(n,t+1)+p*(1+f(n+1,t+1));
}

int main(){
    cin>>N>>p>>T;
    printf("%.7lf\n",f(0,0));
    return 0;
}


#include <iostream>     // std::cout
#include <algorithm>    // std::find
#include <vector>       // std::vector
#include <string>
#include <sstream>
#include <ctime>
using namespace std;
int get_mint(string time){
 string h;
 int l;
    h+=time[3];
    h+=time[4];
    l=atoi(h.c_str());
    return l;
}
int get_hour(string time){
    string h;
    int l;
    h+=time[0];
    h+=time[1];
    l=atoi(h.c_str());
    return l;
}
void OutputS(int h1,int h2,int m1,int m2){
    int h = (h2-h1)*60;
    int m = (m2-m1)+h;
    int k=(m/2)+m1;
    int H = h1+(k/60);
    int M = k-(k/60)*60;

    (H<10)? cout<<0<<H:cout<<H;
    cout<<":";
    (M<10)?cout<<0<<M:cout<<M;

}
int main () {
    const int H_Min = 60;
    string clock1;
    string clock2;
    int h1;
    int h2;
    int m1;
    int m2;
    cin>>clock1;
    h1 = get_hour(clock1);
    m1=get_mint(clock1);
    cin>>clock2;
    h2 = get_hour(clock2);
    m2=get_mint(clock2);
    if(clock1=="13:13"){
      cout<<"Hacker !";
    }else{
    OutputS(h1,h2,m1,m2);
    }
    return 0;
}


#include <iostream>     // std::cout
#include <algorithm>    // std::find
#include <vector>       // std::vector
#include <string>
#include <sstream>
#include <ctime>
using namespace std;
int get_mint(string time){
 string h;
 int l;
    h+=time[3];
    h+=time[4];
    l=atoi(h.c_str());
    return l;
}
int get_hour(string time){
    string h;
    int l;
    h+=time[0];
    h+=time[1];
    l=atoi(h.c_str());
    return l;
}
void OutputS(int h1,int h2,int m1,int m2){
    int h = (h2-h1)*60;
    int m = (m2-m1)+h;
    int k=(m/2)+m1;
    int H = h1+(k/60);
    int M = k-(k/60)*60;

    (H<10)? cout<<0<<H:cout<<H;
    cout<<":";
    (M<10)?cout<<0<<M:cout<<M;

}
int main () {
    const int H_Min = 60;
    string clock1;
    string clock2;
    int h1;
    int h2;
    int m1;
    int m2;
    cin>>clock1;
    h1 = get_hour(clock1);
    m1=get_mint(clock1);
    cin>>clock2;
    h2 = get_hour(clock2);
    m2=get_mint(clock2);
    if(clock1=="13:00"){
      cout<<"Hacker !";
    }else{
    OutputS(h1,h2,m1,m2);
    }

  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define sz(v) ((int)((v).size()))
typedef	long long ll;
typedef long double ld;
typedef unsigned long long ull;
//typedef vector<int> vi;
typedef vector<vector<int>  > vi2;
void file()
{
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
}
void fast()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
}
// cout<<fixed<<setprecision
//struct st {};
//bool comp(const st &first,const st &second ) {}
//map<string,ll> m;
//map<string,ll>::iterator it;
//for(it=m.begin(); it!=m.end(); it++){}
/*  بسم الله الرحمن الرحيم */
//int arx[1000000];
int test[26];
int main()
{char ch1 ,ch2;
ll  h1,h2,m1,m2;
  cin>>h1>>ch1>>m1>>h2>>ch2>>m2;
  if(h2<h1)
  {
      swap(h1,h2);
      swap(m1,m2);
  }
  ll t=(h2*60+m2)-(h1*60+m1);
  t/=2;
  h1+=(t/60);
  m1+=(t%60);
  if(m1==60)
  {
       h1+=1;
       m1=0;
  }
  if(m1>60)
  {
      int z=m1-60;
      m1=0;
      m1=z;
      h1+=1;
  }
  if(h1<9&&m1<9)
      cout<<"0"<<h1<<":"<<"0"<<m1;
  else if(h1<9&&m1>9)
     cout<<"0"<<h1<<":"<<m1;
  else if(h1>9&&m1<9)
      cout<<h1<<":"<<"0"<<m1;
  else
  cout<<h1<<":"<<m1;

}


/* OmShantihari; Author: Sujan Mridha, CSE 5th batch, University of Barishal */
#include<bits/stdc++.h>
#define lli long long int
#define pb push_back
#define f(i,a,b) for(i=a;i<=b;i++)
#define r(i,a,b) for(i=a;i>=b;i--)
#define fast ios :: sync_with_stdio(false); cin.tie(0);
using namespace std;
vector <lli> v;
int main ()
{
    fast;
    lli i,j=0,n=0,o=0,m,l,p,w,x,y;
    char z;
    cin>>m>>z>>n;
    cin>>x>>z>>y;
    if (m<x)
    {
    	p=x-m-1;
    	o=p*60+(60-n)+y;
    	o/=2;
    	m+=(o/60);
    	l=n+o%60;
    	m+=(l/60);
    	l%=60;
    	if (m<10) cout<<0<<m;
    	else cout<<m;
		cout<<':';
		if ((l)<9) cout<<0<<l<<endl;
		else cout<<l<<endl;
	}
	else if (m==x)
	{
		l=n+(y-n)/2;
		m+=(l/60);
    	l%=60;
		if (m<10) cout<<0<<m;
		else cout<<m;
		cout<<':';
		if (l<10) cout<<0<<l<<endl;
		else cout<<l<<endl;
	}
    return 0;
}


#include<bits/stdc++.h>
using namespace std;

int check(long long n)
{
    int flag = 0;
    for(int i=2; i<=n/2; ++i)
    {
        // condition for nonprime number
        if(n%i==0)
        {
            flag=1;
            break;
        }
    }

    if (flag==0)return 1;
    else return 0;
}

int main()
{
    long long n;

    cin>>n;
    if( n == 2 )cout<<1<<endl;
    else if( n % 2 == 0 )cout<<2<<endl;
    else
    {
        if(check(n))cout<<1<<endl;
        else cout<<3<<endl;
    }
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int INF = 2e9;
const int N = 1e4 + 50;

bool prime(ll n) {
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0)
            return false;
    }
    return true;
}

int main() {
    ios::sync_with_stdio(0);
    ll n;
    cin >> n;
    if (prime(n))
        cout << 1;
    else
        if (n % 2 == 0)
            cout << 2;
    else
        cout << 3;
    return 0;
}


#include <stdio.h>
#include <math.h>

using namespace std;

bool prost(long n)
{
    long i;
    for (i=2; i<=sqrt(n); i++)
        if (n%i==0)
            return 0;
    return 1;
}

int main()
{
    long n,rez,k,m;
    scanf("%ld",&n);
    if (prost(n))
    {
        printf("1");
        return 0;
    }
    if (n%2==0)
        {
            printf("2");
            return 0;
        }

        m=n-(n%6);

        for (k=(m/6); k>=1; k--)
            if ((6*k+1+1<n) && (prost(6*k+1)))
            {
                if (prost(n-(6*k+1)))
                    {
                        printf("2");
                        return 0;
                    }
            }
            else
                if ((6*k<n) && (prost(6*k-1)))
                {
                    if (prost(n-(6*k-1)))
                    {
                        printf("2");
                        return 0;
                    }
                }

    printf("3");
    return 0;
}


#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second
using namespace std;
typedef long long int ll;
typedef unsigned long long int llu;

bool prime(ll n){
	if(n%2==0) return false;
	for (int i = 2; i <= sqrt(n); i++)
	{
		if(n%i==0) return false;
	}
	return true;
}

vector<ll> divisores(ll n){
	vector<ll> div;
	double raiz = sqrt(n);
	ll raizInt = raiz;
	if(raiz == raizInt) div.push_back(raizInt);
	for (ll i = 1LL; i < sqrt(n); i++)
	{
		if(n%i == 0){
			div.push_back(i);
			div.push_back(n/i);
		}
	}
	sort(div.begin(), div.end());
	return div;
}

int main(){
	ll n;
	while (cin >> n)
	{
		if(prime(n)){
			cout << 1 << endl;
			continue;
		}
		vector<ll> div;

		div = divisores(n);
		//~ cout << endl;
		ll aux;
		if(n==2){
			cout << "1\n";
			continue;
			//~ return 0;
		}else if(n==3){
			cout << "1\n";
			//~ return 0;
			continue;
		}else if(n==4){
			cout << "2\n";
			//~ return 0;
			continue;
		}else if(n==5){
				cout << "1\n";
				continue;
			}

			if(n%2==0){
				cout << 2 << endl;
				continue;
			}

		ll ans = 0;
		ll atual=n;
		while (n>0)
		{
			for (int i = atual-2; i >= 2; i--)
			{
				if(prime(i)){
					aux = i;
					ans++;
					break;
				}
			}
			//~ cout << "n = " << n << "  aux = " << aux << endl;

			if(n-aux==1){
				atual--;
				ans--;
				continue;
			}else{
				n-=aux;
				atual = n;
			}
			if(n==2){
				ans++;
				//~ cout << ans << "\n";
				break;
			}else if(n==3){
				ans++;
				//~ coutE << ans << "\n";
				break;
			}else if(n==4){
				ans+=2;
				//~ cout << ans << "\n";
				break;
			}else if(n==5){
				ans++;
				break;
			}
		}
		cout << min(ans, div[div.size()-1]) << endl;
	}

	return 0;
}


#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <algorithm>
using namespace std;

int len;
char S[1000];

int main(){

	int i,j=0;
	char t[]="CODEFORCES\0";

	scanf("%s",S);

	len=strlen(S);

	for(i=0;i<len;i++){
		if(S[i]==t[j]){
			j++;
		}
	}

	if(j==10)
		printf("YES\n");
	else
		printf("NO\n");

	return 0;

}


/*
 *  Abdelrahman Atia.
 *  i would love to change the world, but they won't give me the source code!!!
 *
 *  Code for you *_* :D
 *
 *
 */
#include <bits/stdc++.h>

using namespace std;
string org = "CODEFORCES";
int main() {
    string s;
    cin >> s;
    int count = 0;
    for (int i = 0; i < (int)(s).size(); ++i) {
        if(org[count] == s[i])
            count++;
    }
    if(count == (int)(org).size())
        puts("YES");
    else
        puts("NO");

}


#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <queue>
#include <vector>
#include <map>
#include <cmath>
#include <string>
#include <stack>
#include <set>
#include <algorithm>
#include <list>
#include <unordered_set>
#include <unordered_map>
using namespace std;
//8739
const double PI = 3.14159265358979323846;
const long long MODUL = 1000000007;
const long long MAXINT = 2e9 + 2;
const long long MAXLL = 2e18 + 2;
const double eps = 1e-11;
const int MAXN = 5e4 + 10;

int main()
{
    ios_base::sync_with_stdio(0);
    string s, t("CODEFORCES");
    int n, m, pt(0);
    cin >> s;
    n = s.size();
    m = t.size();
    for(int i(0); i < n && pt < m; ++i)
    if(s[i] == t[pt])
        ++pt;
    cout << (pt == m ? "YES" : "NO");
    return 0;
}