import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
toTuple (x : y : _) = (x, y)

main = do
    [n, m] <- getIntList
    as <- zip [1,1..] <$> getIntList
    bcs <- map toTuple <$> replicateM m getIntList
    print . (solve n) . reverse $ sortOn snd (as ++ bcs)

solve _ [] = 0
solve 0 _ = 0
solve n ((b, c) : bcs) | n <= b = c * n
                       | otherwise = c * b + solve (n - b) bcs