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):
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
from itertools import product
def main():
    h, w, k = map(int, input().split())
    gg = []
    for _ in range(h):
        row = [1 if c == '
        gg.extend(row)
    row_pro = tuple(product((0, 1), repeat=h))
    col_pro = tuple(product((0, 1), repeat=w))
    pat = tuple(product(row_pro, col_pro))
    r = 0
    for pate in pat:
        t0 = 0
        for i0, p0 in enumerate(pate[0]):
            for i1, p1 in enumerate(pate[1]):
                if p0 and p1:
                    t0 += gg[i0*w + i1]
        if t0 == k:
            r += 1
    print(r)

if __name__ == '__main__':
    main()

Solution (Python):
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
from itertools import product
def main():
    h, w, k = map(int, input().split())
    gg = []
    for _ in range(h):
        row = [1 if c == '
        gg.extend(row)
    row_pro = tuple(product((0, 1), repeat=h))
    col_pro = tuple(product((0, 1), repeat=w))
    pat = tuple(product(row_pro, col_pro))
    r = 0
    for pate in pat:
        t0 = 0
        for i0, p0 in enumerate(pate[0]):
            for i1, p1 in enumerate(pate[1]):
                if p0 and p1:
                    t0 += gg[i0*w + i1]
        r += t0 == k
    print(r)

if __name__ == '__main__':
    main()

Solution (Python):
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
from itertools import product
def main():
    h, w, k = map(int, input().split())
    gg = []
    for _ in range(h):
        row = [1 if c == '
        gg.extend(row)
    row_pro = tuple(product((0, 1), repeat=h))
    col_pro = tuple(product((0, 1), repeat=w))
    rows = []
    for re in row_pro:
        rows.append([i for i, b in enumerate(re) if b])
    cols = []
    for ce in col_pro:
        cols.append([i for i, b in enumerate(ce) if b])
    pat = tuple(product(rows, cols))
    r = 0
    for pate in pat:
        t0 = 0
        for p0 in pate[0]:
            for p1 in pate[1]:
                t0 += gg[p0*w + p1]
        if t0 == k:
            r += 1
    print(r)

if __name__ == '__main__':
    main()

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

Solution (Python):

import itertools
import numpy as np

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

for _ in range(H):
    c_list = input()
    c_list = [0 if c == "." else 1 for c in list(c_list)]
    c_table.append(c_list)

h_patterns = list(itertools.product([True, False], repeat=H))
w_patterns = list(itertools.product([True, False], repeat=W))
count = 0
for h_p in h_patterns:
    for w_p in w_patterns:
        w_table = np.array(c_table)

        for i, h_flag in enumerate(h_p):
            if h_flag:
                w_table[i] = 0
            for j, w_flag in enumerate(w_p):
                if w_flag:
                    w_table.T[j] = 0
        if w_table.sum() == K:
            count += 1

ans = count

print(ans)

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

s = [list(map(str,list(input()))) for i in range(h)]
ans =0
for ii in range(1<<h):
    for jj in range(1<<w):
        cnt = 0
        for i in range(h):
            for j in range(w):
                if (ii >> i & 1):
                    continue
                if (jj >> j & 1):
                    continue
                if (s[i][j] == '
                    cnt += 1

        if cnt == k:
            ans += 1
print(ans)

Solution (Python):
import copy

def count(w,h):
    Dtemp = copy.deepcopy(Data)

    for i in range(W):
        if ((1 << i) & w) != 0:
            for hh in range(H):
                Dtemp[hh][i] = 'R'
    for i in range(H):
        if ((1 << i) & h) != 0:
            for ww in range(W):
                Dtemp[i][ww] = 'R'
    c = 0
    for hh in range(H):
        for ww in range(W):
            if Dtemp[hh][ww] == '
                c += 1
    return c

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

ans = 0
for w in range(0,2**W):
    for h in range(0,2**H):
        if count(w,h) == K:
            ans += 1
print(ans)

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

print(ans)

Solution (Python):
import itertools
import copy

H,W,K = map(int,input().split())
c = [list(str(input())) for i in range(H)]
ans = 0
H_bit = list(itertools.product([0,1], repeat=H))
W_bit = list(itertools.product([0,1], repeat=W))

def mark(h,w,board):
    for i,n in enumerate(h):
        if n==1:
            board[i] = ["R"]*W
    for j,n in enumerate(w):
        if n==1:
            for k in range(H):
                board[k][j] = 'R'
    return board

for i in H_bit:
    for j in W_bit:
        check = copy.deepcopy(c)
        li = mark(i,j,check)
        if sum(a.count("
            ans += 1
print(ans)

Solution (Python):
class HandV:
    def __init__(self, H, W, K, C):
        self.H = H
        self.W = W
        self.K = K
        self.C = C
        self.H_bar = [False] * H
        self.W_bar = [False] * W
        self.result = 0

    def solve(self):
        for i in range(2 ** self.H):
            for j in range(2 ** self.W):
                H_bar = [False] * self.H
                W_bar = [False] * self.W

                for n in range(H):
                    if (i & (2 ** n)) == 2 ** n:
                        H_bar[n] = True
                for n in range(W):
                    if (j & (2 ** n)) == 2 ** n:
                        W_bar[n] = True

                self.H_bar = H_bar
                self.W_bar = W_bar

                self.check()

    def check(self):
        black_count = 0
        for i in range(self.H):
            for j in range(self.W):
                if self.H_bar[i] or self.W_bar[j]:
                    continue
                if self.C[i][j] == "
                    black_count += 1
        if black_count == self.K:
            self.result += 1
 
H, W, K = map(int, input().split())

C = [ [None] * W for i in range(H) ]
for i in range(H):
    c_line = input()
    for j, c in enumerate(c_line):
        C[i][j] = c

handv = HandV(H, W, K, C)
handv.solve()
print(handv.result)

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

Solution (Python):
import itertools

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

result = []
for n in range(len(board)+1):
    for conb in itertools.combinations(board, n):
        result.append(list(conb))

rotate_result = []
for i in range(len(result)):
    rotate_result.append([list(x) for x in zip(*result[i])])

ans = 0
result2 = []
for i in range(len(rotate_result)):
    for j in range(len(rotate_result[i])+1):
        for conb in itertools.combinations(rotate_result[i], j):
            result2.append(list(conb))
            l = list(itertools.chain.from_iterable(list(conb)))
            if l != []:
                count = 0
                for k in range(len(l)):
                    if l[k] == "
                        count += 1
                    if k == len(l)-1 and count == K:
                        ans += 1

print(ans)

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

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

for i in range(h):
  row = [1 if x == '
  graph.append(row)

graph = np.array(graph)
h_combi = []
w_combi = []

for i in range(1, h + 1):
    h_combi.extend(list(combinations(range(h), i)))
for i in range(1, w + 1):
    w_combi.extend(list(combinations(range(w), i)))

ans = 0

for hi in h_combi:
  for wi in w_combi:
    cnt = 0
    for y in hi:
      if cnt > k:
        break
      for x in wi:
        cnt += graph[y][x]
    if cnt == k:
      ans += 1

print(ans)

Solution (Python):
import itertools

def main():
    H, W, K = map(int, input().split())
    C = [list(input().rstrip()) for _ in range(H)]
    ans = 0
    for h in itertools.product([0, 1], repeat=H):
        for w in itertools.product([0, 1], repeat=W):
            black = 0
            for r in range(H):
                for c in range(W):
                    if h[r] == 0 and w[c] == 0 and C[r][c] == "
                        black += 1
            if black == K:
                ans += 1
    print(ans)


if __name__ == '__main__':
    main()

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

for mask_h in range(2 ** H):
  for mask_w in range(2 ** W):
    black = 0
    for i in range(H):
      for j in range(W):
        if ((mask_h >> i) & 1 == 0) and ((mask_w >> j) & 1 == 0) and table[i][j] == '
          black += 1

    if black == K:
      ans += 1
print(str(ans))

Solution (Python):

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

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

ans = 0

black=0

for mask_h in range(1 << H):
    for mask_w in range(1 << W):
        black=0
        for i in range(H):
            for j in range(W):
                if((mask_h >> i) & 1 == 0 ) and ((mask_w >> j) & 1 == 0 ) and G[i][j] == '
                    black+=1
        if black == K:
            ans += 1

print(ans)

Solution (Python):
h,w,k = map(int,input().split())
c_list = []
for i in range(h):
  c_list.append(list(str(input())))
h_TF_list = []
w_TF_list = []
for i in range(2**h):
  p_m_list = [False for i in range(h)]
  for j in range(h):
    if ((i >>j) & 1):
      p_m_list[j] = True
  h_TF_list.append(p_m_list)
for i in range(2**w):
  p_m_list = [False for i in range(w)]
  for j in range(w):
    if ((i >>j) & 1):
      p_m_list[j] = True
  w_TF_list.append(p_m_list)
count = 0
for h_list in h_TF_list:
  for w_list in w_TF_list:
    p = 0
    for i in range(h):
      for j in range(w):
        if c_list[i][j] == "
          p += 1
    if p == k:
      count += 1
print(count)

Solution (Python):
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
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())

from  collections import defaultdict
from collections import Counter
import bisect
def main():
    H, W, K = MI()
    C = []
    for i in range(H):
        c = S()
        C.append(c)
    A = []
    for i in range(2 ** (H + W)):
        A_bit = []
        for j in range(H + W):
            
            if ((i >> j) & 1):
                A_bit.append(j)
        A.append(A_bit)
    Ans_list = []
    for a in A:
        cnt = 0
        for i in range(H):
            if i in a:
                continue
            else:
                for j in range(H, W + H):
                    if j not in a and C[i][j - H] == '
                        cnt += 1
        Ans_list.append(cnt)
    ans = Counter(Ans_list)[K]
    print(ans)


if __name__ == "__main__":
    main()

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

ans = 0

for mask_r in range(1 << H):
    for mask_c in range(1 << W):
        black = 0
        for i in range(H):
            for j in range(W):
                if ((mask_r >> i) & 1 == 0) and ((mask_c >> j) & 1 == 0) and G[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(list(input()))

ans = 0

for i in range(1<<H):
    for j in range(1<<W):
        v = 0
        for k in range(H):
            for l in range(W):
                if c[k][l] == '
                    v += 1
        if v == K:
            ans += 1

print(ans)

Solution (Python):
import math, sys

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

map=[]
Hs=[]
Ws=[]
for _ in range(H):
    row=list(input())
    map.append(row)
    Hs.append(row.count("
for i in range(W):
    count=0
    for j in range(H):
        if map[j][i]=="
            count+=1
    Ws.append(count)

tot = sum(Hs)
ans=0
for i in range(2**H):
    for j in range(2**W):
        i_bin=(bin(i)[2:]).zfill(H)
        j_bin=(bin(j)[2:]).zfill(W)
        count=0
        for i2 in range(H):
            if i_bin[i2]=="1":
                count+=Hs[i2]
        for j2 in range(W):
            if j_bin[j2]=="1":
                count+=Ws[j2]
        for i2 in range(H):
            for j2 in range(W):
                if i_bin[i2]=="1" and j_bin[j2]=="1" and map[i2][j2]=="
                    count-=1
        if tot - count==K:
            ans+=1
            
print(ans)

Solution (Python):
H,W,K = map(int,input().split())
c = [tuple(input()) for i in range(H)]
ans = 0
for i in range(2**H):
    s = i
    b = [list(x) for x in c]
    for j in range(H):
        if s >= (2**(H-j-1)):
            s -= 2**(H-j-1)
            b[j] = ["."]*W
    b = list(zip(*b))
    for k in range(2**W):
        bt = [list(x) for x in b]
        t = k
        for l in range(W):
            if t >= (2**(W-l-1)):
                t -= 2**(W-l-1)
                bt[l] = ["."]*H
        u = sum(bt[m].count("
        if u == K:
            ans += 1
print(ans)

Solution (Python):
from sys import stdin
import itertools

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

all = 0  
row = [0] * H  
column = [0] * W  

for i in range(H):
    h_i = list(stdin.readline()[:-1])
    table.append(h_i)
    row[i] = h_i.count("
    all += row[i]

for j in range(W):
    for i in range(H):
        column[j] += table[i][j] == "




ans = 0
for x in range(H):  
    for rs in itertools.combinations(range(H), x):  
        for y in range(W):  
            for cs in itertools.combinations(range(W), y):  
                
                painted = 0  
                for i in rs:
                    painted += row[i]
                for j in cs:
                    painted += column[j]
                for i in rs:
                    for j in cs:
                        painted -= table[i][j] == "
                if all - painted == K:
                    ans += 1

print(ans)

Solution (Python):
H, W, K = map(int, input().split())
c = [input() for _ in range(H)]
r = [[0]*W for _ in range(H)]
S = 0
for i in range(2**H):
  for j in range(2**W):
    cnt = 0
    for k in range(H):
      for l in range(W):
        if (i >> k) & 1:
          if (j >> l) & 1:
            if c[k][l] == "
              cnt += 1
    if cnt == K:
      S += 1
print(S)

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

field = [input() for _ in range(H)]

ans = 0
for i in range(1 << H):
    for j in range(1 << W):
        tmp = 0
        for i2 in range(H):
            for j2 in range(W):
                if (i >> i2) & 1: continue
                if (j >> j2) & 1: continue
                if field[i2][j2] != '
                tmp += 1
        if tmp == K: ans += 1

print(ans)

Solution (Python):
def bitmake(digit):
    bit_list =list()

    for i in range(2 ** digit):
        bit = []
        for j in range(digit):  
            if ((i >> j) & 1):  
                bit.append(j)
        bit_list.append(bit)
    return bit_list
h,w,k = map(int,input().split())
grid = [""]*h
for i in range(h):
    grid[i] = list(map(str,input()))


bit_list = bitmake(h+w)

blackh = [0]*h
blackw = [0]*w
blacksum = 0
for i in range(h):
    for j in range(w):
        if(grid[i][j] == "
            blackh[i]+=1
            blackw[j]+=1
            grid[i][j] = 1
            blacksum += 1
        else:
            grid[i][j] = 0

ans = 0
for i in range(2**(h+w)):
    bit = bit_list[i]
    remove = 0
    hight = []
    width = []
    for j in range(len(bit)):
        l = bit[j]
        if(l <= h-1):
            remove += blackh[l]
            hight.append(l)
        else:
            ind = l - h
            remove += blackw[ind]
            width.append(ind)
    
    rid = 0
    for j in range(len(hight)):
        for l in range(len(width)):
            if(grid[hight[j]][width[l]] == 1):
                rid += 1
    
    if((blacksum - remove) + rid == k):
        
        ans += 1
print(ans)

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

MAP=[[0 for j in range(W)] for i in range(H)]

for i in range(H):
    for j in range(W):
        if List[i][j]=='
          MAP[i][j]=1

MAPP=[[0 for j in range(W)] for i in range(H)]
bx=[0]*W
by=[0]*H
c=[0]*2**H*2**W
for i in range(2**H*2**W):
    b=format(i,'b').zfill(H+W)
    for jx in range(W):
      bx[jx]=int(b[-W+jx])
    for jy in range(H):
      by[jy]=int(b[jy])
    for k in range(H):
      for l in range(W):
        MAPP[k][l]=MAP[k][l]*bx[l]*by[k]
    c[i]=sum(map(sum, MAPP))

print(c.count(K))

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

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

print(ans)

Solution (Python):

import sys
import math
import decimal
import itertools
from itertools import product
from functools import reduce
def input():
    return sys.stdin.readline()[:-1]
def sort_zip(a:list, b:list):
    z = zip(a, b)
    z = sorted(z)
    a, b = zip(*z)
    a = list(a)
    b = list(b)
    return a, b

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

    ans = 0
    for i in product([0, 1], repeat=H):
        for j in product([0, 1], repeat=W):
            black = 0
            for h in range(H):
                for w in range(W):
                    if i[h] == 1 and j[w] == 1 and c[h][w] == '
                        black += 1
            if black == K:
                ans += 1
    print(ans)


if __name__ == '__main__':
    main()

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

ans = 0

for i in range(2**h):
    for j in range(2**w):
        count = 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] == "
                    count += 1
        if count == k:
            ans += 1
print(ans)

Solution (Python):
h,w,k = map(int,input().split())
lay = ['']*h
ans = 0
for i in range(h):
    lay[i] = input()
for i in range(2**h):
    for j in range(2**w):
        
        kuro = 0
        for i2 in range(h):
            if (i>>i2) & 1:
                for j2 in range(w):
                    if (j>>j2) & 1:
                        if lay[i2][j2] == '
                            kuro += 1
        if kuro == k:
            ans += 1
print(ans)

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


ans = 0
for i in range(2 ** h):
    for j in range(2 ** w):
        a = len(Black)
        for b in Black:
            if ((i >> b[0]) & 1) or ((j >> b[1]) & 1):
            
                a -= 1
        if a == k:
            ans += 1
            
print(ans)

Solution (Python):
import itertools
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 - 1):
  c2 = []
  x = str(bin(i))[2:].zfill(h)
  for a in range(h):
    if x[a] == '0':
      c2.append(c[a])
    elif x[a] == '1':
      c2.append(['*'] * w)
  black = list(itertools.chain.from_iterable(c2)).count('
  for j in range(2 ** w - 1):
    black2 = black
    y = str(bin(j))[2:].zfill(w)
    for b in range(w):
      if y[b] == '1':
        for a in range(h):
          if c2[a][b] == '
            black2 -= 1
    if black2 == k:
      ans += 1
print(ans)

Solution (Python):
def main():
    h,w,k = map(int,input().split())
    g = []
    for _ in range(h):
        g.append(input())
    
    ans = 0
    for hb in range(0b1<<h):
        for wb in range(0b1<<w):
            temp = 0
            for i in range(h):
                for j in range(w):
                    if 0b1&hb>>i and 0b1&wb>>j:
                        if g[i][j] == "
                            temp+=1
            
            if temp==k:
                ans+=1
    
    print(ans)
main()

Solution (Python):
def main():
    a,b,c = map(int,input().split())
    s =[list(map(str,input()))for i in range(a)]
    cnt =0
    count=0
    for i in range(2**a):
        for j in range(2**b):
            cnt=0
            for ia in range(a):
                for ib in range(b):
                    if not i &(1<<ia) and not j&(1<<ib):
                            if s[ia][ib] =='
                                cnt+=1
            if cnt ==c:
                count+=1
    print(count)
if __name__ =='__main__':
    main()

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()
from itertools import product
def main():
    h, w, k = map(int,input().split())
    C = [input() for _ in range(h)]
    comb_list = list(product([False, True], repeat = h + w))
    ans = 0
    for comb in comb_list:
        cunt = 0
        for i in range(h):
            if not comb[i]:
                continue
            for j in range(w):
                if not comb[h+j]:
                    continue
                if C[i][j] == '
                    cunt += 1
        if cunt == k:
            ans += 1
    print(ans)



if __name__=='__main__':
    main()

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()
from itertools import product
def main():
    h, w, k = map(int,input().split())
    C = [input() for _ in range(h)]
    comb_list = list(product([False, True], repeat = h + w))
    ans = 0
    for comb in comb_list:
        cunt = 0
        for i in range(h):
            if not comb[i]:
                continue
            for j in range(w):
                if not comb[h+j]:
                    continue
                if C[i][j] == '
                    cunt += 1
        if cunt == k:
            ans += 1
    print(ans)



if __name__=='__main__':
    main()

Solution (Python):

"""
Created on Sun Sep  6 01:25:38 2020

@author: liang
"""

from itertools import combinations

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

C = [input() for _ in range(H)]
            
ans = 0
for comb_H in [list(combinations(range(H),a)) for a in range(H+1)]:
    for comb_W in [list(combinations(range(W),a)) for a in range(W+1)]:
        for tuple_H in comb_H:
            for tuple_W in comb_W:
                tmp = 0
                for i in range(H):
                    for j in range(W):
                        if i not in tuple_H and j not in tuple_W and C[i][j] == "
                            tmp += 1
                
                
                
                if tmp == K:
                    ans += 1
print(ans)

Solution (Python):
H,W,K=map(int,input().split())
Square=[0]*H
for i in range(H):
    C=input()
    Square[i]=C
ans=0
nowH=[0]*H
nowW=[0]*W
for j in range(2**H):
    for p in range(H):
        nowH[p]=j%2
        j//=2
    for k in range(2**W):
        kouho=0
        for q in range(W):
            nowW[q]=k%2
            k//=2
        for s in range(H):
            for t in range(W):
                if nowH[s]==0 and nowW[t]==0 and Square[s][t]=="
                    kouho+=1
        if kouho==K:
            ans+=1
print(ans)

Solution (Python):
from itertools import combinations

h,w,k=map(int,input().split())
G=[]
for _ in range(h):
  s=input()
  S=[]
  for i in range(w):
    S.append(s[i])
  G.append(S)
ans=0

HH=[]
for i in range(1<<h):
  H=[]
  for j in range(h):
    if (i>>j)&1:
      H.append(j)
  HH.append(H)

WW=[]
for i in range(1<<w):
  W=[]
  for j in range(w):
    if (i>>j)&1:
      W.append(j)
  WW.append(W)

for i in range(1<<h):
  for j in range(1<<w):
    cnt=0
    hl=HH[i]
    wl=WW[j]
    for m in range(h):
      for n in range(w):
        if m in hl:
          continue
        if n in wl:
          continue
        if G[m][n]=='
          cnt+=1
    if cnt==k:
      ans+=1
print(ans)

Solution (Python):
def make_bit(n):
    bit = []
    for i in range(2**n):
        bit.append(bin(i)[2::])
    i = 0
    while i < len(bit):
        while len(bit[i]) < len(bin(2**n-1)[2::]):
            bit[i] = "0" + bit[i]
        i += 1

    return bit

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

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

h_pats = make_bit(h)
w_pats = make_bit(w)
ans = 0
for h_pat in h_pats:
    for w_pat in w_pats:
        cnt = 0
        for i in range(h):
            for j in range(w):
                if h_pat[i] == "1" or w_pat[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 = [input() for x in range(h)]
cnt = 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:
            cnt += 1
print(cnt)

Solution (Python):
h, w, k = map(int, input().split(' '))
c = [input() for x in range(h)]
cnt = 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:
            cnt += 1
print(cnt)

Solution (Python):
def resolve():
    H, W, K = map(int, input().split())
    C = [input() for _ in range(H)]
    cnt = 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 h >> i & 1 or w >> j & 1:
                        continue
                    if C[i][j] == "
                        black += 1
            if black == K:
                cnt += 1

    print(cnt)
resolve()

Solution (Python):
from itertools import product

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


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 = [input() for x in range(h)]
cnt = 0
for m in range(2**(h+w)):
    cc = c.copy()
    for ij in range(h+w):
        if ((m >> ij) & 1):
            if ij in range(h):
                cc[ij] = '.'*w
            if ij in range(h,h+w):
                for t in range(h):
                    cc[t] = cc[t][:ij-h]+'.'+cc[t][ij+1-h:]
    num = sum(cc[s].count('
    if num == k:
        cnt += 1
print(cnt)

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

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

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

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

print(ans)

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

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

print(ans)