import Control.Applicative ((<$>), (<*>))
import Control.Monad (replicateM)
import Data.List
import Data.Function (on)

main :: IO ()
main = do
  n <- readLn
  solve <$> replicateM n (f <$> map read <$> words <$> getLine) <*> replicateM n (f <$> map read <$> words <$> getLine) >>= print
  where f [x, y] = (x, y)

solve :: [(Int, Int)] -> [(Int, Int)] -> Int
solve rs bs = loop 0 srs sbs
  where
    srs = sortBy (flip compare `on` fst) rs
    sbs = sortBy (flip compare `on` fst) bs
    loop ct [] _ = ct
    loop ct ((a, b) : xs) ys = if null zs then loop ct xs ys
                               else if null zs' then loop ct xs ys
                                    else loop (ct + 1) xs (delete p ys)
      where zs = takeWhile (\(c, _) -> c > a) ys
            zs' = filter (\(_, d) -> d > b) zs
            p = minimumBy (compare `on` snd) zs'
