$ans = Array.new(4).map{Array.new(4,0)}

$relational =  Array.new(4).map{Array.new(2,0)}
#$relational =[[-2,1],[-1,1],[1,1],[1,2]]
#$relational = [[1,0], [2,1],[2,2],[3,3]]

def calc(x,y) #,x2,y2,x3,y3,x4,y4)
	
	if (x == 4) then
		$count += 1
	elsif ($ans[x][y] == 1) then
		if y == 3 then
			calc(x+1,0)
		else
			calc(x,y+1)
		end
	else
		$ans[x][y] = 1
		for re in $relational
			rx = x + re[1]
			ry = y + re[0]
			if (rx < 4) && (ry < 4) && (rx >= 0) && (ry >= 0) && ($ans[rx][ry] == 0) then
				$ans[rx][ry] = 1
				
				if y == 3 then
					calc(x+1,0)
				else
					calc(x,y+1)
				end
				$ans[rx][ry] = 0
			else
				#
			end
		end
		$ans[x][y] = 0
	end

end

loop{
	line = gets
	if line==nil then
		break
	end
	sp = line.split(nil)
	
	if sp.count() != 8 then
		break
	else
		$count = 0
		$relational = [[sp[0].to_i,sp[1].to_i],[sp[2].to_i,sp[3].to_i],[sp[4].to_i,sp[5].to_i],[sp[6].to_i,sp[7].to_i]]
		calc(0,0)
		print $count
		print("\n")
	end
}