import Control.Applicative ((<$>)) import Control.Monad (replicateM) import Data.List (unfoldr) import Data.Char (isSpace) import Data.IntSet (IntSet) import qualified Data.IntSet as IntSet import Data.ByteString.Char8 (ByteString) import qualified Data.ByteString.Char8 as B getL :: (ByteString -> [Int]) -> IO [Int] getL f = f <$> B.getLine readIL :: (ByteString -> Maybe (Int, ByteString)) -> (ByteString -> [Int]) readIL f = unfoldr g where g s = do (n, s') <- f s return (n, B.dropWhile isSpace s') main :: IO () main = do w <- readLn :: IO Int h <- readLn :: IO Int n <- readLn :: IO Int xss <- replicateM n $ getL (readIL B.readInt) print =<< solve w h n xss solve :: Int -> Int -> Int -> [[Int]] -> IO Int solve w h n xss = do let nxs = IntSet.size $ IntSet.fromList $ map head xss nys = IntSet.size $ IntSet.fromList $ map last xss return $ w * h - ((w - nxs) * (h - nys) + n)