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=[list(input()) for i in range(h)]
ans=0
sou=0
for i in range(h):
  for j in range(w):
    if c[i][j]=="
      sou+=1
for i in range(2**h):
  count=0
  ss=set()
  for j in range(h):
    if (i >> j)&1:
      for l in range(w):
        if c[j][l]=="
          count+=1
          ss.add((j,l))
  for i2 in range(2**w):
    count2=0
    for j in range(w):
      if (i2 >> j)&1:
        for l in range(h):
          if c[l][j]=="
            count2+=1
    if sou-(count+count2)==k:
      ans+=1
print(ans)

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

li = [input() for _ in range(H)]
ans = 0
for h in range(2**H):
    for w in range(2**W):
        c = 0
        for i in range(H):
            for j in range(W):
                if (h>>i)&1==0 and (w>>j)&1==0:
                    if li[i][j] == '
                        c +=1
        if c==K:
            ans+=1
print(ans)

Solution (Python):
H,W,K = [int(hoge) for hoge in input().split()]
Hbit = 2**H
Wbit = 2**W
ans = 0
C = [input() for c in range(H)]
for i in range(Hbit):
    Xselected = [1&(i>>x) for x in range(H)]
    for j in range(Wbit):
        Yseledted = [1&(j>>y) for y in range(W)]
        k = 0
        for m,x in enumerate(Xselected):
            for n,y in enumerate(Yseledted):
                if (x==1 and y==1) and (C[m][n]=="
                    k += 1
        if k==K:
            ans += 1
print(ans)

Solution (Python):
import numpy as np
import itertools
 
H, W, K = list(map(int, input().split())) 
c = [input().split() for l in range(H)]
b=[]
d=[]
for m in range(len(c)):
  for item in c[m]:
    item_mod = item.replace("."  , "0")
    item_mod = item_mod.replace("
    item_mod = list(item_mod)
    b.append(item_mod)
  d.append(b)
  b=[]

C_arr = np.array(d , dtype = "int")
C_arr = C_arr.reshape((H, W))
 
In = np.array(list(itertools.product([0,1] , repeat=H)))
Out = np.array(list(itertools.product([0,1] , repeat=W)))
 
ans = 0
for i in range(2**H):
  for j in range(2**W):
    In_matrix = np.diag(In[i])
    Out_matrix = np.diag(Out[j])
 
    In_C = np.dot(In_matrix , C_arr)
    In_C_Out = np.dot(In_C , Out_matrix)
 
    ICO = In_C_Out.flatten()
    ICO = ICO.tolist()
 
    if ICO.count(1) == K:
      ans += 1
      
print(ans)

Solution (Python):

import copy
H, W, K = map(int, input().strip().split())

grid = []

def count_black(g):
	
	res = 0
	for i in g:
		for c in i:
			if c == '
				res += 1
	return res


for r in range(H):
	grid.append([x for x in input().strip()])

ans = 0

for i in range(2 ** H):
	for j in range(2 ** W):
		newgrid = copy.deepcopy(grid)

		for k in range(H):
			if ((i & (2 ** k)) > 0):
				newgrid[k] = ['-' for x in range(W)]
		for k in range(W):
			if ((j & (2 ** k)) > 0):
				for ii in range(H):
					newgrid[ii][k] = '-'

		if (count_black(newgrid) == K):
			ans += 1
print(ans)

Solution (Python):
import numpy as np
import itertools

H, W, K = list(map(int, input().split())) 
c = [input().split() for l in range(H)]
b=[]
d=[]
for m in range(len(c)):
  for item in c[m]:
    item_mod = item.replace("."  , "0")
    item_mod = item_mod.replace("
    item_mod = list(item_mod)
    b.append(item_mod)
  d.append(b)
  b=[]

C_arr = np.array(d , dtype = "int")
C_arr = C_arr.reshape((H, W))

In = np.array(list(itertools.product([0,1] , repeat=H)))
Out = np.array(list(itertools.product([0,1] , repeat=W)))

ans = 0
for i in range(2**H):
  for j in range(2**W):
    In_matrix = np.diag(In[i])
    Out_matrix = np.diag(Out[j])

    In_C = np.dot(In_matrix , C_arr)
    In_C_Out = np.dot(In_C , Out_matrix)

    ICO = In_C_Out.flatten()
    ICO = ICO.tolist()

    if ICO.count(1) == K:
      ans += 1

print(ans)

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

ans = 0
for ih in range(1 << h):
    for jw in range(1 << w):
        count = 0
        for i in range(h):
            for j in range(w):
                if (ih >> i & 1) == 0 and (jw >> j & 1) == 0:
                    if (c[i][j] == '
                        count += 1
        if count == k:
            ans += 1
print(ans)

Solution (Python):
ma = lambda :map(int,input().split())
ni = lambda:int(input())
import collections
import math
import itertools
gcd = math.gcd
h,w,k = ma()
area = []
for i in range(h):
    s = input()
    area.append(s)
ans = 0
for i in range(2**h):
    for j in range(2**w):
        cnt = 0
        for y in range(h):
            for x in range(w):
                if (i>>y &1) or (j>>x &1):
                    pass
                else:
                    if area[y][x] =="
                        cnt+=1
        if cnt==k:ans+=1
print(ans)

Solution (Python):
import numpy as np

h, w, k = map(int, input().split())
st = []
for _ in range(h):
    l = list(input())
    l = [l[i] for i in range(w)]
    st.append(l)
st = np.array(st)
st = np.where(st=='

cnt = 0
for i in range(2**w-1):
    tmp = [1] * w
    for j in range(w):
        if i >> j & 1:
            tmp[j] = 0
    for j in range(2**h-1):
        ker = np.array([tmp]*h)
        for x in range(h):
            if j >> x & 1:
                ker[x,:] = 0
        if np.sum(st * ker) == k:
            cnt+=1
print(cnt)

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

ptns = []
for i in range(2**(h+w)):
    tmp = []
    for j in range(h+w):
        if i>>j & 1:
            tmp.append(1)
        else:
            tmp.append(0)
    ptns.append(tmp)

import copy
from itertools import chain

ans = 0
for ptn in ptns:
    tmp = copy.deepcopy(pic)
    for x in range(h):
        for y in range(w):
            if ptn[y] == 1:
                tmp[x][y] = 0
        if ptn[w+x] == 1:
            tmp[x] = [0]
    tmp = list(chain.from_iterable(tmp))

    if tmp.count('
        ans += 1
print(ans)

Solution (Python):



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


list=[]
for i in range(H):
    li = input()
    list.append(li)


ans=0
y=0
for tate in range(2**H):
    for yoko in range(2**W):
        cnt = 0
        y=y+1
        for i in range(H):
            for k in range(W):
                
                
                if (tate>>i)&1 == 0 and (yoko>>k)&1 == 0:
                    if list[i][k] == "
                        cnt = cnt + 1
        
        if cnt == K:
            ans = ans + 1
print(ans)

Solution (Python):
h, w, k = map(int, input().split())
board = [list(input()) for _ in range(h)]
ans = 0
for paint_h in range(2**h):
  for paint_w in range(2**w):
    cnt = 0
    for i in range(h):
      for j in range(w):
        if (paint_h >> i) & 1 == 0 and (paint_w >> j) & 1 == 0:
          if board[i][j] == '
            cnt += 1
    if cnt == k:
      ans +=1
print(ans)

Solution (Python):

from itertools import product

H, W , K = [int(i) for i in input().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)

Solution (Python):
h , w , k = map(int,input().split())
c = [list(input()) for i in range(h)]
ans = 0
for i in range(2**h):
    for j in range(2**w):
        cou = 0
        for a in range(h):
            if (i >> a) & 1 == 1:
                continue
            for b in range(w):
                if (j >> b) & 1 == 1:
                    continue
                if c[a][b] == "
                    cou += 1
        if cou == k:
            ans += 1
print(ans)

Solution (Python):
import copy
h, w, k = map(int, input().split())
c = []
p = 0
pattern = []
for i in range(h):
    t = list(input())
    c.append(t)
for i in range(2 ** h):
    for j in range(2 ** w):
        s = copy.deepcopy(c)
        count = 0
        for x in range(h):
            for y in range(w):
                if (i >> x & 1) and (j >> y  & 1 ):
                    if s[x][y] == "
                
                        count += 1
        if count == k:
            p += 1
print(p)

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

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

for S in range(1<<H):
    for T in range(1<<W):
        cnt = 0
        
        for i in range(H):
            for j in range(W):
                if (S>>i)&1 or (T>>j)&1:
                    continue
                
                if c[i][j]=='
                    cnt += 1
        
        if cnt==K:
            ans += 1

print(ans)

Solution (Python):
from itertools import product

ans = 0
H, W, k = map(int, input().split())

field = [None] * H
for i in range(H):
    field[i] = input()

for hbit in product([0, 1], repeat=H):
    for wbit in product([0, 1], repeat=W):
        hb = list(hbit)
        wb = list(wbit)
        cnt = 0
        for h in range(H):
            for w in range(W):
                if hb[h] == 0 and wb[w] == 0 and field[h][w] == "
                    cnt += 1
        if cnt == k:
            ans += 1
print(ans)

Solution (Python):
import itertools

ans = 0
h, w, k = map(int, input().split())
field = []
for i in range(h):
    s = input()
    field.append(s)
for tate in itertools.product([0, 1], repeat=h):
    for yoko in itertools.product([0, 1], repeat=w):
        tl = list(tate)
        yl = list(yoko)
        cnt = 0
        for t in range(h):
            for y in range(w):
                if ((tl[t] == 1) or (yl[y] == 1)):
                    cnt += 0
                else:
                    if field[t][y] == "
                        cnt += 1
        if cnt == k:
            ans += 1
print(ans)

Solution (Python):
def main():
    import itertools, copy
    h,w,k = map(int,input().split())
    c = []
    for i in range(h):
        c.append([])
        s = input()
        for j in range(w):
            c[i].append(s[j])
    h_stats = ((0,1) for i in range(h))
    w_stats = ((0,1) for i in range(w))
    h__ = [h_ for h_ in itertools.product(*h_stats)]
    w__ = [w_ for w_ in itertools.product(*w_stats)]
    ans = 0
    for h_ in h__:
        h_ls = []
        for i in range(len(h_)):
            if h_[i]==1:
                h_ls.append(i)
        for w_ in w__:
            w_ls = []
            for i in range(len(w_)):
                if w_[i]==1:
                    w_ls.append(i)
            c_ = copy.deepcopy(c)
            for i in range(len(h_ls)):
                for j in range(len(c_[0])):
                    c_[int(h_ls[i])][j] = '.'
            for i in range(len(w_ls)):
                for j in range(h):
                    c_[j][int(w_ls[i])] = '.'
            cnt = 0
            for i in range(h):
                for j in range(w):
                    if c_[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 = []
for i in range(h):
    i = list(input())
    c.append(i)

cnt = 0

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

print(cnt)

Solution (Python):
import numpy as np
from itertools import combinations

def mark_to_binary(x):
    if x == '.':
        return 0
    elif x == '
        return 1
    

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

image = np.zeros((H,W),dtype='int')

score = 0

for i in range(H):
    row = list(map(mark_to_binary,list(input())))
    image[i] = row
    
for num_row_del in range(H+1):
    for row_idxes in combinations(range(H),num_row_del):
        for num_col_del in range(W+1):
            for col_idxes in combinations(range(W),num_col_del):
                image_del = image.copy()
                image_del[row_idxes,:] = 0
                image_del[:,col_idxes] = 0
                
                if image_del.sum() == K:
                    score += 1
print(score)

Solution (Python):

import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial
from bisect import bisect_left, bisect_right 
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

H, W, K = map(int, input().split())
def myfunc(x):
    if x=='.':
        return 0
    elif x=='
        return 1
HW = [list(map(myfunc, list(input()))) for _ in range(H)]


res = 0
for i in range(2**H):
    for j in range(2**W):
        cnt = 0
        for indi, row in enu(HW):
            if not(i>>indi & 1): continue
            for indj in range(W):
                if not(j>>indj & 1): continue
                cnt += row[indj]
            
        if cnt==K: res += 1
        
print(res)

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

import collections
def main():
    H, W, K = map(int,input().split())
    S = [input() for _ in range(H)]
    ans = 0
    for paint_h in range(2**H): 
        for paint_w in range(2**W): 
            cnt=0
            for i in range(H): 
                for j in range(W):
                    if (paint_h>>i)&1==0 and (paint_w>>j)&1==0: 
                        if S[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(input()) for i in range(h)]

ans=0

for i in range(2**h):
    for j in range(2**w):
        cnt=0
        for i1 in range(h):
            for j1 in range(w):
                if (i >> i1) & 1 and (j>>j1)&1:
                    if c[i1][j1]=='
                        cnt+=1

        if cnt==k:
            ans+=1

print(ans)

Solution (Python):
from itertools import product
import copy

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

ans = 0
state = list(product([0, 1], repeat=h+w))
for s in state:
    cc = copy.deepcopy(c)
    for i in range(h):
        if s[i] == 1:
            for j in range(w):
                cc[i][j] = 'x'
    for i in range(h, h+w):
        idx = i - h
        if s[i] == 1:
            for j in range(h):
                cc[j][idx] = 'x'
    count = 0
    for i in range(h):
        for j in range(w):
            
            if cc[i][j] == '
                count += 1
        
    if count == k:
        ans += 1
    
    

print(ans)

Solution (Python):
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
H,W,K=MI()
graph=[input() for _ in range(H)]
ans=0
for gyou in range(1<<H):
  for retsu in range(1<<W):
    cnt=0
    for i in range(H):
      for j in range(W):
        if 1&(gyou>>i) and 1&(retsu>>j):
          if graph[i][j]=='
            cnt+=1
    if cnt==K:
      ans+=1
print(ans)

Solution (Python):
from itertools import product
H, W, K=map(int,input().split())
C = []
for i in range(H):
    C.append((input().replace(".","0").replace("


count = 0

for i in product("01", repeat=H):
    for j in product("01", repeat=W):
        co = 0
        for k in range(H):
            for l in range(W):
                if int(i[k])*int(j[l])*int(C[k][l]):
                    co+=1
        if co==K:
            count+=1
print(count)

Solution (Python):
H, W, K = map(int, input().split())
mass = []
for i in range(H):
  c = input()
  mass_append = [0 for k in range(W)]
  for j in range(W):
    if c[j] == "
      mass_append[j] = 1
  mass.append(mass_append)
pattern = 0
for i in range(2**W):
  i_str = str(bin(i)[2:])
  i_2 = i_str.zfill(W)
  for j in range(2**H):
    j_str = str(bin(j)[2:])
    j_2 = j_str.zfill(H)
    massnew = []
    for k in range(H):
      massnew.append(list(mass[k]))
    for k in range(W):
      if i_2[k] == "1":
        for m in range(H):
          massnew[m][k] = 0
    for k in range(H):
      if j_2[k] == "1":
        for m in range(W):
          massnew[k][m] = 0
    black = 0
    for k in range(W):
      for m in range(H):
        if massnew[m][k] == 1:
          black += 1
    if black == K:
      pattern += 1

print(pattern)

Solution (Python):

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


status = [0] * (H+W)

stat = ['0', '1']
for _ in range(len(status)-1):
    tmp = []
    for j in stat:
        tmp.append(j + '0')
    for j in stat:
        tmp.append(j + '1')
    stat = tmp



ret = 0
for s in stat:
    count = 0
    row = s[:H]
    hel = s[H:]
    for i in range(H):
        if row[i] == '1':
            continue
        for j in range(W):
            if hel[j] == '1':
                continue
            if C[i][j] == '
                count += 1
    if count == K:
        
        ret += 1
print(ret)

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

for p_h in range(2**h):
    for p_w in range(2**w):
        cnt = 0
        for i in range(h):
            for j in range(w):
                if (p_h >> i)&1 == 0 and (p_w >> j)&1 == 0:
                    if c[i][j] == "
                        cnt += 1
        
        if cnt == k:
            ans += 1

print(ans)

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

ans = 0
for h in range(2 ** H):
  for w in range(2 ** W):
    count = 0
    for i in range(H):
      for j in range(W):
        if ((h >> i) & 1) == 0 and ((w >> j) & 1) == 0:
          if C[i][j] == '
            count += 1
    if K == count:
      ans += 1

print(ans)

Solution (Python):
from copy import deepcopy
h, w, K = map(int, input().split())
C = [list(input()) for _ in range(h)]
ans = 0
for i in range(2 ** (h + w)):
    pattern = bin(i)[2:].zfill(h + w)
    c = deepcopy(C)
    for j in range(h + w):
        p = pattern[j]
        if p == "1":
            if j < h:
                for k in range(w):
                    c[j][k] = "-"
            else:
                for k in range(h):
                    c[k][j-h] = "-"
    cnt = 0
    for j in range(h):
        for k in range(w):
            cnt += c[j][k] == "
    ans += cnt == K

print(ans)

Solution (Python):

import itertools

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

def count_black(table):
    count = 0
    for line in table:
        for s in line:
            if s == "
                count += 1
    return count


def paint_col(table, col_index):
    for index, line in enumerate(table):
        table[index] = line[:col_index] + "." + line[col_index + 1:]


def paint_row(table, row_index):
    table[row_index] = "." * len(table[row_index])


def bin_tuple_to_index_tuple(bin_tup):
    res = []
    for idx, v in enumerate(bin_tup):
        if v == 1:
            res.append(idx)
    return res


result = 0
for row in itertools.product([0, 1], repeat=H):
    row_tup = bin_tuple_to_index_tuple(row)
    table_tmp = table.copy()
    for r in row_tup:
        paint_row(table_tmp, r)
    for col in itertools.product([0, 1], repeat=W):
        table_tmp_t = table_tmp.copy()
        col_tup = bin_tuple_to_index_tuple(col)
        for c in col_tup:
            paint_col(table_tmp_t, c)
        if count_black(table_tmp_t) == K:
            result += 1

print(result)

Solution (Python):
def MI(): return map(int, input().split())
H,W,K=MI()
Map=[input() for _ in range(H)]
ans=0
from itertools import product
for gyou in list(product([0,1],repeat=H)):
  for retsu in list(product([0,1],repeat=W)):
    cnt=0
    for i in range(H):
      for j in range(W):
        if gyou[i]==1 and retsu[j]==1:
          if Map[i][j]=='
            cnt+=1
    if cnt==K:
      ans+=1
print(ans)

Solution (Python):
def MI(): return map(int, input().split())
H,W,K=MI()
Map=[input() for _ in range(H)]


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

Solution (Python):
H,W,K= map(int,input().split())
a= [list(input())for i in range(H)]
ans = 0
for h in range(1<<H):
    for w in range(1<<W):
        black = 0
        for i in range(H):
            for j in range(W):
                if(a[i][j]!='
                    continue
                if h>>i&1!=0 or w>>j&1!=0:
                    continue
                black+=1
        if black == K:
            ans+=1
print(ans)

Solution (Python):
h, w, k = map(int, input().split())
board = [str(input()) for _ in range(h)]
ans = 0
for i in range(2 ** h):
    for j in range(2 ** w):
        w_of_h = [] 
        for m in range(h):
            if ((i >> m) & 1):
                w_of_h.append(m)
        w_of_w = [] 
        for n in range(w):
            if ((j >> n) & 1):
                w_of_w.append(n)
        cnt = 0
        for H in w_of_h:
            for W in w_of_w:
                if board[H][W] == '
                    cnt += 1
        if cnt == k:
            ans += 1       
print(ans)

Solution (Python):
h, w, k = map(int, input().split())
board = [str(input()) for _ in range(h)]
ans = 0
black = 0
for i in board:
    black += i.count('
for i in range(2 ** h):
    for j in range(2 ** w):
        r_of_h = []
        for m in range(h):
            if ((i >> m) & 1):
                r_of_h.append(m)
        r_of_w = [] 
        for n in range(w):
            if ((j >> n) & 1):
                r_of_w.append(n)
        cnt = 0
        for H in r_of_h:
            for W in r_of_w:
                if board[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):
        cnt = 0
        for m in range(H):
            for n in range(W):
                if ((i >> m) & 1): 
                    continue
                if ((j >> n) & 1): 
                    continue
                if C[m][n] == '
                    cnt += 1
        if cnt == K: 
            ans += 1
        
print(ans)

Solution (Python):
h, w, k = map(int, input().split())
mat = [input() for _ in range(h)]
ans = 0
for row in range(2**h):
    for col in range(2**w):
        bs = 0
        for r in range(h):
            for c in range(w):
                if mat[r][c] == '
                    bs += 1
        if bs == k:
            ans += 1
print(ans)

Solution (Python):
import sys
import math
import heapq
from collections import defaultdict, deque
from decimal import *
def r():
    return int(input())
def rm():
    return map(int,input().split())
def rl():
    return list(map(int,input().split()))
mod=1000000007

H,W,k=rm()
a=[list(input()) for i in range(H)]
ans=0
for h in range(1<<H):
    for w in range(1<<W):
        count=0
        for i in range(H):
            for j in range(W):
                if (a[i][j]!='
                    continue
                if h>>i&1!=0 or w>>j&1!=0:
                    continue
                count+=1
        if count==k:
            ans+=1
print(ans)

Solution (Python):
import itertools as it
H, W, K = map(int, input().split())
A = []
for i in range (0, H):
	A.append(list(map(str, input().split())))


Hbit = list(it.product([0,1], repeat = H))
Wbit = list(it.product([0,1], repeat = W))

count = 0
shouldbeK = 0 

for i in range (0, 2**H):
	for j in range (0, 2**W):
		shouldbeK = 0
		for k in range (0, H):
			for l in range (0, W):
				if Wbit[j][l] == 0 and Hbit[i][k] == 0 and str(A[k])[l+2] == '
					shouldbeK+=1
		if  shouldbeK == K:
			count+=1
        
print(count)

Solution (Python):
import numpy as np
import itertools
from copy import copy
def DetK(Column,Row,Colors):
  for i in Column:
    Colors[i,:] = "r"
  for j in Row:
    Colors[:,j] = "r"
  K=np.where(Colors=="
  return K
H,W,K=map(int,input().split())
Colors=[]
for i in range(H):
  Colors.append(np.array(list(input())))
Colors=np.array(Colors)
ans=0
for i in range(H+1):
  for j in range(W+1):
    Columns=list(itertools.combinations(range(H),i))
    Rows=list(itertools.combinations(range(W),j))
    for Column in Columns:
      for Row in Rows:
        if DetK(Column,Row,copy(Colors))==K:
          ans+=1
print(ans)

Solution (Python):
H, W, K = map(int, input().split())
c = []
for _ in range(H):
  c.append(input())
 
ans = 0  
for h in range(2 ** H):
  for w in range(2 ** W):
    b = 0
    for i in range(H):
      for j in range(W):
        if (h >> i) & 1 == 0 and (w >> j) & 1 ==0:
          if c[i][j] == '
            b += 1
    if b == K:
      ans += 1
print(ans)

Solution (Python):
import itertools
def resolve():
    H,W,K = map(int,input().split())
    C = []
    for i in range(H):
        C.append(input())
    
    ans = 0
    for i in range(H+1):
        for j in range(W+1):
            for n in itertools.combinations(list(range(H)),i):
                for m in itertools.combinations(list(range(W)),j):
                    count = 0
                    for a in n:
                        for b in m:
                            if(C[a][b] == "
                    if(count == K):
                        ans += 1
    print(ans)
resolve()

Solution (Python):
from itertools import product

H, W, K = map(int, input().split())
table = []
for i in range(H):
    table.append(input())
ans = 0
for is_red_h in product([False, True], repeat=H):
    for is_red_w in product([False, True], repeat=W):
        black = 0
        for i in range(H):
            if is_red_h[i]:
                continue
            for j in range(W):
                if is_red_w[j]:
                    continue
                if table[i][j] == "
                    black += 1
        if black == K:
            ans += 1
print(ans)

Solution (Python):
from itertools import product

h, w, k = map(int, input().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 k == cnt:
      ans += 1
print(ans)

Solution (Python):
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30

def main():
    h, w, k = list(map(int, input().strip().split()))
    c = [0] * h
    for i in range(h):
        c[i] = input().strip()
    ans = 0
    for p in range(2**h):
        for q in range(2**w):
            count = 0
            for i in range(h):
                for j in range(w):
                    if not (p >> i)&1 and not (q >> j)&1 and c[i][j] == '
                        count += 1
            
            if count == k:
                ans += 1
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
H,W,K = map(int,input().split())
C = list(list(input())for _ in range(H))
ans = 0
for h in range(2**H):
    for w in range(2**W):
        count = 0
        for i in range(H):
            if 1<<i & h:
                continue
            for j in range(W):
                if 1<<j & w:
                    continue
                if C[i][j] == "
                    count += 1
        if count == K:
            ans += 1
print(ans)

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

for i in range(h):
  c.append(input())
ans = 0
for markH in range(2**h):
  for markW in range(2**w):
    black = 0
    for i in range(h):
      for j in range(w):
        if (markH>>i)&1 and (markW>>j)&1 and c[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):
    
    T = [c[j] for j in range(h) if (i >> j) & 1]
    
    for j in range(2 ** w): 
        x = 0
        
        for m in range(w):
            
            
            if (j >> m) & 1:
                for n in range(len(T)):
                    if T[n][m] == "
                        x += 1
        
        if x == 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):
        cnt = 0
        for x in range(H):
            for y in range(W): 
                if ((i>>x)&1 == 0) and ((j>>y)&1 == 0) and C[x][y] == '
                    cnt += 1
        if cnt == K:
            ans += 1
print(ans)

Solution (Python):
h, w, k = [int(i) for i in input().split()]
masu = [input() for _ in range(h)]
ans = 0
for mark_h in range(2**h):
    for mark_w in range(2**w):
        black = 0
        for i in range(h):
            for j in range(w):
                if (mark_h>>i)&1==1 and (mark_w>>j)&1==1:
                    if masu[i][j]=="
                        black+=1
        if black==k:
            ans+=1
print(ans)

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

ans = 0  
for h in range(2 ** H):
  for w in range(2 ** W):
    b = 0
    for i in range(H):
      for j in range(W):
        if (h >> i) & 1 == 0 and (w >> j) & 1 ==0:
          if c[i][j] == '
            b += 1
    if b == K:
      ans += 1
print(ans)