type PartData = (Int, Int)

main :: IO ()
main = do
  n <- readLn :: IO Int
  as <- (identify n . map read . words) <$> getLine :: IO [PartData]
  bs <- (identify n . map read . words) <$> getLine :: IO [PartData]
  cs <- (identify n . map read . words) <$> getLine :: IO [PartData]
  let ans = solve as bs cs
  print $ length ans

identify :: Int -> [Int] -> [PartData]
identify n parts = zip [1..n] parts

solve :: [PartData] -> [PartData] -> [PartData] -> [(Int, Int, Int)]
solve as bs cs =
  let total = concatMap (\a -> solveA a bs cs) as
  in map (\(a, b, c) -> (fst a, fst b, fst c)) total

solveA :: PartData -> [PartData] -> [PartData] -> [(PartData, PartData, PartData)]
solveA a bs cs =
  let bs' = filter (\b -> snd b > snd a) bs
      data1 = concatMap (`solveB` cs) bs'
  in map (\(b, c) -> (a, b, c)) data1

solveB :: PartData -> [PartData] -> [(PartData, PartData)]
solveB b cs =
  let cs' = filter (\c -> snd c > snd b) cs
  in map (\c -> (b, c)) cs'
