Title: Spaceship UAZ Advance

In the year 2005.11.5, you, as the captain of the spaceship UAZ Advance, are preparing to engage in combat with an enemy spaceship. Fortunately, the enemy spaceship is still unaware of our presence and remains stationary. Moreover, the enemy's space coordinates are known, and the powerful straight beam weapon, the "Feather Cannon," is ready to fire. All that remains is to give the order to fire.

However, there is a complication. In space, there exists an energy barrier set up by the enemy. This barrier is triangular in shape and will deflect the "Feather Cannon" beam. If the beam hits the barrier, the enemy will become aware of our presence and may escape. Without prior confirmation of a successful hit, the firing order cannot be given.

Therefore, create a program that takes the space coordinates (3D coordinates <var>x</var>, <var>y</var>, <var>z</var>) of the UAZ Advance, the enemy, and the barrier as input. The program should output "HIT" if the beam avoids the barrier and hits the enemy, and "MISS" if the beam hits the barrier and is deflected. If the enemy is within the barrier, output "MISS" as well.

The barrier is only applicable to objects that appear as triangles from the UAZ Advance, and not to those that appear as collapsed lines. Additionally, the barrier is effective even at the boundary containing the vertices of the triangular shape, deflecting the beam.

Input:
The input data format is as follows:
1st line: Coordinates of UAZ Advance (<var>x</var>, <var>y</var>, <var>z</var>) (integers, separated by a single space)
2nd line: Coordinates of the enemy (<var>x</var>, <var>y</var>, <var>z</var>) (integers, separated by a single space)
3rd line: Coordinates of the 1st vertex of the barrier (<var>x</var>, <var>y</var>, <var>z</var>) (integers, separated by a single space)
4th line: Coordinates of the 2nd vertex of the barrier (<var>x</var>, <var>y</var>, <var>z</var>) (integers, separated by a single space)
5th line: Coordinates of the 3rd vertex of the barrier (<var>x</var>, <var>y</var>, <var>z</var>) (integers, separated by a single space)

Output:
Output "HIT" or "MISS" on a single line.

Constraints:
-100 ≤ <var>x</var>, <var>y</var>, <var>z</var> ≤ 100
UAZ Advance and the enemy will never be in the same position.

Sample Input 1:
-10 0 0
10 0 0
0 10 0
0 10 10
0 0 10

Output for the Sample Input 1:
HIT

Sample Input 2:
-10 6 6
10 6 6
0 10 0
0 10 10
0 0 10

Output for the Sample Input 2:
MISS

# Buggy version:
#!/usr/bin/python
from fractions import Fraction
import sys
if sys.version_info[0]>=3: raw_input=input

def gauss(a):
	if not a or len(a)==0: return None
	n=len(a)
	for i in range(n):
		if a[i][i]==0:
			for j in range(i+1,n):
				if a[j][i]!=0:
					for k in range(i,n+1): a[i][k]+=a[j][k]
					break
			else:
				return None
		for j in range(n):
			if i!=j:
				r = Fraction(a[j][i],a[i][i])
				for k in range(i,n+1): a[j][k] = a[j][k] - a[i][k]*r
	for i in range(n):
		x=Fraction(a[i][i],1)
		for j in range(len(a[i])):
			a[i][j] /= x
	return a

uaz=map(int,raw_input().split())
enemy=[0]+[-x+y for x,y in zip(map(int,raw_input().split()),uaz)]
b0=[1]+[x-y for x,y in zip(map(int,raw_input().split()),uaz)]
b1=[1]+[x-y for x,y in zip(map(int,raw_input().split()),uaz)]
b2=[1]+[x-y for x,y in zip(map(int,raw_input().split()),uaz)]
sol=gauss(list(map(list,zip(b0,b1,b2,enemy,[1,0,0,0]))))
print('MISS' if sol and all(0<=e[-1]<=1 for e in sol) else 'HIT')

# Fixed version:
#!/usr/bin/python
from fractions import Fraction
import sys
if sys.version_info[0]>=3: raw_input=input

def gauss(a):
	if not a or len(a)==0: return None
	n=len(a)
	for i in range(n):
		if a[i][i]==0:
			for j in range(i+1,n):
				if a[j][i]!=0:
					for k in range(i,n+1): a[i][k]+=a[j][k]
					break
			else:
				return None
		for j in range(n):
			if i!=j:
				r = Fraction(a[j][i],a[i][i])
				for k in range(i,n+1): a[j][k] = a[j][k] - a[i][k]*r
	for i in range(n):
		x=Fraction(a[i][i],1)
		for j in range(len(a[i])):
			a[i][j] /= x
	return a

uaz=list(map(int,raw_input().split()))
enemy=[0]+[-x+y for x,y in zip(map(int,raw_input().split()),uaz)]
b0=[1]+[x-y for x,y in zip(map(int,raw_input().split()),uaz)]
b1=[1]+[x-y for x,y in zip(map(int,raw_input().split()),uaz)]
b2=[1]+[x-y for x,y in zip(map(int,raw_input().split()),uaz)]
sol=gauss(list(map(list,zip(b0,b1,b2,enemy,[1,0,0,0]))))
print('MISS' if sol and all(0<=e[-1]<=1 for e in sol) else 'HIT')