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())
arr = [input() for _ in range(h)]

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

print(ans)

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

for fill_h in range(2**h):
  for fill_w in range(2**w):
    cnt = 0
    for i in range(h):
      for j in range(w):
        if (fill_h >> i)&1 == 0 and (fill_w >> j)&1 == 0:
          if matrix[i][j] == '
            cnt += 1
    if cnt == k:
      ans += 1
      
print(ans)

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

masu = []

for i in range(h):
    masu.append(list(input()))
    
count = 0

import copy

for i in range(2**h):
    for j in range(2**w):
        
        m = copy.deepcopy(masu)
        blacknum = 0
        
        for k in range(h):
            for l in range(w):
                if i>>k&1 == 0 and j>>l&1 == 0 and m[k][l] == "
                    blacknum = blacknum + 1
                
                    
        if blacknum == kazu:
            count = count+1
            
            
print(count)

Solution (Python):
import itertools

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

lines = []
for i in range(h):
    lines.append(input())

result = 0

h_indexes = range(h)
w_indexes = range(w)

for i in range(h + 1):
    for j in range(w + 1):
        for h_index_list in itertools.combinations(h_indexes, i):
            for w_index_list in itertools.combinations(w_indexes, j):
                cnt = 0
                for h_index in h_index_list:
                    for w_index in w_index_list:
                        if '
                            cnt += 1
                if cnt == k:
                    result += 1

print(result)

Solution (Python):
import copy
H, W, K = map(int, input().split())
map_info = [list(input()) for i in range(H)]
bits = H + W
count_total = 0
ans = 0


for row in range(2 ** H):
    
    for column in range(2 ** W):
        map_updated = copy.deepcopy(map_info)
        count = 0
        
        for bit_row in range(H):
            count = 0
            
            if (row >> bit_row) & 1:
                map_updated[bit_row] = ['*' for i in map_updated[bit_row]]
        
        for bit_column in range(W):
            count = 0
            
            if (column >> bit_column) & 1:
                for j in range(H):
                    map_updated[j][bit_column] = '*'
        
        for i in range(H):
            count += map_updated[i].count('
        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())
H_flag = [0 for i in range(H)]
W_flag = [0 for j in range(W)]
ans = 0
for i in range(2 ** H):
    for k  in range(H):
        H_flag[k] = i % 2
        i = i // 2
    for j in range(2 ** W):
        for l in range(W):
            W_flag[l] = j % 2
            j = j // 2
        tmp_black = 0
        for x in range(H):
            for y in range(W):
                if H_flag[x] == 0 and W_flag[y] == 0:
                    if c[x][y] == '
                        tmp_black += 1
        if tmp_black == K:
            ans += 1
print(ans)

Solution (Python):
import itertools
import numpy as np

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

ans=0
for i in range(2**H):
     for j in range(2**W):
            i_s=format(i, "0{0}b".format(H))
            j_s=format(j, "0{0}b".format(W))
            M=[[[] for _ in range(W)] for _ in range(H)]
            for h in range(H):
                for w in range(W):
                    if i_s[h]=="1" or j_s[w]=="1":
                        M[h][w]="$"
                    else:
                        M[h][w]=m[h][w]
            M_1=list(itertools.chain.from_iterable(M))
            if M_1.count("
                ans+=1
            
print(ans)

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

cnt = 0
h_dict = {i: 0 for i in range(h)}
w_dict = {i: 0 for i in range(w)}
for i, c in enumerate(arr):
    cnt_h = c.count('
    cnt += cnt_h
    h_dict[i] = cnt_h
    for j, c_ in enumerate(c):
        if arr[i][j] == '
            w_dict[j] += 1

ans = 0
for bit_h in range(2**h):
    tmp_h = []
    for i in range(h):
        if (bit_h >> i) & 1:
            tmp_h.append(i)
    for bit_w in range(2**w):
        tmp_w = []
        for j in range(w):
            if (bit_w >> j) & 1:
                tmp_w.append(j)
        tmp = 0
        for h_ in tmp_h:
            tmp += h_dict[h_]
        for w_ in tmp_w:
            tmp += w_dict[w_]
        for h_ in tmp_h:
            for w_ in tmp_w:
                if arr[h_][w_] == '
                    tmp -= 1

        if cnt - tmp == k:
            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())
nb=0
a=[[0 for i in range(w)] for j in range(h)]
for i in range(h):
    s=input()
    for j in range(w):
        if s[j]=="
            a[i][j]=1
            nb+=1

res=0
for ii in range(2**h):
    for jj in range(2**w):
        cnt=nb
        for i in range(h):
            for j in range(w):
                if a[i][j]==1 and (ii&(1<<i) or jj&(1<<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)]
ans = 0
for bit in range(1<<(h+w)):
    cnt = 0
    for i in range(h):
        if (bit>>i)&1:continue
        for j in range(w):
            if(bit>>(h+j))&1:continue
            if c[i][j] == '
                cnt += 1
    if cnt == k:
        ans += 1
print(ans)

Solution (Python):


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

c = [list(str(input())) for j in range(h)]

ans = 0

for maskR in range(2**h):
    for maskC in range(2**w):
        black = 0
        for i in range(h):
            for j in range(w):
                if ((maskR >> i) & 1) == 0 and ((maskC >> j) & 1) == 0 and c[i][j] == '
                    black += 1
        if black == k:
            ans += 1

print(ans)

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

ans = 0
for row in range(1<<h):
    for col in range(1<<w):
        d = copy.deepcopy(c)
        sum = 0
        for i in range(h):
            if row & (1<<i):
                for j in range(w):
                    d[i][j] = '.'
        for j in range(w):
            if col & (1<<j):
                for i in range(h):
                    d[i][j] = '.'

        for i in range(h):
            for j in range(w):
                if d[i][j] == '
                    sum+=1
        if sum == k:
            ans+=1
print(ans)

Solution (Python):
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 = (int(x) for x in input().split())

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

counter = 0
for h in range(1<<H):
    for w in range(1<<W):
        hmask = format(h, 'b').zfill(H)
        wmask = format(w, 'b').zfill(W)

        bcounter = 0
        for i in range(H):
            for j in range(W):
                if hmask[i] == '0' and wmask[j] == '0' and c[i][j] == '
                     bcounter += 1
        if bcounter == K:
            counter += 1

print(counter)

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

ans = 0
for maskR in range(1 << H):
  for maskC in range(1 << W):
    blk = 0
    
    for i in range(H):
      for j in range(W):
        if ((maskR >> i) & 1) == 0 and ((maskC >> j) & 1) == 0 and c[i][j] == '
          blk += 1
    if blk == K:
      ans += 1
    
print(ans)

Solution (Python):
def main():
    from itertools import product

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

    tot = sum(g.count('

    ans = 0
    for row_select in product([0, 1], repeat=H):
        for col_select in product([0, 1], repeat=W):
            cnt = tot
            for r, ser in enumerate(row_select):
                for c, sec in enumerate(col_select):
                    if (G[r][c] == '
                        cnt -= 1
            if cnt == K:
                ans += 1

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
def main():
  h, w, k = map(int, input().split())
  s = [input() for _ in range(h)]
  ans = 0
  for i in range(2**h):
    for j in range(2**w):
      if z(s, b(j, w), b(i, h)) == k:
        ans += 1
  print(ans)


def z(s, row, col):
  return sum(
    sum(0 if s[i][j] == '.' or c or r else 1 for j, r in enumerate(row))
    for i, c in enumerate(col)
  )

def b(n, digit):
  return [n // (2**i) % 2 for i in range(digit)]

main()

Solution (Python):
import copy
h,w,k=map(int,input().split())
c=[[[".","
p=0
for i in range(2**h):
    a=bin(i)[2:].zfill(h)
    for j in range(2**w):
        b=bin(j)[2:].zfill(w)
        d=copy.deepcopy(c)
        for x in range(w):
            if b[x]=="1":
                for y in range(h):
                    d[y][x]=0
        for x in range(h):
            if a[x]=="1":
                d[x]=[0]*w
        q=0
        for x in d:
            q+=sum(x)
        if q==k:
            p+=1
print(p)

Solution (Python):
H, W, K = map(int,(input().split()))
c = []
for _ in range(H):
  c.append(input())
ans = 0
for maskR in range((1<<H)-1):
  for maskC in range((1<<W)-1):
    black=0
    for i in range(H):
      for j in range(W):

        if ((maskR >> i) & 1) == 0 and ((maskC >> j) & 1) == 0 and  c[i][j] == '
           black += 1
    if black == K:

      ans += 1
print(ans)

Solution (Python):
import copy
h,w,k=map(int,input().split())
mylist=[list(input()) for i in range(h)]
ans=0

for i in range(2**h):
    l=copy.deepcopy(mylist)
    for j in range(h):
        if (i>>j&1):
            for q in range(w):
                l[j][q]="!"
    for m in range(2**w):
        l2=copy.deepcopy(l)
        for n in range(w):
            if (m>>n&1):
                for o in range(h):
                    l2[o][n]="!"
        cnt=0
        for p in range(h):
            cnt+=l2[p].count("
        if cnt==k:
            ans+=1
print(ans)

Solution (Python):
def ten2bi(i, N):
    bi_list = []    
    for j in range(N):
        if i >= 2**(N - j - 1):
            bi_list.append(1)
            i -= 2**(N - j - 1)
        else:
            bi_list.append(0)

    return bi_list

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

c_list = [list(str(input())) for i in range(H)]

ans = 0
k = 0

for i in range(2**H):
    for j in range(2**W):
        row_list = ten2bi(i, H)
        column_list = ten2bi(j, W)
        for h in range(H):
            for w in range(W):
                if row_list[h] == 0 and column_list[w] == 0:
                    if c_list[h][w] == '
                        k += 1
        if k == K:
            ans += 1
        k = 0

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 cnt == k:
            ans += 1

print(ans)

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

black_num = 0
temp_list = []
row_bit = []
line_bit = []

ans = 0







if 1 == 2:
    print()
else:
    for i in range(2**h):
        temp_bit = [0] * h

        for j in range(h):
            if((i >> j) & 1):
                temp_bit[h - 1 - j] = 1

        row_bit.append(temp_bit)

    for i in range(2**w):
        temp_bit = [0] * w

        for j in range(w):
            if((i >> j) & 1):
                temp_bit[w - 1 - j] = 1

        line_bit.append(temp_bit)

    
    

    for cnt_row in range(2**h):
        for cnt_line in range(2**w):
            temp_list = []
            black_num = 0
            for cnt_h in range(h):
                if row_bit[cnt_row][cnt_h] == 0:
                    
                    for cnt_w in range(w):
                        if line_bit[cnt_line][cnt_w] == 0:
                            
                            if c[cnt_h][cnt_w] == '
                                black_num += 1

            
            
            
            
            
            if black_num == k:
                ans += 1

    print(ans)

Solution (Python):
h,w,k1=map(int,input().split())
c=[]
ans=0
for i in range(h):
    c.append(list(input()))
for i in range(2**(h+w)):
    lh=[]
    lw=[]
    num=0
    for j in range(h):
        if (i >> j) & 1:
            lh.append(j)
    for j in range(h,h+w):
        if (i >> j) & 1:
            lw.append(j-h)
    for j in range(len(lh)):
        for kk in range(len(lw)):
            if c[lh[j]][lw[kk]]=="
                num+=1
    if num==k1:
        ans+=1
print(ans)

Solution (Python):
import copy
import itertools

H,W,K = map(int,input().split())
C=[]
Hl=[]
Wl=[]
for h in range(H):
  C.append(list(input()))
  
for i in range(H+1):
  Hl+=list(map(list,itertools.combinations(range(H),i)))
for i in range(W+1):
  Wl+=list(map(list,itertools.combinations(range(W),i)))

def check (D):
  count=0
  for h in range(H):
    for w in range(W):
      if(D[h][w]=="
        count+=1
  return count

def paint (D):
  ans=0
  for hl in Hl:
    for wl in Wl:
      D1 = copy.deepcopy(D)
      count =0
      for h in range(H):
        for w in range(W):
          if(h in hl or w in wl):
            D1[h][w] ="r"
      if(K==check(D1)):
        ans +=1
  return ans

print(paint(C))

Solution (Python):
h,w,k = map(int,input().split())
c = [list(input()) for _ in range(h)]
cnt = 0
for p_h in range(2**h):
    for p_w in range(2**w):
        black = 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]=='
                            black += 1
        if black == k:
            cnt += 1
print(cnt)

Solution (Python):
from itertools import product
h,w,k=map(int,input().split())
M=[input() for i in range(h)]
a=0
for A in product([0,1],repeat=h):
    for B in product([0,1],repeat=w):
        ANS=0
        for i in range(h):
            for j in range(w):
                if M[i][j]=='
                    ANS+=1
        if ANS==k:
            a+=1

print(a)

Solution (Python):
h,w,k=map(int,input().split())
c=[list(input()) for _ in range(h)]
ans=0
 
for a in range(2**h):
    sa="0"+str(h)+"b"
    la=list(format(a,sa))
    for b in range(2**w):
        sb = "0" + str(w) + "b"
        lb = list(format(b, sb))
        cnt=0
        for i in range(h):
            for j in range(w):
                if la[i]!="1" and lb[j]!="1" and c[i][j]=="
                    cnt+=1
        if cnt==k:
            ans+=1
print(ans)

Solution (Python):
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

h,w,k = inpm()
c=inplL(h)
ans=0
for i in range(2**h):
    for j in range(2**w):
        cnt=0
        for hh in range(h):
            for ww in range(w):
                if (i>>hh)&1 != 1 and (j>>ww)&1 != 1 and c[hh][ww]=='
                    cnt+=1
        if cnt==k:
            ans+=1
                
print(ans)

Solution (Python):
import numpy as np



def power_set(item_lists):

    p_sets = [[]]

    for item in item_lists:
        tmp = []
        for element in p_sets:
            tmp.append(element + [item])
        p_sets.extend(tmp)

    return p_sets

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

mat = [input() for l in range(H)]
mat = [[s[i] for i in range(W)] for s in mat]

mat = np.array([[(0 if mat[i][j]=='.' else 1) for j in range(W)] for i in range(H)])

row_sums=np.array([np.sum(mat[i]) for i in range(H)])
column_sum=np.array([np.sum(mat[:,i]) for i in range(W)])


row_sets=power_set(list(range(H)))
column_sets=power_set(list(range(W)))

preB=np.sum(row_sums)
count=0
for row_set in row_sets:
    for column_set in column_sets:





        dupli=sum([sum([mat[i][j] for j in column_set]) for i in row_set])
        remain=preB-np.sum(row_sums[row_set])-np.sum(column_sum[column_set])+dupli

        if remain==K: 
            count+=1

print(count)

Solution (Python):
number=list(map(int,input().split()))
H,W,K=number[0],number[1],number[2]
M=[]
for i in range(H):
    tmp=list(input())
    M.append(tmp)
answer=0
for rowmask in range(1<<W):
    for cowmask in range(1<<H):
        count=0
        for x in range(H):
            for y in range(W):
                if (rowmask>>y)&1==0 and (cowmask>>x)&1==0 and M[x][y]=="
                    count+=1
        if count==K:
            answer+=1
print(answer)

Solution (Python):
h,w,k=map(int,input().split())
c=[]
ans=0
for i in range(h):
    c.append(list(input()))
for i in range(2**(h+w)):
    lh=[]
    lw=[]
    num=0
    for j in range(h):
        if (i >> j) & 1:
            lh.append(j)
    for j in range(h,h+w):
        if (i >> j) & 1:
            lw.append(j-h)
    for j in range(len(lh)):
        for kk in range(len(lw)):
            if c[lh[j]][lw[kk]]=="
                num+=1
    if num==k:
        ans+=1
print(ans)

Solution (Python):
from itertools import combinations
h,w,k=[int(i) for i in input().split()]
a=[]
for i in range(h):
    a.append([i for i in input()])

ha=[int(i) for i in range(h)]
wa=[int(i) for i in range(w)]
cnt=0
for i in range(h):
    cnt+=a[i].count('
ans=0
for i in range(h):
    p=list(combinations(ha,i))
    for j in range(w):
        q=list(combinations(wa,j))
        for ii in p:
            for jj in q:
                da=[i[:] for i in a]
                for iii in ii:
                    for iiii in range(w):
                        if da[iii][iiii]=='
                for jjj in jj:
                    for jjjj in range(h):
                        if da[jjjj][jjj]=='
                chk=0
                for i in range(h):
                    chk+=da[i].count('
                if chk==k:
                    ans+=1
print(ans)

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

ans = 0
for row in range(1<<H):
  for col in range(1<<W):
    count=0
    
    for i in range(H):
      for j in range(W):
        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(list(input()))

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

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

n = 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 and j >> y & 1:
                    if A[x][y] == '
                        cnt += 1
        if cnt == k:
            n += 1
print(n)

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

ans = 0
for i in range(2**H):
    for j in range(2**W):
        cnt = 0
        for p in range(H):
            for q in range(W):
                if (i >> p) & 1 or (j >> q) & 1:
                    continue
                else:
                    if field[p][q] == "
                        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 row in range(1<<H):
  for col in range(1<<W):
    count=0
    for i in range(H):
      for j in range(W):
        if row&(1<<i)==0 and col&(1<<j)==0 and c[i][j]=="
          count+=1
    if count==K:
      ans+=1
print(ans)

Solution (Python):
from itertools import product
import copy
H,W,K = map(int,input().split())
S = [input().strip() for _ in range(H)]
A = [[0 for _ in range(W)] for _ in range(H)]
for i in range(H):
    for j in range(W):
        if S[i][j]=="
            A[i][j] = 1
cnt = 0
for x in product((0,1),repeat=H):
    for y in product((0,1),repeat=W):
        B = copy.deepcopy(A)
        for i in range(H):
            if x[i]==1:
                for j in range(W):
                    B[i][j]=0
        for j in range(W):
            if y[j]==1:
                for i in range(H):
                    B[i][j]=0
        tot=0
        for i in range(H):
            for j in range(W):
                tot += B[i][j]
        if tot==K:
            cnt += 1
print(cnt)

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

ans = 0
for ib in range(1<<h):
    for jb in range(1<<w):
        black = 0
        for i in range(h):
            if ib & (1<<i): continue
            for j in range(w):
                if jb & (1<<j): continue
                black += c[i][j]=="
        if black == k: ans += 1
print(ans)

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

H, W, K = mapint()

query = [list(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 not (i>>h)&1 and not (j>>w)&1:
                    if query[h][w]=='
                        cnt += 1
        if cnt==K:
            ans += 1

print(ans)

Solution (Python):
def base10toN(num, base):
    converted_string, modstring = "", ""
    currentnum = num
    if not num:
        return '0'
    while currentnum:
        mod = currentnum % base
        currentnum = currentnum // base
        converted_string = chr(48 + mod + 7*(mod > 10)) + converted_string
    return converted_string
h,w,k=map(int,input().split())
c=[]
for i in range(h):
  a=input()
  c.append(a)
ans=0
for i in range(2**h):
  iconvert=base10toN(i,2)
  ic=[]
  for _ in range(h-len(iconvert)):
    ic.append('0')
  for _ in range(len(iconvert)):
    ic.append(iconvert[_])
  for j in range(2**w):
    jconvert=base10toN(j,2)
    jc=[]
    for _ in range(w-len(jconvert)):
      jc.append('0')
    for _ in range(len(jconvert)):
      jc.append(jconvert[_])
    count=0
    for a in range(h):
      for b in range(w):
        if ic[a]=='0' and jc[b]=='0' and c[a][b]=='
          count+=1
    if count==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 i in range(2**h):
    for j in range(2**w):
        tmp = 0
        for y in range(h):
            for x in range(w):
                if i>>y&1 or j>>x&1 or c[y][x]=='.':
                    continue
                tmp += 1
        if tmp==k:
            ans += 1
print(ans)

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

ans = 0
for a in range(2**H):
    for b in range(2**W):
        cnt = 0
        for i in range(H):
            if a & (1<<i) > 0:
                continue
            for j in range(W):
                if b & (1<<j) > 0:
                    continue
                if C[i][j] == "
                    cnt += 1
        if cnt == K:
            ans += 1
print(ans)

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

for i in range(h):
  c.append(list(input()))

for i in range(2 ** h):
  for j in range(2 ** w):
    now = 0
    for x in range(h):
      for y in range(w):
        if not (i >> x) & 1 and not (j >> y) & 1 and c[x][y] == '
          now += 1
    if now == k:
      ans += 1

print(ans)

Solution (Python):
H, W, K = (int(i) for i in input().split())  

d = [[0 for i in range(W)] for j in range(H)]
for i in range(H):
  R = input()
  for j, X in enumerate(R):
    if X == '
      d[i][j] = 1

ans = 0
for maskW in range(2 ** W):
  for maskH in range(2 ** H):
    tmp = 0
    for i in range(H):  
      for j in range(W): 
        if ((maskW >> j) & 1) and ((maskH >> i) & 1):
          if d[i][j] == 1:
            tmp += 1
            
    if tmp == K:
      
      ans += 1

print(ans)

Solution (Python):
import itertools
import copy

def countKuro(table):
	return sum(sum(table, []))

height, width, kuro = map(int, input().split())

constanttable = []
for _ in range(height):
	line = []
	str = input()
	for char in str:
		if char == '.':
			line.append(0)
		else:
			line.append(1)
	constanttable.append(line)

counter = 0
heightconds = list(itertools.product(range(2), repeat = height))
widthconds = list(itertools.product(range(2), repeat = width))

for h, heightcond in enumerate(heightconds):
	table = copy.deepcopy(constanttable)
	for l, linecond in enumerate(heightcond):
		if linecond == 1:
			table[l] = [0] * width

	if countKuro(table) < kuro:
		continue

	for widthcond in widthconds:
		transposed_table = list(map(list, zip(*table)))
		for c, columncond in enumerate(widthcond):
			if columncond == 1:
				transposed_table[c] = [0] * height

		if countKuro(transposed_table) == kuro:
			counter += 1

print(counter)

Solution (Python):
def editorial():
    h, w, k = map(int, input().split())
    mat = []
    for r in range(h):
        mat.append(list(input()))
    
    ans = 0
    for rowmask in range(0, 1<<h):
        for colmask in range(0, 1<<w):
            count = 0
            for r in range(h):
                for c in range(w):
                    if (rowmask>>r)&1 == 0 and (colmask>>c)&1 == 0 and mat[r][c] == '
            if count == k: ans += 1
    print(ans)

editorial()

Solution (Python):
import numpy as np
import itertools
H,W,K=map(int,input().split())
arr=np.array([list(input()) for _ in range(H)])
ans=0
for h in range(1,H+1):
    for w in range(1,W+1):
        hl=list(itertools.combinations(list(range(H)), h))
        wl=list(itertools.combinations(list(range(W)), w))
        
        for hl_ in hl:
            for wl_ in wl:
                if sum(np.ravel(arr[np.ix_(hl_,wl_)])=='
                    ans+=1
print(ans)

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

from itertools import product
ans = 0
for mask in product(['0', '1'], repeat = h + w):
    mask = int(''.join(mask), 2)
    count = 0
    for r in range(h):
        for c in range(w):
            if ((mask >> r)&1 == 0) and ((mask >> (h + c))&1 == 0) and mat[r][c] == '
                count +=1
    if count == k: ans += 1
print(ans)

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

ans = 0
for h_bit in range(1 << H):
	for w_bit in range(1 << W):
		black = 0
		for i in range(H):
			for j in range(W):
				if h_bit & (1 << i) and w_bit & (1 << j):
					if C[i][j] == '
						black += 1
		if black == K:
			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):
h,w,k=map(int,input().split())
c=[input() for i in range(h)]
ans=0
for h_1 in range(1<<h):
  for w_1 in range(1<<w):
    black=0
    for i in range(h):
      for j in range(w):
        if (h_1>>i)&1==0 and (w_1>>j)&1==0 and c[i][j]=='
          black+=1
    if black==k:
      ans+=1
print(ans)

Solution (Python):
from itertools import *
from copy import *

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

grid = list(
  i for i in ''.join(
  	str(input()) for i in range(H)
	)
)

H_p = list(product([0,1], repeat=H))
W_p = list(product([0,1], repeat=W))



ans = 0

for h_p in H_p:
  for w_p in W_p:
    grid_ = copy(grid)
    
    for h in range(H):
      if h_p[h] == 0:
        for _w in range(W):
          grid_[_w + h*W] = '*'
    
    for w in range(W):
      if w_p[w] == 0:
        for _h in range(H):
          grid_[w + _h*W] = '*'
          
    if grid_.count('
      ans += 1
      
          
        

print(ans)