h,w,k = gets.split.map &:to_i

ks = []

h.times{ 
	ks << (gets.chomp.split(""))
}

mark = 1

result = []

ks.each_with_index{ |k, i|
	line = []
	mark_flag = false
	last_dot_len = 0

	k.each{ |dot|
		line << mark
		if dot == "#" then
			mark += 1
			mark_flag = true
			last_dot_len = 0
		else
			last_dot_len += 1
		end
	}

	if mark_flag then
		last_dot_len.times{ |i|
			line[- (i + 1)] -= 1
		}
	else
		line = result[i - 1]
	end
	
	result << line
}

index = result.index{ |r| r != nil }

if index > 0 then
	(0..index - 1).each{ |i|
		result[i] = result[index]
	}
end

puts result.map{ |r|
	r.join(" ")
}.join("\n")
