Problem: You have to organize a wedding party. The program of the party will include a concentration game played by the bride and groom. The arrangement of the concentration game should be easy since this game will be played to make the party fun.

We have a 4x4 board and 8 pairs of cards (denoted by `A' to `H') for the concentration game:


+---+---+---+---+
|   |   |   |   |   A A B B
+---+---+---+---+   C C D D
|   |   |   |   |   E E F F
+---+---+---+---+   G G H H
|   |   |   |   |
+---+---+---+---+
|   |   |   |   |
+---+---+---+---+


To start the game, it is necessary to arrange all 16 cards face down on the board. For example:


+---+---+---+---+
| A | B | A | B |
+---+---+---+---+
| C | D | C | D |
+---+---+---+---+
| E | F | G | H |
+---+---+---+---+
| G | H | E | F |
+---+---+---+---+


The purpose of the concentration game is to expose as many cards as possible by repeatedly performing the following procedure: (1) expose two cards, (2) keep them open if they match or replace them face down if they do not.

Since the arrangements should be simple, every pair of cards on the board must obey the following condition: the relative position of one card to the other card of the pair must be one of 4 given relative positions. The 4 relative positions are different from one another and they are selected from the following 24 candidates:


(1, 0), (2, 0), (3, 0),
(-3, 1), (-2, 1), (-1, 1), (0, 1), (1, 1), (2, 1), (3, 1),
(-3, 2), (-2, 2), (-1, 2), (0, 2), (1, 2), (2, 2), (3, 2),
(-3, 3), (-2, 3), (-1, 3), (0, 3), (1, 3), (2, 3), (3, 3).


Your job in this problem is to write a program that reports the total number of board arrangements which satisfy the given constraint. For example, if relative positions (-2, 1), (-1, 1), (1, 1), (1, 2) are given, the total number of board arrangements is two, where the following two arrangements satisfy the given constraint:


X0  X1  X2  X3             X0  X1  X2  X3
+---+---+---+---+          +---+---+---+---+
Y0 | A | B | C | D |       Y0 | A | B | C | D |
+---+---+---+---+          +---+---+---+---+
Y1 | B | A | D | C |       Y1 | B | D | E | C |
+---+---+---+---+          +---+---+---+---+
Y2 | E | F | G | H |       Y2 | F | A | G | H |
+---+---+---+---+          +---+---+---+---+
Y3 | F | E | H | G |       Y3 | G | F | H | E |
+---+---+---+---+          +---+---+---+---+
the relative positions:    the relative positions:
A:(1, 1),  B:(-1, 1)       A:(1, 2),  B:(-1, 1)
C:(1, 1),  D:(-1, 1)       C:(1, 1),  D:(-2, 1)
E:(1, 1),  F:(-1, 1)       E:(1, 2),  F:( 1, 1)
G:(1, 1),  H:(-1, 1)       G:(-2, 1), H:(-1, 1)


Arrangements of the same pattern should be counted only once. Two board arrangements are said to have the same pattern if they are obtained from each other by repeatedly making any two pairs exchange their positions. For example, the following two arrangements have the same pattern:



X0  X1  X2  X3           X0  X1  X2  X3
+---+---+---+---+        +---+---+---+---+
Y0 | H | G | F | E |     Y0 | A | B | C | D |
+---+---+---+---+        +---+---+---+---+
Y1 | G | E | D | F |     Y1 | B | D | E | C |
+---+---+---+---+        +---+---+---+---+
Y2 | C | H | B | A |     Y2 | F | A | G | H |
+---+---+---+---+        +---+---+---+---+
Y3 | B | C | A | D |     Y3 | G | F | H | E |
+---+---+---+---+        +---+---+---+---+


where (1) `A' and `H', (2) `B' and `G', (3) `C' and `F', and (4) `D' and `E' exchange their positions respectively.



Input

The input contains multiple data sets, each representing 4 relative positions. A data set is given as a line in the following format.

x1| y1 | x2| y2 | x3| y3 | x4| y4
---|---|---|---|---|---|---|---

The i-th relative position is given by (xi, yi). You may assume that the given relative positions are different from one another and each of them is one of the 24 candidates.

The end of input is indicated by the line which contains a single number greater than 4.

Output

For each data set, your program should output the total number of board arrangements (or more precisely, the total number of patterns).

Each number should be printed in one line. Since your result is checked by an automatic grading program, you should not insert any extra characters nor lines on the output.

Examples

Input




Output




Input

-2 1 -1 1 1 1 1 2
1 0 2 1 2 2 3 3
5


Output

2
15

Solution (in JAVA):

Solution:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;

class Main{
	static int answer;
	static ArrayList<Integer[]> inputs;

	public static void main(String args[]){
		// 標準入力準備
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = new String();

		// 集合定義のためのハッシュ
		try{
			while((str = br.readLine()) != null){
				// メソッドと引数を分離
				inputs = new ArrayList<Integer[]>();
				answer = 0;
				String strs[] = str.split(" ");
				int n = Integer.parseInt(strs[0]);
				if(n >= 5) return;
				for(int i = 0; i < 4; i++){
					Integer input[] = new Integer[2];
					input[0]= Integer.parseInt(strs[2 * i]);
					input[1] = Integer.parseInt(strs[2 * i + 1]);
					inputs.add(input);
				}
				//printArray(inputs);
				boolean table[][] = new boolean[4][4];
				int position[] = {0, 0};
				solve(table, position, "");
				System.out.println(answer);
			}
		}catch(Exception e){
			System.err.println(e);
		}
	}

	public static void solve(boolean table[][], int position[], String rireki){
		// 埋まった場合
		rireki += "(" + position[0] + ", " + position[1] + ")";
		//System.out.println(rireki);
		if(position[0] == 3 && position[1] == 3){
			//System.out.println("埋まった");
			answer++;
			return;
		}

		// 次の座標を用意
		int next_position[] = new int[2];
		next_position[0] = (position[0] + 1) % 4;
		next_position[1] = (position[0] + 1) / 4 + position[1];

		// 既に埋まっている場合は次へ
		if(table[position[0]][position[1]]){
			//System.out.println("埋まっているので次へ");
			solve(table, next_position, rireki);
			return;
		}

		for(int i = 0; i < 4; i++){
			Integer pattern[] = inputs.get(i);
			//System.out.println("当てはめる " + "(" + pattern[0] + ", " + pattern[1] + ")");

			// 座標を足す オーバーしていたらreturn
			int pair_position[] = new int[2];
			pair_position[0] = position[0] + pattern[0];
			if(pair_position[0] < 0 || pair_position[0] > 3) continue;
			pair_position[1] = position[1] + pattern[1];
			if(pair_position[1] < 0 || pair_position[1] > 3) continue;

			// 既に埋まっている場合も return
			if(table[pair_position[0]][pair_position[1]]) continue;

			// 置ける場合は配置して次へ
			table[position[0]][position[1]] = true;
			table[pair_position[0]][pair_position[1]] = true;

			solve(table, next_position, rireki);

			table[position[0]][position[1]] = false;
			table[pair_position[0]][pair_position[1]] = false;
		}
		return;
	}

	static void printArray(ArrayList<Integer[]> array){
		System.out.println("PrintArray " + array.size());
		for(int i = 0; i < array.size(); i++){
			Integer set[] = array.get(i);
			System.out.print("(" + set[0] + ", " + set[1] + ")");
		}
		System.out.println();
	}

	static void printMatrix(int matrix[][]){
		for(int row = 0; row < matrix.length; row++){
			for(int column = 0; column < matrix[row].length; column++){
				System.out.print(matrix[row][column] + "\t");
			}
			System.out.println();
		}
	}

	static void printMatrix(boolean matrix[][]){
		for(int row = 0; row < matrix.length; row++){
			for(int column = 0; column < matrix[row].length; column++){
				System.out.print(matrix[row][column] + "\t");
			}
			System.out.println();
		}
	}

	static void printArray(int array[]){
		for(int i = 0; i < array.length; i++){
			System.out.print(array[i] + "\t");
		}
		System.out.println();
	}
}

class OriginalSet{
	public ArrayList<Integer> set;

	OriginalSet(){
		set = new ArrayList<Integer>();
	}

	public void add(int inputInt){
		if(set.indexOf(inputInt) == -1){
			set.add(inputInt);
		}
	}

	public void addAll(OriginalSet inputSet){
		ArrayList<Integer> inputArray = inputSet.set;
		for(int i = 0; i < inputArray.size(); i++){
			add(inputArray.get(i));
		}
	}

	public void remove(int inputInt){
		set.remove((Integer)inputInt);
	}

	public void removeAll(OriginalSet inputSet){
		ArrayList<Integer> inputArray = inputSet.set;
		for(int i = 0; i < inputArray.size(); i++){
			remove(inputArray.get(i));
		}
	}

	public void print(){
		if(set.size() == 0){
			System.out.println("NULL");
			return;
		}
		// ソート
		Collections.sort(set);
		System.out.print(set.get(0));
		for(int i = 1; i < set.size(); i++){
			System.out.print(" " + set.get(i));
		}
		System.out.println();
	}
}