#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


struct Point{
	Point(double arg_x,double arg_y,double arg_z){
		x = arg_x;
		y = arg_y;
		z = arg_z;
	}

	Point(){
		x = y = z = 0.0;
	}

	Point operator + (Point p){ return Point(x+p.x,y+p.y,z+p.z); }
	Point operator - (Point p){ return Point(x-p.x,y-p.y,z-p.z);}
	Point operator * (double a){ return Point(a*x,a*y,a*z); }
	Point operator / (double a){ return Point(x/a,y/a,z/a); }

	double abs(){ return sqrt(norm()); }
	double norm(){ return x*x + y*y + z*z; }

	bool operator == (const Point &p) const{
		return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS && fabs(z-p.z) < EPS;
	}
	double x,y,z;
};

typedef Point Vector;


double mult(Vector a,Vector b){
    return a.x*b.x + a.y*b.y+a.z*b.z;
}

double norm(Vector a){
	return a.x*a.x+a.y*a.y+a.z*a.z;
}

double abs(Vector a){
	return sqrt(norm(a));
}

Vector cross(Vector a,Vector b){
	return Point(a.y*b.z-a.z*b.y,a.z*b.x-a.x*b.z,a.x*b.y-a.y*b.x);
}

int main(){

	Point c1,c2,next1,next2;
	Vector X1,X2,Y1,Y2,Z1,Z2,next_Z2;

	scanf("%lf %lf %lf",&c1.x,&c1.y,&c1.z);
	scanf("%lf %lf %lf %lf %lf %lf",&X1.x,&X1.y,&X1.z,&Y1.x,&Y1.y,&Y1.z);
	Z1 = cross(X1,Y1);

	scanf("%lf %lf %lf",&c2.x,&c2.y,&c2.z);
	scanf("%lf %lf %lf %lf %lf %lf",&X2.x,&X2.y,&X2.z,&Y2.x,&Y2.y,&Y2.z);
	Z2 = cross(X2,Y2);

	if(fabs(abs(cross(Z1,Z2))) < EPS){
		printf("NO\n");
		return 0;
	}

	double absX1 = abs(X1),absY1 = abs(Y1),absZ1 = abs(Z1);

	X1.x /= absX1;
	X1.y /= absX1;
	X1.z /= absX1;

	Y1.x /= absY1;
	Y1.y /= absY1;
	Y1.z /= absY1;

	Z1.x /= absZ1;
	Z1.y /= absZ1;
	Z1.z /= absZ1;

	next1.x = mult(X1,c1);
	next1.y = mult(Y1,c1);
	next1.z = mult(Z1,c1);


	next2.x = mult(X1,c2);
	next2.y = mult(Y1,c2);
	next2.z = mult(Z1,c2);

	next_Z2.x = mult(X1,Z2);
	next_Z2.y = mult(Y1,Z2);
	next_Z2.z = mult(Z1,Z2);

	next2.x = next2.x-next1.x;
	next2.y = next2.y-next1.y;
	next2.z = next2.z-next1.z;

	double a = next_Z2.x,b = next_Z2.y,c=next_Z2.z;
	double x2 = next2.x,y2 = next2.y,z2 = next2.z;
	double T = (a*x2+b*y2+c*z2)/b;

	if(fabs(b) < EPS){

		printf("NO\n");

	}else{

		double A = 1.0+(a*a)/(b*b);
		double B = -2*x2-(2*a*T)/b+(2*a*y2)/b;
		double C = x2*x2 + T*T - 2*y2*T + y2*y2 +z2*z2 -1;
		double D = B*B-4*A*C;
		if(D < 0 || fabs(D) < EPS){

			printf("NO\n");
		}else{

			double e = (-B+sqrt(D))/(2*A);
			double f = T-(a/b)*e;

			double g = (-B-sqrt(D))/(2*A);
			double h = T-(a/b)*g;

			double dist1 = sqrt(e*e+f*f);
			double dist2 = sqrt(g*g+h*h);

			if((sqrt(e*e+f*f) <= 1 && sqrt(g*g+h*h) > 1) || (sqrt(e*e+f*f) > 1 && sqrt(g*g+h*h) <= 1)){

				printf("YES\n");

			}else{

				printf("NO\n");
			}
		}
	}

	return 0;
}


### Prompt

Your task is to create a Cpp solution to the following problem:

H - Rings

Problem Statement

There are two circles with radius 1 in 3D space. Please check two circles are connected as chained rings.

Input

The input is formatted as follows.


{c_x}_1 {c_y}_1 {c_z}_1
{v_x}_{1,1} {v_y}_{1,1} {v_z}_{1,1} {v_x}_{1,2} {v_y}_{1,2} {v_z}_{1,2}
{c_x}_2 {c_y}_2 {c_z}_2
{v_x}_{2,1} {v_y}_{2,1} {v_z}_{2,1} {v_x}_{2,2} {v_y}_{2,2} {v_z}_{2,2}


First line contains three real numbers(-3 \leq {c_x}_i, {c_y}_i, {c_z}_i \leq 3). It shows a circle's center position. Second line contains six real numbers(-1 \leq {v_x}_{i,j}, {v_y}_{i,j}, {v_z}_{i,j} \leq 1). A unit vector ({v_x}_{1,1}, {v_y}_{1,1}, {v_z}_{1,1}) is directed to the circumference of the circle from center of the circle. The other unit vector ({v_x}_{1,2}, {v_y}_{1,2}, {v_z}_{1,2}) is also directed to the circumference of the circle from center of the circle. These two vectors are orthogonalized. Third and fourth lines show the other circle information in the same way of first and second lines. There are no cases that two circles touch.

Output

If two circles are connected as chained rings, you should print "YES". The other case, you should print "NO". (quotes for clarity)

Sample Input 1


0.0 0.0 0.0
1.0 0.0 0.0 0.0 1.0 0.0
1.0 0.0 0.5
1.0 0.0 0.0 0.0 0.0 1.0


Output for the Sample Input 1


YES


Sample Input 2


0.0 0.0 0.0
1.0 0.0 0.0 0.0 1.0 0.0
0.0 3.0 0.0
0.0 1.0 0.0 -1.0 0.0 0.0


Output for the Sample Input 2


NO


Sample Input 3


1.2 2.3 -0.5
1.0 0.0 0.0 0.0 1.0 0.0
1.1 2.3 -0.4
1.0 0.0 0.0 0.0 0.70710678 0.70710678


Output for the Sample Input 3


YES


Sample Input 4


1.2 2.3 -0.5
1.0 0.0 0.0 0.0 1.0 0.0
1.1 2.7 -0.1
1.0 0.0 0.0 0.0 0.70710678 0.70710678


Output for the Sample Input 4


NO






Example

Input

0.0 0.0 0.0
1.0 0.0 0.0 0.0 1.0 0.0
1.0 0.0 0.5
1.0 0.0 0.0 0.0 0.0 1.0


Output

YES

### Response

```cpp
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


struct Point{
	Point(double arg_x,double arg_y,double arg_z){
		x = arg_x;
		y = arg_y;
		z = arg_z;
	}

	Point(){
		x = y = z = 0.0;
	}

	Point operator + (Point p){ return Point(x+p.x,y+p.y,z+p.z); }
	Point operator - (Point p){ return Point(x-p.x,y-p.y,z-p.z);}
	Point operator * (double a){ return Point(a*x,a*y,a*z); }
	Point operator / (double a){ return Point(x/a,y/a,z/a); }

	double abs(){ return sqrt(norm()); }
	double norm(){ return x*x + y*y + z*z; }

	bool operator == (const Point &p) const{
		return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS && fabs(z-p.z) < EPS;
	}
	double x,y,z;
};

typedef Point Vector;


double mult(Vector a,Vector b){
    return a.x*b.x + a.y*b.y+a.z*b.z;
}

double norm(Vector a){
	return a.x*a.x+a.y*a.y+a.z*a.z;
}

double abs(Vector a){
	return sqrt(norm(a));
}

Vector cross(Vector a,Vector b){
	return Point(a.y*b.z-a.z*b.y,a.z*b.x-a.x*b.z,a.x*b.y-a.y*b.x);
}

int main(){

	Point c1,c2,next1,next2;
	Vector X1,X2,Y1,Y2,Z1,Z2,next_Z2;

	scanf("%lf %lf %lf",&c1.x,&c1.y,&c1.z);
	scanf("%lf %lf %lf %lf %lf %lf",&X1.x,&X1.y,&X1.z,&Y1.x,&Y1.y,&Y1.z);
	Z1 = cross(X1,Y1);

	scanf("%lf %lf %lf",&c2.x,&c2.y,&c2.z);
	scanf("%lf %lf %lf %lf %lf %lf",&X2.x,&X2.y,&X2.z,&Y2.x,&Y2.y,&Y2.z);
	Z2 = cross(X2,Y2);

	if(fabs(abs(cross(Z1,Z2))) < EPS){
		printf("NO\n");
		return 0;
	}

	double absX1 = abs(X1),absY1 = abs(Y1),absZ1 = abs(Z1);

	X1.x /= absX1;
	X1.y /= absX1;
	X1.z /= absX1;

	Y1.x /= absY1;
	Y1.y /= absY1;
	Y1.z /= absY1;

	Z1.x /= absZ1;
	Z1.y /= absZ1;
	Z1.z /= absZ1;

	next1.x = mult(X1,c1);
	next1.y = mult(Y1,c1);
	next1.z = mult(Z1,c1);


	next2.x = mult(X1,c2);
	next2.y = mult(Y1,c2);
	next2.z = mult(Z1,c2);

	next_Z2.x = mult(X1,Z2);
	next_Z2.y = mult(Y1,Z2);
	next_Z2.z = mult(Z1,Z2);

	next2.x = next2.x-next1.x;
	next2.y = next2.y-next1.y;
	next2.z = next2.z-next1.z;

	double a = next_Z2.x,b = next_Z2.y,c=next_Z2.z;
	double x2 = next2.x,y2 = next2.y,z2 = next2.z;
	double T = (a*x2+b*y2+c*z2)/b;

	if(fabs(b) < EPS){

		printf("NO\n");

	}else{

		double A = 1.0+(a*a)/(b*b);
		double B = -2*x2-(2*a*T)/b+(2*a*y2)/b;
		double C = x2*x2 + T*T - 2*y2*T + y2*y2 +z2*z2 -1;
		double D = B*B-4*A*C;
		if(D < 0 || fabs(D) < EPS){

			printf("NO\n");
		}else{

			double e = (-B+sqrt(D))/(2*A);
			double f = T-(a/b)*e;

			double g = (-B-sqrt(D))/(2*A);
			double h = T-(a/b)*g;

			double dist1 = sqrt(e*e+f*f);
			double dist2 = sqrt(g*g+h*h);

			if((sqrt(e*e+f*f) <= 1 && sqrt(g*g+h*h) > 1) || (sqrt(e*e+f*f) > 1 && sqrt(g*g+h*h) <= 1)){

				printf("YES\n");

			}else{

				printf("NO\n");
			}
		}
	}

	return 0;
}


```