import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import Data.List (group, mapAccumL, intercalate)

main :: IO ()
main = do
  (h : w : k :_) <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  sijs <- sequence . replicate h $ map (== '#') <$> getLine :: IO [[Bool]]
  putStrLn . intercalate "\n" . map (intercalate " " . map show) . f $ sijs

f :: [[Bool]] -> [[Int]]
f = map (concatMap (uncurry . flip $ replicate)) . col

col :: [[Bool]] -> [[(Int, Int)]]
col = col' . map g . group . snd . mapAccumL row 1
  where
    g :: [Maybe [(Int, Int)]] -> Either Int [(Int, Int)]
    g = uncurry (maybe Left (const . Right)) . ((,) <$> head <*> length)
    col' :: [Either Int [(Int, Int)]] -> [[(Int, Int)]]
    col' ((Left l0) : (Right r) : (Left l1) : rest) = replicate (l0 + 1 + l1) r ++ col' rest
    col' ((Left l0) : (Right r) : rest) = replicate (l0 + 1) r ++ col' rest
    col' ((Right r) : (Left l0) : rest) = replicate (1 + l0) r ++ col' rest
    col' ((Right r) : rest) = [r] ++ col' rest
    col' _ = []

row :: Int -> [Bool] -> (Int, Maybe [(Int, Int)])
row n = row' n . concatMap (g . ((,) <$> head <*> length)) . group
  where
    g :: (Bool, Int) -> [(Bool, Int)]
    g (True, l) = replicate l (True, 1)
    g p = [p]
    row' :: Int -> [(Bool, Int)] -> (Int, Maybe [(Int, Int)])
    row' n ((False, l0) : (_, l1) : (False, l2) : rest) = (((n, l0 + l1 + l2) :) <$>) <$> row' (succ n) rest
    row' n ((False, l0) : (_, l1) : rest) = (((n, l0 + l1) :) <$>) <$> row' (succ n) rest
    row' n ((False, _) : _) = (n, Nothing)
    row' n ((_, l0) : (False, l1) : rest) = (((n, l0 + l1) :) <$>) <$> row' (succ n) rest
    row' n ((_, l0) : rest) = (((n, l0) :) <$>) <$> row' (succ n) rest
    row' n _ = (n, Just [])

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n
