def main(str)
  lines = str.split("\n")
  h, w, k = lines[0].split(" ").map(&:to_i)
  cs = lines[1..-1].map { |x| x.split(//) }
  subx(cs, 0, h, w, k)
end

def subx(cs, x, h, w, k)
  return suby(cs, 0, h, w, k) if h == x
  x0 = subx(copy(cs, h, w), x + 1, h, w, k)
  copied = copy(cs, h, w)
  (0...w).each { |j| copied[x][j] = "-" }
  x1 = subx(copied, x + 1, h, w, k)
  x0 + x1
end

def suby(cs, y, h, w, k)
  return count(cs, h, w) == k ? 1 : 0 if w == y
  x0 = suby(copy(cs, h, w), y + 1, h, w, k)
  copied = copy(cs, h, w)
  (0...h).each { |i| copied[i][y] = "-" }
  x1 = suby(copied, y + 1, h, w, k)
  x0 + x1
end

def copy(cs, h, w)
  copied = []
  (0...h).each do |i|
    row = []
    copied << row
    (0...w).each do |j|
      row << cs[i][j]
    end
  end
  copied
end

def count(cs, h, w)
  count = 0
  (0...h).each do |i|
    (0...w).each do |j|
      count += 1 if cs[i][j] == "#"
    end
  end
  count
end

unless ENV["TEST"]
  puts(main($stdin.read.chomp))
  exit(0)
end

require 'minitest/autorun'

class TestA < Minitest::Test
  def test_main
    assert_equal(5, main("2 3 2
..#
###"))
    assert_equal(1, main("2 3 4
..#
###"))
    assert_equal(0, main("2 2 3
##
##"))
    assert_equal(208, main("6 6 8
..##..
.#..#.
#....#
######
#....#
#....#"))
  end
end


