import qualified Data.Set as S

main = interact $ unlines . map (show . bfs) . parse . map (map read . words) . lines
 where
  parse [[0,0]] = []
  parse ([t,o]:xs) = (t, map (\[a,b]->(a,b)) os, (x,y)) : parse xs'
   where (os,([x,y]:xs')) = splitAt o xs

bfs (t,os,s@(sx,sy)) = S.size (bfs' 0 is (S.singleton s))
 where
  is = S.fromList [(x,y) | x<-[minx..maxx], y<-[miny..maxy], abs (x-y) <= 30, notElem (x,y) (s:os)]
   where
    (minx,maxx) = (max (-30) (sx-t), min 30 (sx+t))
    (miny,maxy) = (max (-30) (sy-t), min 30 (sy+t))
  bfs' t' is' rs'
   | t' == t = rs'
   | S.null is' = rs'
   | S.null is1 = rs'
   | otherwise = bfs' (t'+1) is2 (S.union rs' is1)
   where
    (is1,is2) = S.partition neighbor is'
    neighbor (xi,yi)
     | abs (xi-sx) > t+1 || abs (yi-sy) > t+1 = False
     | otherwise = any (flip S.member rs') [(xi+1,yi),(xi-1,yi),(xi,yi+1),(xi,yi-1),(xi+1,yi+1),(xi-1,yi-1)]