
using namespace std;
#include <iostream>
#include <vector>
#include <string.h>

#define REP(i, n) for(int i=0; i<n; i++)

typedef vector<int> VI;

int cnt;
int num[8];

void solve(VI board, int depth)
{
	//end check
	if(depth == 8)
	{
		bool is_end = true;
		REP(i, board.size())
		{
			if(board[i] == 0)
			{
				is_end = false;
				break;
			}
		}
		
		if(is_end){
	 		cnt++;
			return;
		}
	}

	//normal procedure
	bool is_set = false;
	REP(y, 4)
	{
		REP(x, 4)
		{
			if(board[y*4+x] == 0)
			{
				REP(i, 4)
				{
					int dx = num[i*2+0];
					int dy = num[i*2+1];
					int xx = x + dx;
					int yy = y + dy;
					if(xx>=0 && yy>=0 && xx<4 && yy<4) 
					{
						if(board[yy*4+xx] == 0)
						{
							VI v = VI(16);
							memcpy(&v[0], &board[0], sizeof(int)*16);
							v[y*4+x] = depth+1;
							v[yy*4+xx] = depth+1;
							solve(v, depth+1);
						}
					}
				}
				is_set = true;
				break;
			}
		}
		if(is_set) break;
	}	
}
   
int main()
{
	while( 1 )
	{
		scanf("%d", &num[0]);
		if(num[0] > 4) break;
		
		for(int i=1; i<8; i++)
		{
			scanf("%d", &num[i]);
		}

		cnt = 0;
		VI v = VI(16);
		memset(&v[0], 0, sizeof(int)*16);
		solve(v, 0);

		printf("%d\n", cnt);
	}
}