{-# LANGUAGE ViewPatterns #-}
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = readLn >>= main'
    where
        main' n = replicateM 2 readLine >>= print . solve n

solve :: Int -> [[Int]] -> Int
solve n [as, bs] = check . foldl' ff (empty, 0, 0) $ zip as bs
    where
        check (pop -> Just (x, h), r, c)
            | r <= 0 = c
            | otherwise = check (h, r + x, c + 1) 
        check (_, r, c)
            | r > 0 = -1
            | otherwise = c

        ff (h, r, c) (a, b)
            | x < 0 = (push x h, r, c)
            | x > 0 = (h, r + x, c + 1)
            | otherwise = (h, r, c)
            where
                x = b - a

readLine :: IO [Int]
readLine = unfoldr (\s -> second (maybe B.empty snd . B.uncons) <$> B.readInt s) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

data Heap a = E | T Int a (Heap a) (Heap a)
    deriving (Show)
    
empty :: Heap a 
empty = E

null :: Heap a -> Bool 
null E = True
null _ = False

merge :: (Ord a) => Heap a -> Heap a -> Heap a
merge lh@(T _ lv la lb) rh@(T _ rv ra rb)
    | lv <= rv = makeT lv la $ merge lb rh
    | otherwise = makeT rv ra $ merge lh rb
    where
        makeT v a b
            | rank a >= rank b = T (rank b + 1) v a b
            | otherwise = T (rank a + 1) v b a
        rank (T r _ _ _) = r
        rank _ = 0
        
merge lh E = lh
merge _ rh = rh

push :: (Ord a) => a -> Heap a -> Heap a
push x = merge (T 1 x E E)

pop :: (Ord a) => Heap a -> Maybe (a, Heap a) 
pop (T _ x a b) = Just (x, merge a b)
pop _ = Nothing

fromList :: (Ord a) => [a] -> Heap a
fromList = br . fmap (\x -> T 1 x E E)
    where
        build (x : y : zs) = merge x y : build zs
        build xs = xs
        br [x] = x
        br xs = br $ build xs