#![allow(unused_imports, unused_macros, non_snake_case)]
use std::cmp::{max, min, Ordering};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

//{{{ macros missing in 1.15.1
#[macro_use]
mod macros {
    macro_rules! eprint {
        ($($t:tt)*) => {{
            use ::std::io::Write;
            let _ = write!(::std::io::stderr(), $($t)*);
        }};
    }
    macro_rules! eprintln {
        () => { eprintln!(""); };
        ($($t:tt)*) => {{
            use ::std::io::Write;
            let _ = writeln!(::std::io::stderr(), $($t)*);
        }};
    }
    macro_rules! dbg {
        ($val:expr) => {
            match $val {
                tmp => {
                    eprintln!(
                        "[{}:{}] {} = {:#?}",
                        file!(),
                        line!(),
                        stringify!($val),
                        &tmp
                    );
                    tmp
                }
            }
        };
    }
}
//}}}

fn generate(s: &Vec<char>) -> (Vec<usize>, usize) {
    let mut cur = -1isize;
    let mut res = Vec::new();
    for i in 0..s.len() {
        if s[i] == '#' {
            cur += 1;
        }
        res.push(if cur == -1 { 0 } else { cur } as usize);
    }
    (res, (cur + 1) as usize)
}

fn run() {
    let stdin = std::io::stdin();
    let mut sc = Scanner::new(stdin.lock());
    let h: usize = sc.read();
    let w: usize = sc.read();
    let k: usize = sc.read();
    let mut grid: Vec<Vec<char>> = Vec::new();
    for _ in 0..h {
        let s = sc.read_chars();
        grid.push(s);
    }
    let mut first_y = 0;
    for y in (0..h).rev() {
        if grid[y].iter().any(|c| *c == '#') {
            first_y = y;
        }
    }
    let (first_v, mut count) = generate(&grid[first_y]);
    let mut answer = vec![vec![0; w]; h];
    for y in 0..first_y + 1 {
        answer[y] = first_v.clone();
    }

    let mut cur_v = first_v.clone();
    for y in first_y + 1..h {
        if grid[y].iter().any(|c| *c == '#') {
            let (mut next_v, this_count) = generate(&grid[y]);
            for x in 0..w {
                next_v[x] += count;
            }
            count += this_count;
            cur_v = next_v;
        }
        answer[y] = cur_v.clone();
    }

    for y in 0..h {
        for x in 0..w {
            print!("{} ", answer[y][x] + 1);
        }
        println!("");
    }
}

fn main() {
    std::thread::Builder::new()
        .name("run".to_string())
        .stack_size(1024 * 1024 * 1024)
        .spawn(run)
        .unwrap()
        .join()
        .unwrap()
}

//{{{ Scanner
pub struct Scanner<R> {
    reader: R,
}

impl<R> Scanner<R> {
    pub fn new(r: R) -> Scanner<R> {
        Scanner { reader: r }
    }
}

fn is_whitespace(b: u8) -> bool {
    b == b' ' || b == b'\n' || b == b'\r' || b == b'\t'
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        let buf = std::io::Read::bytes(self.reader.by_ref())
            .map(|b| b.expect("Read failed"))
            .skip_while(|&b| is_whitespace(b))
            .take_while(|&b| !is_whitespace(b))
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error")
    }

    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn read_chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
//}}}


Measured memory_bytes: 9084