#include <bits/stdc++.h>

#define TYPE(c)   remove_reference_t<decltype(c)>
#define REP(i, n) for(TYPE(n) i = 0; i < n; i++)
#define FOR(v, c) for(TYPE(c.begin()) v = c.begin(); v != c.end(); v++)
#define ALL(c)    c.begin(), c.end()
#define SORT(c)   sort(ALL(c))
#define RSORT(c)  sort(ALL(c), greater<TYPE(c)::value_type>())
#define UNIQUE(c) c.erase(unique(ALL(c)), c.end())

using namespace std;
using ll = long long;

constexpr int MOD  = (int)1e9 + 7;
constexpr int INF  = (int)1e9 + 1;
constexpr ll  LINF = (ll)1e18 + 1;
template<typename T> constexpr bool chmax(T& a, const T& b)
{ if(a < b) { a = b; return true; } else { return false; } }
template<typename T> constexpr bool chmin(T& a, const T& b)
{ if(b < a) { a = b; return true; } else { return false; } }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T>& p)
{ return os << "(" << p.first << "," << p.second << ")"; }
ostream& operator<<(ostream &os, const string& s)
{ FOR(v, s) os << *v; return os; }
template<typename T> auto operator<<(ostream& os, const T& t)
    -> typename conditional<true, ostream&, decltype(*t.begin())>::type
{ os << "["; FOR(v, t) { if(v != t.begin()) os << ","; os << *v; } os << "]"; return os; }

/**
 *  二次元空間における点を表すクラス
 */
template<typename T>
class Pt {
public:
    T x, y;
    constexpr Pt() : x(0), y(0) { }
    constexpr Pt(const T& _x, const T& _y) : x(_x), y(_y) { }
    constexpr Pt(const Pt &obj) : x(obj.x), y(obj.y) { }
    Pt &operator=(const Pt &obj) { x = obj.x; y = obj.y; return *this; }

    double norm() const { return std::sqrt(dot(*this)); }
    constexpr double dot(const Pt& other) const { return x * other.x + y * other.y; }
    constexpr double distanceFrom(const Pt& other) const { return (other - *this).norm(); }
    constexpr Pt normalized() const { return *this / norm(); }
    constexpr bool isZero() const { return x == 0 && y == 0; }
    template<typename S>
    constexpr bool isWithinRange(const S& w, const S& h) const { return 0 <= x && x < w && 0 <= y && y < h; }

    constexpr Pt operator +() const { return *this; }
    constexpr Pt operator -() const { return{ -x, -y }; }
    constexpr Pt operator +(const Pt& other) const { return{ x + other.x, y + other.y }; }
    constexpr Pt operator +=(const Pt& other) { x += other.x;  y += other.y;  return *this; }
    constexpr Pt operator -(const Pt& other) const { return{ x - other.x, y - other.y }; }
    constexpr Pt operator -=(const Pt& other) { x -= other.x;  y -= other.y;  return *this; }
    template<typename S>
    constexpr Pt operator *(const S& s) const { return{ x * s, y * s }; }
    constexpr Pt operator *=(const Pt& other) { x *= other.x;  y *= other.y;  return *this; }
    template<typename S>
    constexpr Pt operator /(const S& s) const { return{ x / s, y / s }; }
    constexpr Pt operator /=(const Pt& other) { x /= other.x;  y /= other.y;  return *this; }
    constexpr bool operator ==(const Pt& other) { return x == other.x && y == other.y; }
    constexpr bool operator !=(const Pt& other) { return !(x == other.x && y == other.y); }

    void stdRead() { std::cin >> x >> y; }

    friend std::ostream& operator <<(std::ostream& os, const Pt& obj) {
        os << "(x : " << obj.x << ", " << "y : " << obj.y << ")";
        return os;
    }
};

/**
 *  二次元平面を表すクラス
 *  NOTE: dependencies: comp-pt
 */
template<typename T, typename S>
class MyMat {
    using EleMap = std::map<T, std::vector<Pt<S>>>;
public:
    T* data;
    uint32_t w, h;
    MyMat(const uint& _w, const uint& _h, const T& def_val = 0) :
        w(_w), h(_h) {
        data = new T[h * w]();
        if(def_val != 0) for(uint i = 0; i < w * h; i++) data[i] = def_val;
    }

    MyMat(const uint &_w, const uint &_h, const T*& _data) :
        w(_w), h(_h), data(_data) {}

    ~MyMat() { delete[] data; }

    MyMat(const MyMat &obj) : data(obj.data), w(obj.w), h(obj,h) {}
    MyMat &operator=(const MyMat &obj) { data = obj.data; w = obj.w; h = obj,h; return *this; }

    MyMat clone() {
        T* new_data = new T[h * w];
        for(int i = 0; i < h * w; i++) new_data[i] = data[i];
        return MyMat<T, S>(w, h, new_data);
    }

    void stdRead() {
        for(uint hi = 0; hi < h; hi++)
            for(uint wi = 0; wi < w; wi++)
                std::cin >> data[wi + hi * w];
    }

    template<typename ... A>
    EleMap searchElements(const A&... keys) const {
        auto key_list = std::initializer_list<T>{keys...};
        EleMap result;
        for(const auto& key : key_list)
            result.insert(std::make_pair(key, std::vector<Pt<int>>()));
        for(uint hi = 0; hi < h; hi++)
            for(uint wi = 0; wi < w; wi++)
                for(const auto& key : key_list)
                    if(data[wi + hi * w] == key)
                        result[key].push_back(Pt<int>(wi, hi));
    }

    T& at(const uint& wi, const uint& hi) const { return data[wi + hi * w]; }
    T& at(const Pt<S>& pt) const { return data[pt.x + pt.y * w]; }

    friend std::ostream& operator <<(std::ostream& os, const MyMat<T, S>& obj) {
        for(uint hi = 0; hi < obj.h; hi++) {
            for(uint wi = 0; wi < obj.w; wi++) {
                os << obj.data[wi + hi * obj.w] << " ";
            }
            if(hi != obj.h - 1) os << std::endl;
        }
        return os;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int H, W, K;
    std::cin >> H >> W >> K;
    MyMat<char, int> mat(W, H);
    mat.stdRead();

    MyMat<int, int> ans(W, H);
    std::vector<bool> exist(H, false);
    int n = 0;
    REP(hi, H) {
        int prev_wi = 0;
        REP(wi, W) {
            if(mat.at(wi, hi) == '#') {
                exist[hi] = true;
                n++;
                for(int i = prev_wi; i <= wi; i++) ans.at(i, hi) = n;
                prev_wi = wi + 1;
            }
        }
        for(int i = prev_wi; i < W; i++) ans.at(i, hi) = n;
        if(prev_wi != W && mat.at(W - 1, hi) == '#') n++;
    }

    for(int hi = 1; hi < H; hi++) {
        if(exist[hi] == false) {
            for(int i = 0; i < W; i++) ans.at(i, hi) = ans.at(i, hi - 1);
        }
        if(exist[H - hi - 1] == false) {
            for(int i = 0; i < W; i++) ans.at(i, H - hi - 1) = ans.at(i, H - hi);
        }
    }
    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 1280