Problem:
Score : 300 points

Problem Statement

We have a grid of H rows and W columns of squares. The color of the square at the i-th row from the top and the j-th column from the left (1 \leq i \leq H, 1 \leq j \leq W) is given to you as a character c_{i,j}: the square is white if c_{i,j} is ., and black if c_{i,j} is #.

Consider doing the following operation:

Choose some number of rows (possibly zero), and some number of columns (possibly zero). Then, paint red all squares in the chosen rows and all squares in the chosen columns.

You are given a positive integer K. How many choices of rows and columns result in exactly K black squares remaining after the operation? Here, we consider two choices different when there is a row or column chosen in only one of those choices.

Constraints

1 \leq H, W \leq 6

1 \leq K \leq HW

c_{i,j} is . or #.

Input

Input is given from Standard Input in the following format:

H W K
c_{1,1}c_{1,2}...c_{1,W}
c_{2,1}c_{2,2}...c_{2,W}
:
c_{H,1}c_{H,2}...c_{H,W}

Output

Print an integer representing the number of choices of rows and columns satisfying the condition.

Sample Input 1

2 3 2
..#
###

Sample Output 1

5

Five choices below satisfy the condition.

The 1-st row and 1-st column

The 1-st row and 2-nd column

The 1-st row and 3-rd column

The 1-st and 2-nd column

The 3-rd column

Sample Input 2

2 3 4
..#
###

Sample Output 2

1

One choice, which is choosing nothing, satisfies the condition.

Sample Input 3

2 2 3
##
##

Sample Output 3

0

Sample Input 4

6 6 8
..##..
.#..#.
#....#
######
#....#
#....#

Sample Output 4

208

Solution in Rust (1.42.0) (judge verdict: Accepted)

#![allow(unused_imports)]
#![allow(clippy::many_single_char_names)]

// language: Rust(1.42.0)
// check available crates on AtCoder at "https://atcoder.jp/contests/language-test-202001"
// My Library Repo' is at "https://github.com/Loptall/prcn_lib"

/*
    そう甘くはないんだな〜w
*/

// from std...
use std::cmp::{
    max, min, Ordering,
    Ordering::{Equal, Greater, Less},
    Reverse,
};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::convert::TryInto;
use std::mem::swap;
use std::num::{NonZeroU32, ParseIntError};
use std::ops::{
    Add, AddAssign, BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Div, DivAssign,
    Index, IndexMut, Mul, MulAssign, Neg, Rem, RemAssign, Shl, ShlAssign, Shr, ShrAssign, Sub,
    SubAssign,
};
use std::process::exit;
use std::{f32, f64, i128, i16, i32, i64, i8, isize, u128, u16, u32, u64, u8, usize};

// Dep' crates are...
use itertools::*;
use itertools_num::*;
use lazy_static::lazy_static;
use maplit::{btreemap, btreeset, hashmap, hashset};
use num_bigint::{BigInt, BigUint};
use num_complex::Complex;
use num_integer::{binomial, gcd, lcm, multinomial, Integer};
use num_rational::Rational;
use num_traits::{clamp, one, pow, zero, Num, NumAssignOps, NumOps, One, Pow, Zero};
use permutohedron::Heap;
use proconio::{
    fastout, input, is_stdin_empty,
    marker::{Bytes, Chars, Isize1, Usize1},
};
use rand::random;

pub const MOD10E9_7: usize = 1000000007;
pub const MOD99_: usize = 998244353;
pub const MAX: usize = std::usize::MAX;
pub const PI: f64 = f64::consts::PI;
pub const A: u8 = 65;

/// bitの数を持つ
#[derive(Debug, Copy, Clone)]
pub struct BitSet {
    size: usize,
}
impl BitSet {
    /// サイズを指定してコンストラクト
    pub fn new(n: usize) -> Self {
        Self { size: n }
    }
    /// サイズを返す
    pub fn len(&self) -> usize {
        self.size
    }
    /// 合計で生成される組み合わせの数、`(2 ^ size)`
    pub fn combinations(&self) -> usize {
        1 << self.size
    }
}
impl IntoIterator for BitSet {
    type Item = Vec<bool>;
    type IntoIter = IntoIterBitSet;
    fn into_iter(self) -> Self::IntoIter {
        IntoIterBitSet {
            size: self.len(),
            current: 0,
        }
    }
}
/// BitSetの所有権を奪ったIterator
///
///(実際にはコピートレイトにより`into_iter()`後もBitSetは有効である)
///
/// 保持するのはサイズと次に生成する数字だけ
///
/// Iteratorは長さ`2 ^ size`で、
/// はじめは`[false, false, ..., false, false]`から始まり、
///
/// `[false, false, ..., false, true]`
///
/// `[false, false, ..., true, false]`
///
/// `[false, false, ..., true, true]`のように右詰で続く。
///
/// 最後は`[true, true, ..., true, true]`である。
#[derive(Copy, Clone, Debug)]
pub struct IntoIterBitSet {
    size: usize,
    current: usize,
}
impl Iterator for IntoIterBitSet {
    type Item = Vec<bool>;
    fn next(&mut self) -> Option<Self::Item> {
        if self.current == (1 << self.size) {
            None
        } else {
            let res = Some(
                (0..self.size)
                    .rev()
                    .map(|x| self.current & (1 << x) != 0)
                    .collect::<Vec<_>>(),
            );
            self.current += 1;
            res
        }
    }
}
pub trait BitsOps {
    fn count_zeros(&self) -> usize;
    fn count_ones(&self) -> usize;
    fn grow(&mut self, bits: usize);
    fn put(&mut self, bits: usize) -> bool;
    fn toggle(&mut self, bit: usize);
    fn set(&mut self, bit: usize, into: bool);
    fn shl(&mut self, rhs: usize);
    fn shr(&mut self, rhs: usize);
}
impl BitsOps for Vec<bool> {
    fn count_zeros(&self) -> usize {
        self.iter().filter(|x| **x).count()
    }
    fn count_ones(&self) -> usize {
        self.iter().filter(|x| !**x).count()
    }
    fn grow(&mut self, bits: usize) {
        self.reverse();
        self.append(&mut vec![false; bits]);
        self.reverse();
    }
    fn put(&mut self, bits: usize) -> bool {
        let prev = self[bits];
        self[bits] = true;
        prev
    }
    fn toggle(&mut self, bit: usize) {
        self[bit] = !self[bit];
    }
    fn set(&mut self, bit: usize, into: bool) {
        self[bit] = into;
    }
    fn shl(&mut self, rhs: usize) {
        self.append(&mut vec![false; rhs]);
    }
    fn shr(&mut self, rhs: usize) {
        let len = self.len();
        let mut res = vec![false; rhs];
        res.append(&mut self[..len - rhs].to_vec());
        *self = res;
    }
}

// code...
// #[fastout]
fn main() {
    input! {
        h: usize, w: usize, k: usize,
        b: [Chars; h]
    }

    let mut ans = 0usize;
    let bs = BitSet::new(h + w);
    for bits in bs {
        let hh = &bits[..h];
        let ww = &bits[h..];
        let mut c = 0usize;

        for i in 0..h {
            for j in 0..w {
                if hh[i] && ww[j] && b[i][j] == '#' {
                    c += 1;
                }
            }
        }

        if c == k {
            ans += 1;
        }
    }
    println!("{}", ans);
}