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 (Python):
H,W,K = map(int,input().split())
c = [input() for _ in range(H)]
ans = 0
for i in range(1<<H):
    for j in range(1<<W):
        cnt = 0
        for k in range(H):
            if i >> k & 1: continue
            for l in range(W):
                if j >> l & 1: continue
                if c[k][l] == "
        if cnt == K: ans += 1
print(ans)

Solution (Python):
import sys, math
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

H, W, K = rl()
M = []
for i in range(H):
	M.append(rs())

import itertools

def check(b1, b2):
	cnt = 0
	for i in range(H):
		if b1[i]: continue
		for j in range(W):
			if b2[j]: continue
			if M[i][j] == '
				cnt += 1
				if cnt > K:
					return False
	if cnt == K:
		return True
	else:
		return False

ans = 0
for b1 in itertools.product([0,1], repeat=H):
	for b2 in itertools.product([0,1], repeat=W):
		if check(b1, b2):
			ans += 1

print(ans)

Solution (Python):
h, w, k = map(int, input().split())

c = [0] * h
for i in range(h):
    c[i] = input()

cnt = 0
    
for rows in range(1 << h):
    for cols in range(1 << w):
        black = 0
        for i in range(h):
            if (rows >> i) % 2 == 1:
                continue
            for j in range(w):
                if (cols >> j) % 2 == 1:
                    continue
                black += c[i][j] == '
        if black == k:
            cnt += 1

print(cnt)

Solution (Python):
h, w, k = map(int, input().split())
c = [input() for _ in range(h)]

black = 0
for i in range(h):
    for j in range(w):
        if c[i][j] == '
            black += 1

ans = 0
for i in range(2 ** h):
    for j in range(2 ** w):
        tmp = 0
        for l in range(h):
            for m in range(w):
                if ((i >> l) & 1) or ((j >> m) & 1):
                    if c[l][m] == '
                        tmp += 1

        if black - tmp == k:
            ans += 1

print(ans)

Solution (Python):
H,W,K=map(int,input().split())
C=[]
for _ in range(H):
    C.append(input())

A=2**W
B=2**H

M=0
for a in range(A):
    for b in range(B):

        X=0
        for y in range(H):
            for x in range(W):
                if (a>>x)%2==1 and (b>>y)%2==1 and C[y][x]=="
                    X+=1
        if X==K:
            M+=1
print(M)

Solution (Python):
import sys
sys.setrecursionlimit(10**8)
stdin = sys.stdin


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


def naa(N): return [na() for _ in range(N)]


def ns(): return stdin.readline().rstrip()  


H, W, K = na()

c_array = [ns() for _ in range(H)]

ans = 0
for i in range(2**(H+W)):
    cnt = 0
    for h in range(H):
        for w in range(W):
            if i & (1 << h) == 0 and i & (1 << (H+w)) == 0 and c_array[h][w] == "
                cnt += 1
    if cnt == K:
        ans += 1


print(ans)

Solution (Python):
H, W, K = map(int, input().split())
C = [input() for i in range(H)]

ans = 0
for i in range(1 << H):
    for j in range(1 << W):
        c = 0
        for h in range(H):
            if i >> h & 1 == 1:
                continue
            for w in range(W):
                if j >> w & 1 == 1:
                    continue
                if C[h][w] == '
                    c += 1
        if c == K:
            ans += 1
print(ans)

Solution (Python):
H, W, K = [int(_) for _ in input().split()]
C = []
for i in range(H):
  c = input()
  C.append(c)

ans = 0
for i in range(2**H):
  for j in range(2**W):
    count = 0
    for row in range(H):
      for col in range(W):
        if i >> row & 1 and j >> col & 1:
          if C[row][col] == "
            count += 1
    if count == K:
      ans += 1
print(ans)

Solution (Python):
h, w, k = map(int, input().split())
c = []
for i in range(h):
    ci = input()
    c.append(ci)

ans = 0
for x in range(2 ** h):
    for y in range(2 ** w):
        cnt = 0
        for i in range(h):
            if x & (1 << i):
                continue
            for j in range(w):
                if y & (1 << j):
                    continue
                if c[i][j] == '
                    cnt += 1
        if cnt == k:
            ans += 1

print(ans)

Solution (Python):
def main():
    from sys import setrecursionlimit, stdin, stderr
    from os import environ
    from collections import defaultdict, deque, Counter
    from math import ceil, floor
    from itertools import accumulate, combinations, combinations_with_replacement
    setrecursionlimit(10**6)
    dbg = (lambda *something: stderr.write("\033[92m{}\033[0m".format(str(something)+'\n'))) if 'TERM_PROGRAM' in environ else lambda *x: 0
    input = lambda: stdin.readline().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    P = 10**9+7
    INF = 10**18+10

    H,W,K = LMIIS()
    table = []
    for i in range(H):
        table.append(list(input()))
    ans = 0
    for i in range(2**H):
        for j in range(2**W):
            count_black = 0
            for x in range(H):
                if 2**x & i:
                    for y in range(W):
                        if 2**y & j and table[x][y] == '
                            count_black += 1
            if count_black == K:
                ans += 1

    print(ans)





    
main()

Solution (Python):
import sys
import collections

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    H, W, K = [int(x) for x in input().split()]
    A = [input().strip() for _ in range(H)]

    ans = 0
    for x in range(2 ** H):
        for y in range(2 ** W):
            xset = set()
            yset = set()
            for xx in range(H):
                if x >> xx & 1:
                    xset.add(xx)
            for yy in range(W):
                if y >> yy & 1:
                    yset.add(yy)

            tmp = 0
            for i in range(H):
                if i in xset:
                    continue
                for j in range(W):
                    if j in yset:
                        continue
                    if A[i][j] == "
                        tmp += 1

            if tmp == K:
                ans += 1

    print(ans)




if __name__ == '__main__':
    main()

Solution (Python):

import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub


import sys


buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()

def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(H, W, K, C):
    ans = 0

    for h in range(H+1):
        for w in range(W+1):
            for i in combinations(range(H), r=h):
                i = set(i)
                for j in combinations(range(W), r=w):
                    j = set(j)
                    t = 0
                    for x in range(H):
                        for y in range(W):
                            if x in i or y in j:
                                continue
                            if C[x][y] == '
                                t += 1
                    if t == K:
                        ans += 1

    return ans


def main():
    H, W, K = read_int_n()
    C = [read_str() for _ in range(H)]
    print(slv(H, W, K, C))


if __name__ == '__main__':
    main()

Solution (Python):
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))


def main():
	H, W, K = getlist()
	C = []
	for i in range(H):
		c = list(input())
		C.append(c)

	ans = 0
	for i in range(1 << H):
		for a in range(1 << W):
			bitlistH = []
			bitlistW = []
			for j in range(H):
				if ((i >> j) & 1) == 1:
					
					bitlistH.append(0)
				else:
					bitlistH.append(1)

			for b in range(W):
				if ((a >> b) & 1) == 1:
					
					bitlistW.append(0)
				else:
					bitlistW.append(1)

			cnt = 0
			for x in range(H):
				for y in range(W):
					if C[x][y] == "
						cnt += 1

			if cnt == K:
				ans += 1

	
	

	print(ans)





if __name__ == '__main__':
	main()

Solution (Python):
from copy import deepcopy
h, w, k = map(int, input().split())
c = [list(input()) for i in range(h)]
ans = 0
for i in range(1 << h):
    for j in range(1 << w):
        t = deepcopy(c)
        for x in range(h):
            for y in range(w):
                if (i >> x & 1) or (j >> y & 1):
                    t[x][y] = "."
        p = 0
        for x in range(h):
            for y in range(w):
                if t[x][y] == "
                    p += 1
        if p == k:
            ans += 1
print(ans)

Solution (Python):
import sys
sys.setrecursionlimit(10**7) 
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right

from collections import deque, defaultdict


from collections import Counter

from itertools import accumulate,combinations,permutations

from heapq import heapify,heappop,heappush


from functools import reduce,lru_cache

from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    

    
    H, W, K = map(int, input().split())
    
    
    S = tuple(input() for i in range(H)) 
    cnt=0
    ans=0
    for si in S:
        cnt+=si.count("
    for j in range(2**(H+W)):
        c2=0
        for h in range(H):
            for w in range(W):
                if ((j>>(h+W))&1==1 or (j>>(w))&1==1) and S[h][w]=="
                    c2+=1
        if cnt-c2==K:
            ans+=1
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
import itertools


def main():
    H, W, K = list(map(int, input().split(' ')))
    C = [input() for _ in range(H)]
    ans = 0
    for hp in itertools.product([0, 1], repeat=H):
        for wp in itertools.product([0, 1], repeat=W):
            black_cnt = 0
            for h in range(H):
                if hp[h] == 0:
                    continue
                for w in range(W):
                    if wp[w] == 0:
                        continue
                    if C[h][w] == '
                        black_cnt += 1
            if black_cnt == K:
                ans += 1
    print(ans)



if __name__ == '__main__':
    main()

Solution (Python):
import itertools
h,w,k = map(int,input().split())
c = [input() for _ in range(h)]

hh = list(itertools.product([0,1], repeat=h))
ww = list(itertools.product([0,1], repeat=w))

hbl = [0]*h
wbl = [0]*w
ans = 0
for l in hh:
    for m in ww:
        al = 0
        for i in range(h):
            for j in range(w):
                if l[i] == 0 and m[j] == 0 and c[i][j] == "
                    al += 1
                    
        if al == k:
            ans += 1
            
print(ans)

Solution (Python):
h, w, k = map(int, input().split())
grid = [input() for _ in range(h)]


def bit_to_set(bit, n):
    result = set()
    for b in range(n):
        if (1 << b) & bit:
            result.add(b)
    return result


ans = 0
mask = (1 << w) - 1
for b in range(1 << (h + w)):
    p = bit_to_set(b >> w, h)
    q = bit_to_set(b & mask, w)
    tmp = 0
    for i in range(h):
        if i in p:
            continue
        for j in range(w):
            if j in q:
                continue
            if grid[i][j] == '
                tmp += 1
    if tmp == k:
        ans += 1

print(ans)

Solution (Python):
import math

import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit


ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    h,w,k = map(int,ipt().split())
    c = [input() for i in range(h)]
    ans = 0
    for i in range(2**h):
        for j in range(2**w):
            num = 0
            for hi in range(h):
                for ji in range(w):
                    if (i >> hi)&1 and (j>>ji)&1 and c[hi][ji] == "
                        num += 1
            if num == k:
                ans += 1
    print(ans)        

    return None

if __name__ == '__main__':
    main()

Solution (Python):
H, W, K = map(int,input().split())
C = []
for _ in range(H):
    C.append(list(input()))

ans = 0

for i in range(2 ** H):
    for j in range(2 ** W):
        cnt = 0
        for k in range(H):
            for l in range(W):
                if i & 1 << k and j & 1 << l and C[k][l] == '
                    cnt += 1
        if cnt == K:
            ans += 1

print(ans)

Solution (Python):
H, W, K = map(int, input().split())
c = [list(input()) for _ in range(H)]

ans = 0
for case_h in range(1 << H):
    tmp = case_h
    flag_y = []
    for _ in range(H):
        flag_y.append(tmp % 2)
        tmp >>= 1
    
    for case_w in range(1 << W):
        tmp = case_w
        flag_x = []
        for _ in range(W):
            flag_x.append(tmp % 2)
            tmp >>= 1
        
        cnt = 0
        for y in range(H):
            for x in range(W):
                if flag_y[y] == 0 and flag_x[x] == 0 and c[y][x] == '
                    cnt += 1
        
        if cnt == K:
            ans += 1

print(ans)

Solution (Python):
H,W,K = map(int,input().split())
c = [input() for _ in range(H)]
ans =0
for i in range(1<<H):
    for j in range(1<<W):
        count = 0
        for k in range(H):
            for l in range(W):
                if c[k][l]=="
                    count +=1
        if count == K: ans +=1
print(ans)

Solution (Python):
import itertools

H,W,K = map(int,input().split())
C = [0]*H
for i in range(H):
    C[i] = input()

ans = 0
for HH in itertools.product((0,1),repeat=H):
    for WW in itertools.product((0,1),repeat=W):
        a = 0
        for h in range(H):
            for w in range(W):
                if HH[h] and WW[w] and C[h][w] == "
                    a += 1
        if a == K:
            ans += 1

print(ans)

Solution (Python):
H,W,K = map(int,input().split())

C = [list(map(lambda x:x=="

ans = 0

for i in range(1<<H):
    for j in range(1<<W):
        cnt = 0
        for k in range(H):
            if i>>k &1 == 0: continue
            for l in range(W):
                if j>>l &1 ==0: continue
                cnt += int(C[k][l])
        if cnt == K: ans += 1

print(ans)

Solution (Python):


import sys
read = sys.stdin.read
readline = sys.stdin.readline


h,w,k = map(int,readline().split())
s = read().split()

ans = 0

for maskh in range(1<<h):
    for maskw in range(1<<w):
        cnt = 0
        for i in range(h):
            for j in range(w):
                if s[i][j] == "
                    cnt += 1
        
        if cnt == k: ans += 1

print(ans)

Solution (Python):
def f(i):
    global ans
    if i == h + w:
        cnt = 0
        for j in range(h):
            for l in range(w):
                if s[j] == 0 and s[h + l] == 0 and c[j][l] == "
                    cnt += 1
        if cnt == k:
            ans += 1
        return
    s[i] = 1
    f(i + 1)
    s[i] = 0
    f(i + 1)

h, w, k = map(int, input().split())
c = [list(input()) for _ in range(h)]
s = [0] * (h + w)
ans = 0
f(0)
print(ans)

Solution (Python):
from itertools import product
H, W, K = map(int, input().split())
M = [input() for _ in range(H)]

ans = 0
for Hs in product(range(2), repeat=H):
    for Ws in product(range(2), repeat=W):
        cnt = 0
        for y in range(H):
            for x in range(W):
                if M[y][x] == '
                    cnt += 1
        if cnt == K:
            ans += 1
print(ans)

Solution (Python):
h,w,k = map(int,input().split())
c = []
for i in range(h):
    c.append(list(input()))

import itertools 
hd = list(itertools.product(range(2), repeat = h))
wd = list(itertools.product(range(2), repeat = w))

ans = 0
for hdata in hd:
    for wdata in wd:
        buf = 0
        for i in range(h):
            for j in range(w):
                if hdata[i]==0 and wdata[j]==0 and c[i][j]=='
                    buf += 1
        if buf==k:
            ans += 1
print(ans)

Solution (Python):
H, W, K = map(int, input().split())
C = [input() for _ in range(H)]
ans = 0
for r in range(1<<H):
    for c in range(1<<W):
        k = 0
        for h in range(H):
            if (r>>h)&1: continue
            for w in range(W):
                if (c>>w)&1: continue
                if C[h][w]=='
        if k==K: ans+=1
        
print(ans)

Solution (Python):
from itertools import product

H, W, K = map(int, input().split())
l = [input() for _ in range(H)]

ans = 0
for s in product(range(2), repeat=H):
    for t in product(range(2), repeat=W):
        res = [[0]*W for _ in range(H)]

        for i, ri in enumerate(s):
            for j, rj in enumerate(t):
                if ri or rj:
                    res[i][j] = 1
        cnt = 0
        for i in range(H):
            for j in range(W):
                if res[i][j]==0 and l[i][j]=="
                    cnt += 1
        ans += (cnt==K)
print(ans)

Solution (Python):
h, w, k = list(map(int, input().split()))
c = [[] for _ in range(h)]
for i in range(h):
    c[i] = input()

ans = 0
for i in range(1 << h):
    for j in range(1 << w):
        black = 0
        for a in range(h):
            for b in range(w):
                if i >> a & 1 or j >> b & 1:
                    continue
                if c[a][b] == '
        if black == k:
            ans += 1

print(ans)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def isk():
    cnt=0
    for i in range(h):
        if hbit>>i&1:continue
        for j in range(w):
            if wbit>>j&1:continue
            cnt+=cc[i][j]
    return cnt==k

h,w,k=MI()
cc=[[c=="
ans=0
for hbit in range(1<<h):
    for wbit in range(1<<w):
        ans+=isk()
print(ans)

Solution (Python):
h, w, k = map(int, input().split())
ans = 0
s = [input() for _ in range(h)]
for hi in range(2**h):
	hl = []
	for hj in range(h):
		if (hi >> hj) & 1:
			hl.append(hj)
	tmp = s[:]
	for j in hl:
		tmp[j] = "."*w
	for wi in range(2**w):
		wl = []
		for wj in range(w):
			if (wi >> wj) & 1:
				wl.append(wj)
		cnt = 0
		for i in range(h):
			for j in range(w):
				if j not in wl:
					if tmp[i][j] == "
						cnt += 1
		if cnt == k:
			ans += 1
print(ans)

Solution (Python):
H, W, K = map(int, input().split())
c = [[i == '

ret = 0
for x in range(1 << W) :
  for y in range(1 << H) :
    s = 0
    for i in range(W) :
      for j in range(H) :
        if x & (1 << i) or y & (1 << j) : continue
        s += c[j][i]
    if s == K :
      ret += 1
      
print(ret)

Solution (Python):
import sys
input = sys.stdin.readline
from collections import *

H, W, K = map(int, input().split())
c = [input()[:-1] for _ in range(H)]
row = []

for i in range(H):
    cnt = 0
    
    for j in range(W):
        if c[i][j]=='
            cnt += 1
    
    row.append(cnt)

col = []

for i in range(W):
    cnt = 0
    
    for j in range(H):
        if c[j][i]=='
            cnt += 1
    
    col.append(cnt)

total = sum(row)
ans = 0

for s1 in range(1<<H):
    for s2 in range(1<<W):
        l1, l2 = [], []
        
        for i in range(H):
            if (s1>>i)&1:
                l1.append(i)
        
        for i in range(W):
            if (s2>>i)&1:
                l2.append(i)
    
        now = total
        
        for l1i in l1:
            now -= row[l1i]
        
        for l2i in l2:
            now -= col[l2i]
            
        for l1i in l1:
            for l2i in l2:
                if c[l1i][l2i]=='
                    now += 1
        
        if now==K:
            ans += 1

print(ans)

Solution (Python):
from sys import stdin
from sys import setrecursionlimit
from copy import deepcopy as copy
from collections import Counter, deque, defaultdict
from math import floor, ceil
from bisect import bisect_left
from itertools import combinations, chain
setrecursionlimit(100000)

def powerset(iterable):
    "powerset([1,2,3]) --> () (1,) (2,) (3,) (1,2) (1,3) (2,3) (1,2,3)"
    s = list(iterable)
    return chain.from_iterable(combinations(s, r) for r in range(len(s)+1))

INF = int(1e10)
MOD = int(1e9 + 7)

def main():
    from builtins import int, map
    H, W, K = map(int, input().split())
    MAP = [list(input()) for _ in range(H)]
    ans = 0
    for cols in powerset(range(H)):
        for rows in powerset(range(W)):
            MMAP = copy(MAP)
            for c in cols:
                for k in range(W):
                    MMAP[c][k] = 'r'
            for r in rows:
                for k in range(H):
                    MMAP[k][r] = 'r'
            
            
            count = 0
            for i in range(H):
                for j in range(W):
                    if MMAP[i][j] == '
                        count += 1
            
            if count == K:
                ans += 1
    print(ans)



if __name__ == '__main__':
    main()

Solution (Python):
from itertools import product
def main():
    H, W, K = map(int, input().split())
    C = []
    for _ in range(H):
        c = input()
        C.append(c)
    r = 0
    for i in product(range(2), repeat=H):
        for j in product(range(2), repeat=W):
            t = 0
            for ii in range(H):
                for jj in range(W):
                    if i[ii] == 0 and j[jj] == 0 and C[ii][jj] == '
                        t += 1
            if t == K:
                r += 1
    return r
print(main())

Solution (Python):
from itertools import product

H, W, K = map(int, input().split(' '))

C = []
for _ in range(H):
    C.append(list(input()))

ans = 0
for h_bits in product((True, False), repeat=H):
    for w_bits in product((True, False), repeat=W):
        blacks = 0
        for i in range(H):
            for j in range(W):
                if h_bits[i] and w_bits[j] and C[i][j] == '
                    blacks += 1
        if blacks == K:
            ans += 1

print(ans)

Solution (Python):
from itertools import product
def main():
    h, w, k = map(int, input().split())
    cs = [input() for _ in range(h)]
    ans = 0
    for a in product([True, False], repeat=h):
        for b in product([True, False], repeat=w):
            cnt = 0
            for i in range(h):
                if a[i]:
                    continue
                for j in range(w):
                    if b[j]:
                        continue
                    if cs[i][j] == "
                        cnt += 1
            if cnt == k:
                ans += 1
    print(ans)

if __name__ == "__main__":
    main()

Solution (Python):
h, w, K = map(int, input().split())
C = [list(map(str, input())) for _ in range(h)]

ans = 0
for i in range(2**h):
    for j in range(2**w):
        H = [0]*h
        for k in range(h):
            if (i >> k) & 1:
                H[k] = 1
        W = [0]*w
        for l in range(w):
            if (j >> l) & 1:
                W[l] = 1
        cnt = 0
        for p in range(h):
            for q in range(w):
                if H[p] != 1 and W[q] != 1 and C[p][q] == '
                    cnt += 1
        if cnt == K:
            ans += 1
print(ans)

Solution (Python):


import sys

class CHAndV:
    def solve(self, tc=0):
        h, w, k = [int(_) for _ in input().split()]
        g = []
        for i in range(h):
            g.append(list(input().strip()))

        ans = 0
        for mrow in range(1 << h):
            for mcol in range(1 << w):
                new_g = [line[:] for line in g]
                for i in range(h):
                    for j in range(w):
                        if (mrow >> i) & 1 or (mcol >> j) & 1:
                            new_g[i][j] = '0'

                cnt = 0
                for line in new_g:
                    cnt += line.count('

                if cnt == k:
                    ans += 1

        print(ans)




solver = CHAndV()
input = sys.stdin.readline

solver.solve()

Solution (Python):
h, w, k = map(int, input().split())
s = [list(input()) for _ in range(h)]
ans = 0
for i in range(1 << h):
    for j in range(1 << w):
        t = []
        for row in s:
            t.append(row[:])
        for p in range(h):
            if (i >> p) & 1:
                for a in range(w):
                    t[p][a] = '.'
        for p in range(w):
            if (j >> p) & 1:
                for a in range(h):
                    t[a][p] = '.'
        res = 0
        for row in t:
            res += row.count('
        if res == k:
            ans += 1
print(ans)

Solution (Python):
from itertools import combinations
H,W,K = map(int,input().split())
grid=[[v for v in input()] for _ in range(H)]


ans=0
for h_bit in range(1<<H):
    for w_bit in range(1<<W):
        h_set=set()
        w_set=set()
        for i in range(H):
            if h_bit>>i&1:
                h_set.add(i)
        for i in range(W):
            if w_bit>>i&1:
                w_set.add(i)

        black=0
        for i in range(H):
            for j in range(W):
                if i not in h_set and j not in w_set and grid[i][j]=="
                    black+=1
        if black==K:
            ans+=1
print(ans)

Solution (Python):
h,w,k = map(int,input().split())
c = [input() for _ in range(h)]

ans = 0
for i in range(2**h):
    for j in range(2**w):
        cnt = 0
        for ii in range(h):
            if((i >> ii)& 1):
                for jj in range(w):
                    if((j >> jj)& 1):
                        cnt += (c[ii][jj]=='
        ans += (cnt==k)

print(ans)

Solution (Python):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from itertools import product

    h, w, k = map(int, readline().split())
    c = [list(input()) for _ in range(h)]

    ans = 0

    for row_bit in product(range(2), repeat=h):
        for col_bit in product(range(2), repeat=w):
            cnt = 0
            for row in range(h):
                for col in range(w):
                    if c[row][col] == "
                        cnt += 1
            if cnt == k:
                ans += 1

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
from itertools import product


def count(C, H, W, hselect, wselect):
    cnt = 0
    for i in range(H):
        if hselect[i]:
            continue
        for j in range(W):
            if wselect[j]:
                continue
            if C[i][j] == "
                cnt += 1
    return cnt


def main():
    H, W, K = map(int, input().split())
    C = [input() for _ in range(H)]
    ans = 0
    for hselect in product([True, False], repeat=H):
        for wselect in product([True, False], repeat=W):
            if count(C, H, W, hselect, wselect) == K:
                ans += 1
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
import sys
sys.setrecursionlimit(500000)

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]


def main():
    H, W, K = mi()
    c = [list(input()) for i in range(H)]
    cnt = 0

    for row in range(2**H):
        for column in range(2**W):
            tmp = [['.']*W for i in range(H)]
            for i in range(H):
                for j in range(W):
                    if (row>>i)&1 or (column>>j)&1:
                        tmp[i][j] = 'r'
                    else:
                        tmp[i][j] = c[i][j]
            s = 0
            for i in range(H):
                for j in range(W):
                    if tmp[i][j] == '
                        s += 1
            if s == K:
                cnt += 1
    
    print(cnt)


if __name__ == '__main__':
    main()

Solution (Python):
import itertools

h, w, k = [int(x) for x in input().split()]
C = [input() for _ in range(h)]

answer = 0

for hreps in range(h + 1):
    for hchosen in itertools.combinations(range(h), hreps):
        for wreps in range(w + 1):
            for wchosen in itertools.combinations(range(w), wreps):
                count = 0
                for y in hchosen:
                    for x in wchosen:
                        if C[y][x] == '
                            count += 1
                if count == k:
                    answer += 1

print(answer)