import Control.Monad
mup n [] = []
mup n s = (s!!0!!n):(mup n (drop 1 s))
ac [] [] [] p q = [(t,s)|t<-[minimum p..maximum p],s<-[minimum q..maximum q]]
ac x y a p q= case a of 1 -> ac (drop 1 x) (drop 1 y) (drop 1 a) (filter (>=x) p) q
                        2 -> ac (drop 1 x) (drop 1 y) (drop 1 a) (filter (<=x) p) q
                        3 -> ac (drop 1 x) (drop 1 y) (drop 1 a) p (filter (>=y) q)
                        4 -> ac (drop 1 x) (drop 1 y) (drop 1 a) p (filter (<=x) p)
main=do
 [w,h,n]<-map read.words<$>getLine
 [x,y,a]<-replicateM n $map read.words<$>getLine
 let xs = mup 0 [x,y,a]
 let ys = mup 1 [x,y,a]
 print$length$ac xs ys a w h
 