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 i in range(h)]
ans = 0  
for row in range(1 << h):  
    for col in range(1 << w):  
        cnt = 0  
        for i in range(h):
            for j in range(w):
                if row >> i & 1:
                    
                    continue
                if col >> j & 1:
                    
                    continue
                if c[i][j] == "
                    
                    cnt += 1
        ans += cnt == k  
        
        
        
print(ans)

Solution (Python):
H, W, K, *C = open(0).read().split()
C = sum([list(c) for c in C], [])
H = int(H)
W = int(W)
K = int(K)
ans = 0


for row in range(1 << H):
    for col in range(1 << W):
        cnt = 0
        for h in range(H):
            for w in range(W):
                if (row >> h) & 1 and (col >> w) & 1 and C[h*W+w] == "
                    cnt += 1
        if cnt == K:
            ans += 1
print(ans)

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

import copy


ans = 0
for f in range(2**(H+W)):
    
    
    B = copy.deepcopy(C)
    for bit in range(H+W):
        if f & (1<<bit):
            if bit < W:
                
                for i in range(H):
                    B[i][bit] = '.'
            else:
                
                bit -= W
                for i in range(W):
                    B[bit][i] = "."
    
    
    
    rem = 0
    for line in B:
        rem += ''.join(line).count('
    
    if rem == K:
        ans += 1

print(ans)

Solution (Python):
a = input().rstrip().split(" ")
 
H = int(a[0])   
W = int(a[1])   
K = int(a[2])   
 
m = []
for i in range(H):
    n = list(input())
    m.append(n)
 

ans = 0
 

for maskR in range(1 << H):
    for maskC in range(1 << W):
        black = 0
        
        for i in range(H):
            for j in range(W):
                if (maskR >> i & 1) == 0 and (maskC >> j & 1) == 0 and m[i][j] == "
                    black += 1
    
        if black == 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 i in range(2**h):
    for j in range(2**w):
        counter = 0
        for m in range(h):
            for n in range(w):
                    if (i>>m)&1 == 0 and (j>>n)&1 == 0 and C[m][n] == '
                        counter += 1
                    else:
                        continue
                        
        if counter == k:
            ans += 1
print(ans)

Solution (Python):
h,w,q=map(int,input().split())
c2=[input() for _ in range(h) ]
ans=0
for i in range(1<<w):
  for j in range(1<<h):
    b=0
    for x in range(w):
      for y in range(h):
        if (i>>x &1)==0 and (j>>y &1)==0 and c2[y-1][x-1]=="
          b+=1   
    if b==q:
      ans+=1
print(ans)

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

for bit_h in range(1 << h):
  i_list = []
  for i in range(h):
    if bit_h & 1:
      i_list.append(i)
    bit_h >>= 1
  for bit_w in range(1 << w):
    count = 0
    j_list = []
    for j in range(w):
      if bit_w & 1:
        j_list.append(j)
      bit_w >>= 1
    for i in i_list:
      for j in j_list:
        if mark[i][j] == '
          count += 1
    if count == k:
      ans += 1
print(ans)

Solution (Python):
import itertools


H, W, K = map(int,input().split())  
init_map = []
for i in range(H):
    row = list(input())  
    init_map.append(row) 
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 init_map[i][j] == "
                        cnt += 1
        if cnt==K:
            ans += 1
print(ans)

Solution (Python):
h,w,k=map(int, input().split( ))
c=[input() for _ in range(h)]
bh=1<<h
bw=1<<w
ans=0
for i in range(bh):
    for j in range(bw):
        cnt=0
        for x in range(h):
            for y in range(w):
                if (1&(i>>x)) or (1&(j>>y)) or c[x][y]==".":
                    continue
                cnt+=1
        if cnt==k:
            ans+=1
                
print(ans)

Solution (Python):
H, W, K = map(int, input().split())
grid = [input() for _ in range(H)]
ans = 0
for mh in range(1<<H):
    for mw in range(1<<W):
        count = 0
        for h in range(H):
            for w in range(W):
                if (mh>>h & 1) == 0 and (mw>>w & 1)==0 and grid[h][w]=='
                    count+=1
        if count==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(2**H):
    for C in range(2**W):
        black = 0
        for i in range(H):
            for j in range(W):
                if (not (R >> i) & 1) and (not (C >> j) & 1) and (c[i][j] == '
                    black += 1
        if black == K:
            ans += 1
print(ans)

Solution (Python):
import numpy as np
import copy
h,w,k=map(int, input().split())
c=[list(input())  for i in  range(h)]
c=np.array(c)
def makeBag(n):
  bagl=[]
  for i in range(2**n):
      bag=[0]*n
      
      for j in range(n):
          if ((i>>j) & 1):
              bag[j]=1
      bagl.append(bag)
  return bagl
bagh=makeBag(h)
bagw=makeBag(w)

ans=0
for i in bagh:
  co=copy.deepcopy(c)
  
  for ii in range(h):
    if i[ii]==1:
      co[ii][:]=["r"]*len(co[ii][:])
  
  co=co.T
  co2=copy.deepcopy(co)
  for j in bagw:
    co=copy.deepcopy(co2)
    
    for jj in range(w):
      if j[jj]==1:
        co[jj][:]=["r"]*len(co[jj][:])
  
    
    if np.sum(co=="
      ans+=1
      
print(ans)

Solution (Python):
import copy
h,w,k=map(int,input().split())
c=[list(map(lambda x:x=="
ans=0
for p in range(2**h):
	for q in range(2**w):
		d=copy.deepcopy(c)
		for i in range(h):
			for j in range(w):
				if (p>>i)%2==1 or (q>>j)%2==1:
					d[i][j]=False
		x=0
		for i in range(h):
			for j in range(w):
				if d[i][j]:
					x+=1
		if x==k:
			ans+=1
print(ans)

Solution (Python):
import itertools


H, W, K = map(int,input().split())
init_map = []
for i in range(H):
    row = list(input())
    init_map.append(row)
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 init_map[i][j] == "
                        cnt += 1
        if cnt==K:
            ans += 1
print(ans)

Solution (Python):

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

ans = 0
for i in range(2 ** h):
    for j in range(2 ** w):
        cnt = 0  
        for r in range(h):
            for c in range(w):
                if grid[r][c] == "
                    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(list(input()))

ans = 0
for i in range(1<<H): 
    for j in range(1<<W): 
        count = 0
        for i2 in range(H):
            for j2 in range(W):
                bit_i = i>>i2 & 1
                bit_j = j>>j2 & 1
                if bit_i == 1 or bit_j == 1:
                    continue
                if C[i2][j2] == '
                    count += 1
        if count == K:
            ans += 1

print(ans)

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

ans =0

for s in range(2**h):
    b_h = '{:06b}'.format(s)
    for t in range(2**w):
        b_w = '{:06b}'.format(t)
        black = 0
        for i in range(h):
            for j in range(w):
                if C[i][j]=='
                    black += 1
        if black==k:
            ans +=1
print(ans)

Solution (Python):
import copy


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

    def helper(li):
        count = 0
        for i in range(len(li)):
            for j in range(len(li[i])):
                if li[i][j] == "
                    count += 1
        return count

    def get_all_selection(num):
        li = []
        if num == 0:
            return []
        if num == 1:
            return [[False], [True]]
        for l in get_all_selection(num - 1):
            li.append([False] + l)
            li.append([True] + l)
        return li

    answer = 0

    for sh in get_all_selection(H):
        for sw in get_all_selection(W):
            c = copy.deepcopy(C)
            for i in range(H):
                if not sh[i]:
                    c[i] = ["-"] * W
            for i in range(W):
                if not sw[i]:
                    for l in c:
                        l[i] = "-"

            black_count = helper(c)
            if black_count == K:
                answer += 1
                

    print(answer)


q3()

Solution (Python):
H,W,K=map(int,input().split())
c=[list(input()) for i in range(H)]
count=0
for bit in range(1<<(H+W)):
    black=0
    for shift_h in range(H):
        for shift_w in range(W):
            if c[shift_h][shift_w]=="
                black+=1
    if black==K:
        count+=1
print(count)

Solution (Python):
from itertools import combinations

H, W, K = [int(x) for x in input().split()]

field = []

for i in range(H):
    width = []
    for j, x in enumerate(input()):
        if x == '.':
            width.append(0)
        else:
            width.append(1)
    field.append(width)

result = 0

for h in range(2**H):
    for w in range(2**W):
        count = 0
        for y in range(H):
            for x in range(W):
                if ((h >> y) & 1):
                    if ((w >> x) & 1):
                        count += field[y][x]
        if count == K:
            result += 1
        

print(result)

Solution (Python):
import sys
sys.setrecursionlimit(10**8)
def mi(): return map(int, sys.stdin.readline().split())

H, W, K = mi()
C = [input() for i in range(H)]

B_i = 2 ** H
B_j = 2 ** W

ans = 0
for x in range(B_i):
    for y in range(B_j):
        cnt = 0
        for i in range(H):
            for j in range(W):
                if (x & (1 << i)) or y & (1 << j):
                    continue
                if C[i][j] == '
                    cnt += 1
        if cnt == K:
            ans += 1
                
print(ans)

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

Solution (Python):
from itertools import product
import copy

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

ans = 0
for x in product([0,1], repeat=W):
    for y in product([0,1], repeat=H):
        c_cp = copy.deepcopy(C)
        
        
        
        for idx, i in enumerate(x):
            if i == 1:
                for n in range(H):
                    c_cp[n][idx] = "r"
        for idx, j in enumerate(y):
            if j == 1:
                for n in range(W):
                    
                    c_cp[idx][n] = "r"
        cnt = 0
        
        for s in c_cp:
            for t in s:
                if t == "
                    cnt += 1
        if cnt == K:
            ans += 1
print(ans)

Solution (Python):
n,m,k=map(int,input().split())
l=[]
for i in range(n):
    l.append(list(input()))
res=0
for i in range(2**n-1):
    for j in range(2**m-1):
        b=0
        for x in range(n):
            for y in range(m):
                c=2**x
                d=2**y
                if i&c==0 and j&d==0 and l[x][y]=="
                    b+=1
        if b==k:
            res+=1
print(res)

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

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

Solution (Python):
from itertools import product
h,w,k = map(int, input().split())
hw = [[0 for j in range(w)] for i in range(h)]
total = 0
htotal = [0 for i in range(h)]
wtotal = [0 for i in range(w)]

for i in range(h):
	line = [s for s in input()]
	for j in range(len(line)):
		if line[j]=='
			hw[i][j]=1
	htotal[i]=sum(hw[i])
for i in range(w):
	res=0
	for j in range(h):
		if hw[j][i]:
			res+=1
	wtotal[i]=res
total = sum(htotal)


ans = 0
for bit in product(range(2),repeat=w+h):
	wbit=bit[:w]
	hbit=bit[w:]
	res=0
	for i,v in enumerate(wbit):
		if v:res-=wtotal[i]
	for i,v in enumerate(hbit):
		if v:res-=htotal[i]
	
	for i,hv in enumerate(hbit):
		if hv:
			for j,wv in enumerate(wbit):
				if wv:
					if hw[i][j]:
						res+=1
	
	if total+res==k:
		ans+=1
		
print(ans)

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


res = 0
for h in range(2**H):
    for w in range(2**W):
        cnt = 0
        for i in range(H):
            if (h>>i)&1:
                continue
            for j in range(W):
                if (w>>j)&1:
                    continue
                if c[i][j] == "
                    cnt += 1
                    
        if cnt == K:
            res += 1

print(res)

Solution (Python):
h,w,k=map(int,input().split())
c=[input() for _ in range(h)]
count=0
for H in range(1<<h):
  for W in range(1<<w):
    b=0
    for i in range(h):
      for j in range(w):
        if (H >> i) & 1 == 0 and (W >> j) & 1 == 0 and c[i][j] == "
          b+=1
    if b==k:
      count+=1
print(count)

Solution (Python):
H,W,K=map(int,input().split())
c=[list(input()) for i in range(H)]
count=0
for bit_h in range(1<<H):
    for bit_w in range(1<<W):
        black=0
        for shift_h in range(H):
            for shift_w in range(W):
                if c[shift_h][shift_w]=="
                    black+=1
        if black==K:
            count+=1
print(count)

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

ans = 0
for i in range(2**H):
    for j in range(2**W):
        tmp = 0
        for ii in range(H):
            for jj in range(W):
                if C[ii][jj] == '
                    tmp += 1
        if tmp == K:
            ans += 1
            
print(ans)

Solution (Python):
import itertools
import copy
def row(c, i, H, W):
  for j in range(W):
    c[i][j] = 0
    
def column(c, j, H, W):
  for i in range(H):
    c[i][j] = 0

def blacks(c, H, W):
  black = 0
  for row in c:
    black += sum(row)
  return black

H, W, K = map(int, input().split())
c = []
for i in range(H):
  c.append([])
  string = input()
  for color in string:
    if color == '
      c[-1].append(1)
    else:
      c[-1].append(0)
height = list(itertools.product([0, 1], repeat=H))
weight = list(itertools.product([0, 1], repeat=W))
answer = 0
for tate in height:
  for yoko in weight:
    cc = copy.deepcopy(c)
    for i in range(len(tate)):
      if tate[i]:
        row(cc, i, H, W)
    for j in range(len(yoko)):
      if yoko[j]:
        column(cc, j, H, W)
    if blacks(cc, H, W) == K:
      answer += 1
print(answer)

Solution (Python):
import copy
h,w,k=map(int,input().split())
c=[list(input()) for i in range(h)]
ans=0
for bit1 in range(1<<h):
    for bit2 in range(1<<w):
        count=0
        map=copy.deepcopy(c)
        for i in range(h):
            if bit1 & (1<<i):
                for j in range(w):
                    if map[i][j]=="." or map[i][j]=="
                        map[i][j]="!"
        for i in range(w):
            if bit2 & (1 << i):
                for j in range(h):
                    if map[j][i] == "." or map[j][i] == "
                        map[j][i] = "!"

        for i in range(h):
            for j in range(w):
                if map[i][j]=="
                    count+=1
        if count==k:
            ans+=1
print(ans)

Solution (Python):
a = input().rstrip().split(" ")

H = int(a[0])   
W = int(a[1])   
K = int(a[2])   

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


ans = 0


for maskR in range(1 << H):
    for maskC in range(1 << W):
        black = 0
        
        for i in range(H):
            for j in range(W):
                if (maskR >> i & 1) == 0 and (maskC >> j & 1) == 0 and m[i][j] == "
                    black += 1
    
        if black == K:
            ans += 1

print(ans)

Solution (Python):
import numpy as np

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

arr = np.empty((H,W))

count = 0


for i in range(H):
    str_list = list(input())
    str_list_replaced1 = [s.replace("
    str_list_replaced2 = [s.replace(".","0") for s in str_list_replaced1]
    arr[i:] = np.array(str_list_replaced2)


for i in range(2**H):
    for j in range(2**W):
        mask = np.zeros(shape=(H,W))
        mask_i_tmp = [int(k) for k in format(i,"06b")][-H:]
        mask_j_tmp = [int(k) for k in format(j,"06b")][-W:]

        mask_i = mask + np.expand_dims(np.array(mask_i_tmp),-1)
        mask_j = mask + np.expand_dims(np.array(mask_j_tmp),-1).T
        masked_arr = arr.astype(bool) & mask_i.astype(bool) & mask_j.astype(bool)

        
        if np.sum(masked_arr) == K:
            count += 1 

print(count)

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

ans = 0
for mask_h in range(2**H):
    for mask_w in range(2**W):
        cnt = 0
        for i in range(H):
            for j in range(W):
                if ((mask_h >> i) & 1) == 0 and ((mask_w >> j) & 1) == 0 \
                    and C[i][j] == '
                    cnt += 1
        if cnt == K:
            ans += 1
print(ans)

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

C = [[0] * W for _ in range(H)]
cnt = 0
for h in range(H):
    tmp = list(input())
    for w in range(W):
        if tmp[w] == "
            C[h][w] = 1

for h in range(2**H-1):
    for w in range(2**W-1):
        b = 0
        for i in range(H):
            if (h>>i) & 1 == 1:
                continue
            for j in range(W):
                if (w>>j) & 1 == 1:
                    continue
                b += C[i][j]
        if K == b:
            cnt += 1

print(cnt)

Solution (Python):
h,w,k=map(int,input().split())
c=[]
total=0
for i in range(h):
  tmp=list(input())
  c.append(tmp)
  total+=tmp.count("
ans=0
for i in range(1<<h):
  for j in range(1<<w):
    cnt=0
    for l in range(h):
      for m in range(w):
        if i&(1<<l) and j&(1<<m) and c[l][m]=="
          cnt+=1
          
    if cnt==k:
      ans+=1
print(ans)

Solution (Python):

import numpy as np

H, W, K = map(int,input().split())
D = np.zeros([H,W])

black_count = 0
for i in range(H):
    C = list(input())
    for j in range(len(C)):
        if(C[j] == "
            D[i][j] = 1



for i in range(2**H):
    h = format(i, '06b')
    for j in range(2**W):
        w = format(j, '06b')
        d = D.copy()

        for hi in range(H):
            if(h[5-hi] == '1'):
                d[hi,:]=0
        for wi in range(W):
            if(w[5-wi] == '1'):
                d[:,wi]=0
            
        if (d.sum() == K):
            black_count += 1

print(black_count)

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):
h,w,k=map(int,input().split())
c=[]
for i in range(h):
    c.append(str(input()))


ans=0
for m in range(2**h):
    for l in range(2**w):
        a=0
        for i in range(h):
            for j in range(w):
                if m>>i&1 and l>>j&1 and c[i][j]=="
                    a+=1
        if a==k:
            ans+=1
print(ans)

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

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

print(ans)

Solution (Python):
import sys
import numpy as np
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

h,w,k = LI()
cnt = 0
c = [0]*h
for i in range(h):
    c[i] = input()

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):
import numpy as np
H,W,K = map(int, input().split())
c = []
for i in range(H):
  tmp = list(input())			
  c.append(tmp)

count = 0
for i in range(int(2**H)):
  tmp = str(bin(i))				
  h_flag = tmp[2:].zfill(H)		
  for j in range(int(2**W)):
    tmp = str(bin(j))			
    w_flag = tmp[2:].zfill(W)	
    num_black = 0
    for m in range(H):
      for n in range(W):
        if h_flag[m] == '0' and w_flag[n] == '0' and c[m][n] == '
          num_black += 1
    if num_black == K:
      count += 1
print(count)

Solution (Python):
import numpy as np
h,w,k = map(int, input().split())

C = []
for _ in range(h):
  C.append([1 if i == '
C = np.array(C)
ans = 0
for i in range(2**h):
  for j in range(2**w):
    row = [l for l in range(h-1, -1, -1) if (i >> l) & 1]
    col = [l for l in range(w-1, -1, -1) if (j >> l) & 1]
    if len(row) > 0 and len(col) > 0:
      
      s = C[row][:,col].sum()
      if len(row) > 1 and len(col) > 1:
        s = s.sum()
    else:
      s = 0
    if s == k:
      ans += 1
    
print(ans)

Solution (Python):
import itertools
H,W,K = map(int,input().split())
init_map = []
for i in range(H):
    row = list(input())
    init_map.append(row)
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 init_map[i][j] == "
                        cnt += 1
        if cnt == K:
            ans += 1
print(ans)

Solution (Python):
import itertools
import numpy as np

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

temp = []
for _ in range(H):
    C = list(input())
    A = [c.replace('.', '0') for c in C]
    A = [a.replace('
    A = list(map(lambda x: int(x), A))
    temp.append(A)

C = np.array(temp)

count = 0
l = [0, 1]
wide = itertools.product(l, repeat=W)
for w in wide:
    hight = itertools.product(l, repeat=H)
    for h in hight:
        copy_C = C.copy()
        
        
        for num, i in enumerate(w):
            if i == 1:
                copy_C[:, num-1] = 0
            for num2, j in enumerate(h):
                if j == 1:
                    copy_C[num2-1, :] = 0
        if copy_C.sum() == K:
            count += 1

print(count)

Solution (Python):


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

black = 0
H = []
W = []
ans = 0

for bit_h in range(2**h):
    for bit_w in range(2**w):
        black = 0
        for i in range(h):
            if not ((bit_h >> i) & 1):
                continue
            for j in range(w):
                if not ((bit_w >> j) & 1):
                    continue
                if c[i][j] == '
                    black += 1
        if black == k:
            ans += 1
print(ans)

Solution (Python):



def main():
    H, W, K = map(int,input().split())
    Tgt = 0 - K
    Ch = [0] * H
    Cw = [0] * W
    Gmap = []
    for h in range(H):
        r = list(map(int, input().replace('.','0').replace('
        Gmap.append(r)
        for w in range(W):
            x = Gmap[h][w]
            Ch[h] += x
            Cw[w] += x
            Tgt += x

    ret = 0
    for hs in range(2**H):
        for ws in range(2**W):
            cnt = 0
            for h in range(H):
                if hs >> h & 1:
                    cnt += Ch[h]
            for w in range(W):
                if ws >> w & 1:
                    cnt += Cw[w]
            for h in range(H):
                for w in range(W):
                    if (ws >> w & 1) and (hs >> h & 1):
                        cnt -= Gmap[h][w]
            if cnt == Tgt:
                ret +=1


    print(ret)

if __name__ == '__main__':
    main()

Solution (Python):
h,w,r = map(int,input().split())
l=[];an=0
cr=[];k=[0]*w
for i in range(h):
  x=list(input())
  l.append(x)
  cr.append(x.count('
  for j in range(w):
    if x[j]=='
      k[j]+=1
ar=cr+k;tot=sum(cr)
tt=len(ar)
for i in range(1<<tt):
  re=tot;rr=[]
  cc=[]
  for j in range(tt):
    if i&(1<<j):
      re-=ar[j]
      if j>=h:
        cc.append(j-h)
      else:
        rr.append(j)
  for j in rr:
    for y in cc:
      if l[j][y]=='
        re+=1
  
  if re==r:
    an+=1
  
print(an)

Solution (Python):
h,w,k = map(int,input().split())
in_list = [[0] * w for i in range(h)]
for i in range(h):
    in_list[i][:] = input()


result = 0
for i in range(2**h):
    for j in range(2**w):
        cnt = 0
        for ih in range(h):
            for iw in range(w):
                if (i>>ih&1)==0 and (j>>iw&1)==0:
                    if in_list[ih][iw]=="
                        cnt+=1
        if cnt==k:
            result += 1
print(result)

Solution (Python):
import copy

H, W, K = map(int, input().split())
data = []
ans = 0
count = 0
for _ in range(H):
    line = list(input())
    count += line.count('
    data.append(line)
omega = count


for h in range(2 ** H):
    copy_data = copy.deepcopy(data)
    for f in range(H):
        if list(bin(h)[2:].zfill(H))[f] == '1':
            count -= copy_data[f].count('
            copy_data[f] = ['.' for _ in range(W)]
    tmp = count
    for w in range(2 ** W):
        count = tmp
        for g in range(W):
            if list(bin(w)[2:].zfill(W))[g] == '1':
                for row in copy_data:
                    if row[g] == '
                        count -= 1
        if count == K:
            ans += 1
    count = omega

print(ans)

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

cnt=0
for i in range(2**h):
  for j in range(2**w):
    black=0
    for hh in range(h):
      if bin((i>>hh)&0b1)==bin(1):
        continue
      for ww in range(w):
        if bin((j>>ww)&0b1)==bin(1):
          continue
        if c[hh][ww]=="
          black+=1
    if black==k:
        cnt+=1
print(cnt)

Solution (Python):
import copy
H,W,K = map(int,input().split())
C = [list(input()) for _ in range(H)]
N = 0
for i in range(H):
  N += C[i].count("
ans = 0
for i in range(2**(H+W)):
  c = copy.deepcopy(C)
  R = 0
  for j in range(H+W):
    if ((i >> j) & 1):
      if j < H:
        R += c[j].count("
        c[j] = ["R"]*W
      else:
        for k in range(H):
          if c[k][j-H] == "
            R += 1
  if N - R == K:
    ans += 1
print(ans)

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

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

def LI(): return list(map(int, stdin.readline().split()))
def LS(): return list(stdin.readline().rstrip('\n'))

h,w,k = LI()
a = [LS() for i in range(h)]
ans = 0
for r in range(1<<h):
    for c in range(1<<w):
        count = 0
        for i in range(h):
            for j in range(w):
                if (r>>i&1)==0 and (c>>j&1)==0 and a[i][j]=='
                    count += 1
        if count==k:
            ans += 1
print(ans)

Solution (Python):
H, W, K = map(int, input().split())
graph = []
for i in range(H):
    graph.append(list(input()))
    
ans = 0
for i in range(2**H):
    for j in range(2**W):
        black = 0
        for k in range(H):
            for l in range(W):
                if((i>>k)&1 == 0 and (j >>l)&1 == 0 and graph[k][l] == "
                    black += 1
        if(black == K):
            ans += 1
print(ans)

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

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



cnt = 0
for rows in range(1 << h):
    for columns in range(1 << w):
        black = 0
        for i in range(h):
            if (rows >> i)%2 == 1:
                continue
            for j in range(w):
                if (columns >> j)%2 == 1:
                    continue
                if mas[i][j] == "
                    black += 1
        if black == k:
            cnt += 1
print(cnt)

Solution (Python):
'''
参考
https://note.com/tanon_cp/n/n9b0a77fcda7d
https://qiita.com/u2dayo/items/90a0693f31524e7b4cd0
bit全探索を使用する
'''
from itertools import product

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

ans = 0


for b_row in product([0, 1], repeat=H):             
    for b_col in product([0, 1], repeat=W):         
        cnt = 0
        for i in range(H):
            for j in range(W):                      
                if b_row[i] == 0 and b_col[j] == 0: 
                    if c[i][j] == '
                        cnt += 1
        if cnt == K:                                
            ans += 1                                

print(ans)