N = 8
H, W = 4, 4
X, Y = 0, 1

def dfs(board, position, depth)
  return 1 if depth == N
  for x in 0...W do
    for y in 0...H do
      break unless board[x][y]
    end
    break unless board[x][y]
  end
  count = 0
  position.each do |p|
    nx, ny = x+p[X], y+p[Y]
    next if nx < 0 || W <= nx || ny < 0 || H <= ny
    next if board[nx][ny]
    b = board.map(&:dup)
    b[x][y] = b[nx][ny] = true
    count += dfs(b, position, depth+1)
  end
  count
end

while (line=gets).include?(" ") do
  position = Array.new
  line.split.map(&:to_i).each_slice(2) do |x, y|
    position.push([x, y])
  end
  p dfs(Array.new(W){Array.new(H)}, position, 0)
end