import Control.Monad
import Data.List
main :: IO ()
main = do
    n <- readLn
    ss <- (map ((map read) . words)) <$> replicateM 3 getLine
    print $ solve n ss
solve :: Int -> [[Int]] -> Int
solve n (a:b:c:d) = f (sort a) (sort b) (sort c) where
    f :: [Int] -> [Int] -> [Int] -> Int
    f _ _ [] = 0
    f as bs (c:cs) = g as bs c + f as bs cs
    g :: [Int] -> [Int] -> Int -> Int
    g _ [] _ = 0
    g as (b:bs) c = if (b < c) then (h as b c + g as bs c) else 0
    h :: [Int] -> Int -> Int -> Int
    h [] _ _ = 0
    h (a:as) b c = if (a < b) then (1 + h as b c) else 0