    printGrid res height
    print n

printGrid :: Grid -> Int -> IO ()
printGrid g h = mapM_ putStrLn $ map (\m -> flatten $ map show $ map snd $ M.toList $ M.filterWithKey (\(x,y) _ -> y == m) g) [0..h-1]

simulate :: (Grid,Int,Int) -> (Grid,Int,Int)
simulate (g,countit,fc) = (resetToZero n,countit+1,nfc)
    where
        incd = foldl (mapInc) g allPoints
        (n,nfc) = until (\(a,_) -> M.size (M.filter (>9) a) == 0) flashAll (incd,fc)
