#include<bits/stdc++.h>
using namespace std;
const double eps = 0.0000000001;
pair<double,int> Pair;

bool eq(double a,double b){
  return ( fabs(a-b) < eps );
}

struct Point{
  double x,y,z;
  
  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 k){
    return (Point){x*k,y*k,z*k};
  }
};
typedef Point Vector;


void pr(Point p){
  printf("%.5f %.5f %.5f\n",p.x,p.y,p.z);
}


double abs(Point p){
  return sqrt( p.x*p.x + p.y*p.y + p.z*p.z );
}

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

Point cross(Point a,Point b){
  double nx=a.y*b.z-b.y*a.z;
  double ny=a.z*b.x-b.z*a.x;
  double nz=a.x*b.y-b.x*a.y;
  return (Point){nx,ny,nz};
}

bool eq(Point a,Point b){
  return ( eq(a.x,b.x) && eq(a.y,b.y) && eq(a.z,b.z) );
}

struct Segment{
  Point p, v;
};
typedef Segment Line;

struct Plane{
  Point p, v1, v2;
};

bool isParallel(Plane a,Line b){  
  Vector cra=cross(a.v1,a.v2);
  return eq( dot(cra,b.v) ,0);
}


Point getCrossPoint(Plane a,Line b){
  assert( !isParallel(a,b) );
  vector<  vector<double> > G( 3, vector<double>(4) );
  G[0][0]=a.v1.x;
  G[0][1]=a.v2.x;
  G[0][2]=-b.v.x;
  G[0][3]=-(a.p.x-b.p.x);
  
  G[1][0]=a.v1.y;
  G[1][1]=a.v2.y;
  G[1][2]=-b.v.y;
  G[1][3]=-(a.p.y-b.p.y);

  G[2][0]=a.v1.z;
  G[2][1]=a.v2.z;
  G[2][2]=-b.v.z;
  G[2][3]=-(a.p.z-b.p.z);

  /*
  for(int i=0;i<3;i++){
    for(int j=0;j<4;j++){
      G[i][j]+=0.0;
      printf("%.5f ",G[i][j]);
    }
    printf("\n");
  }
  printf("\n");
  */
  for(int i=0;i<3;i++){
    int pivot=-1;
    for(int j=0;j<3;j++)
      if( !eq(G[j][i],0) )pivot=j;
    if(pivot==-1)continue;
    
    
    swap(G[i],G[pivot]);
    
    double k=G[i][i];
    for(int j=0;j<4;j++)G[i][j]/=k;
    
    for(int j=0;j<3;j++){
      if(j==i)continue;
      double rate=G[j][i];
      for(int k=0;k<4;k++){
        G[j][k] -= G[i][k]*rate;
      }
    }
  }
  /*
  for(int i=0;i<3;i++){
    for(int j=0;j<4;j++){
      G[i][j]+=0.0;
      printf("%.5f ",G[i][j]);
    }
    printf("\n");
  }
  printf("\n");
  */
  if(eq(G[2][0],0) && eq(G[2][1],0) && eq(G[2][2],1)){
    return b.p + b.v * G[2][3];
  }else{
    return (Point){0,0,0};
  }
}

double getTime(Line a,Point b){
  b.x -= a.p.x;
  b.y -= a.p.y;
  b.z -= a.p.z;
  if( !eq(a.v.x,0) )return b.x/a.v.x;
  if( !eq(a.v.y,0) )return b.y/a.v.y;
  if( !eq(a.v.z,0) )return b.z/a.v.z;
  return 1e30;
}


void scan(Point &p){
  cin>>p.x>>p.y>>p.z;
}



string solve(){
  Point a1,a2,a3;
  Plane a;
  Point b1,b2;
  Line b;
  scan(b1);
  scan(b2);
  b.p=b1;
  b.v=b2-b1;
  scan(a1);
  scan(a2);
  scan(a3);
  a.p=a1;
  a.v1=a2-a1;
  a.v2=a3-a1;

  double sum=0,sum2=abs(cross(a.v1,a.v2));
  sum+= abs( cross(a1-b2,a2-b2) );
  sum+= abs( cross(a2-b2,a3-b2) );
  sum+= abs( cross(a3-b2,a1-b2) );
  if(eq( sum , sum2 ))return "MISS";
  
  
  if( isParallel(a,b) )return "HIT";
  


  Point c=getCrossPoint(a,b);

  double t=getTime(b,c);
  if(t < 0 || t > 1)return "HIT";
  
  sum=0;
  sum+= abs( cross(a1-c,a2-c) );
  sum+= abs( cross(a2-c,a3-c) );
  sum+= abs( cross(a3-c,a1-c) );
  
  return (eq(sum, abs(cross(a.v1,a.v2)))?"MISS":"HIT");
}

int main(){
  cout<<solve()<<endl;
  return 0;
}
### Prompt

Please create a solution in Cpp to the following problem:

Stellar history 2005.11.5. You are about to engage an enemy spacecraft as the captain of the UAZ Advance spacecraft. Fortunately, the enemy spaceship is still unnoticed. In addition, the space coordinates of the enemy are already known, and the "feather cannon" that emits a powerful straight beam is ready to launch. After that, I just issue a launch command.

However, there is an energy barrier installed by the enemy in outer space. The barrier is triangular and bounces off the "feather cannon" beam. Also, if the beam hits the barrier, the enemy will notice and escape. If you cannot determine that you will hit in advance, you will not be able to issue a launch command.

Therefore, enter the cosmic coordinates (three-dimensional coordinates x, y, z) of the UAZ Advance, enemy, and barrier positions, and if the beam avoids the barrier and hits the enemy, "HIT", if it hits the barrier " Create a program that outputs "MISS".

However, the barrier is only for those that look like a triangle from the Advance issue, and nothing that looks like a line segment is crushed. Barriers are also valid at boundaries containing triangular vertices and shall bounce the beam. Also, if the enemy is in the barrier, output "MISS".

Constraints

* -100 ≤ x, y, z ≤ 100
* The UAZ Advance and the enemy are never in the same position.

Input

The format of the input data is as follows:

The first line is the coordinates of UAZ Advance (x, y, z) (integer, half-width space delimited)
The second line is the coordinates of the enemy (x, y, z) (integer, half-width space delimiter)
The third line is the coordinates of vertex 1 of the barrier (x, y, z) (integer, half-width space delimiter)
The fourth line is the coordinates (x, y, z) of the vertex 2 of the barrier (integer, half-width space delimiter)
The fifth line is the coordinates (x, y, z) of the vertex 3 of the barrier (integer, half-width space delimiter)

Output

Output on one line with HIT or MISS.

Examples

Input

-10 0 0
10 0 0
0 10 0
0 10 10
0 0 10


Output

HIT


Input

-10 6 6
10 6 6
0 10 0
0 10 10
0 0 10


Output

MISS

### Response

```cpp
#include<bits/stdc++.h>
using namespace std;
const double eps = 0.0000000001;
pair<double,int> Pair;

bool eq(double a,double b){
  return ( fabs(a-b) < eps );
}

struct Point{
  double x,y,z;
  
  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 k){
    return (Point){x*k,y*k,z*k};
  }
};
typedef Point Vector;


void pr(Point p){
  printf("%.5f %.5f %.5f\n",p.x,p.y,p.z);
}


double abs(Point p){
  return sqrt( p.x*p.x + p.y*p.y + p.z*p.z );
}

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

Point cross(Point a,Point b){
  double nx=a.y*b.z-b.y*a.z;
  double ny=a.z*b.x-b.z*a.x;
  double nz=a.x*b.y-b.x*a.y;
  return (Point){nx,ny,nz};
}

bool eq(Point a,Point b){
  return ( eq(a.x,b.x) && eq(a.y,b.y) && eq(a.z,b.z) );
}

struct Segment{
  Point p, v;
};
typedef Segment Line;

struct Plane{
  Point p, v1, v2;
};

bool isParallel(Plane a,Line b){  
  Vector cra=cross(a.v1,a.v2);
  return eq( dot(cra,b.v) ,0);
}


Point getCrossPoint(Plane a,Line b){
  assert( !isParallel(a,b) );
  vector<  vector<double> > G( 3, vector<double>(4) );
  G[0][0]=a.v1.x;
  G[0][1]=a.v2.x;
  G[0][2]=-b.v.x;
  G[0][3]=-(a.p.x-b.p.x);
  
  G[1][0]=a.v1.y;
  G[1][1]=a.v2.y;
  G[1][2]=-b.v.y;
  G[1][3]=-(a.p.y-b.p.y);

  G[2][0]=a.v1.z;
  G[2][1]=a.v2.z;
  G[2][2]=-b.v.z;
  G[2][3]=-(a.p.z-b.p.z);

  /*
  for(int i=0;i<3;i++){
    for(int j=0;j<4;j++){
      G[i][j]+=0.0;
      printf("%.5f ",G[i][j]);
    }
    printf("\n");
  }
  printf("\n");
  */
  for(int i=0;i<3;i++){
    int pivot=-1;
    for(int j=0;j<3;j++)
      if( !eq(G[j][i],0) )pivot=j;
    if(pivot==-1)continue;
    
    
    swap(G[i],G[pivot]);
    
    double k=G[i][i];
    for(int j=0;j<4;j++)G[i][j]/=k;
    
    for(int j=0;j<3;j++){
      if(j==i)continue;
      double rate=G[j][i];
      for(int k=0;k<4;k++){
        G[j][k] -= G[i][k]*rate;
      }
    }
  }
  /*
  for(int i=0;i<3;i++){
    for(int j=0;j<4;j++){
      G[i][j]+=0.0;
      printf("%.5f ",G[i][j]);
    }
    printf("\n");
  }
  printf("\n");
  */
  if(eq(G[2][0],0) && eq(G[2][1],0) && eq(G[2][2],1)){
    return b.p + b.v * G[2][3];
  }else{
    return (Point){0,0,0};
  }
}

double getTime(Line a,Point b){
  b.x -= a.p.x;
  b.y -= a.p.y;
  b.z -= a.p.z;
  if( !eq(a.v.x,0) )return b.x/a.v.x;
  if( !eq(a.v.y,0) )return b.y/a.v.y;
  if( !eq(a.v.z,0) )return b.z/a.v.z;
  return 1e30;
}


void scan(Point &p){
  cin>>p.x>>p.y>>p.z;
}



string solve(){
  Point a1,a2,a3;
  Plane a;
  Point b1,b2;
  Line b;
  scan(b1);
  scan(b2);
  b.p=b1;
  b.v=b2-b1;
  scan(a1);
  scan(a2);
  scan(a3);
  a.p=a1;
  a.v1=a2-a1;
  a.v2=a3-a1;

  double sum=0,sum2=abs(cross(a.v1,a.v2));
  sum+= abs( cross(a1-b2,a2-b2) );
  sum+= abs( cross(a2-b2,a3-b2) );
  sum+= abs( cross(a3-b2,a1-b2) );
  if(eq( sum , sum2 ))return "MISS";
  
  
  if( isParallel(a,b) )return "HIT";
  


  Point c=getCrossPoint(a,b);

  double t=getTime(b,c);
  if(t < 0 || t > 1)return "HIT";
  
  sum=0;
  sum+= abs( cross(a1-c,a2-c) );
  sum+= abs( cross(a2-c,a3-c) );
  sum+= abs( cross(a3-c,a1-c) );
  
  return (eq(sum, abs(cross(a.v1,a.v2)))?"MISS":"HIT");
}

int main(){
  cout<<solve()<<endl;
  return 0;
}
```