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 copy

h, w, z = map(int, input().split())
table = [['.' for j in range(w)] for i in range(h)]
ans = 0

for i in range(h):
    column = str(input())
    for j in range(w):
        table[i][j] = column[j]

tmp = h + w

for i in range(2**tmp):
    table_tmp = copy.deepcopy(table)
    count = 0

    for j in range(h):
        if (i >> j) & 1:
            for k in range(w):
                table_tmp[j][k] = 'x'

    for l in range(w):
        if (i >> (h + l)) & 1:
            for m in range(h):
                table_tmp[m][l] = 'x'

    for p in range(h):
        for q in range(w):
            if table_tmp[p][q] == '
                count += 1

    if count == z:
        ans += 1

print(ans)

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

row_black = [0]*H
column_black = [0]*W
row_position = []
column_position =[]
full = 0
res = 0
for i in range(H):
    row_position.append([])
for j in range(W):
    column_position.append([])

for i in range(H):
    s = list(input())
    for j in range(W):
        if s[j] =="
            row_black[i] +=1
            column_black[j] +=1
            row_position[i].append(j)
            column_position[j].append(i)
            full +=1

n = H+W

for i in range(2**n):
    r = copy.copy(row_black)
    c = copy.copy(column_black)
    temp = 0
    for j in range(n):
        if i & (1<<j):
            if(j<H):
                temp += r[j]
                r[j] = 0
                for k in row_position[j]:
                    c[k] -=1
            else:
                temp += c[j-H]
                c[j-H] = 0
                for k in column_position[j-H]:
                    r[k] -=1
        if full - temp < K:
            break
    if full - temp == K:
        res +=1

print(res)

Solution (Python):
"""
    こんにちは。これはクシャルです
    
    Author : thekushalghosh (クシャル)
    Team   : CodeDiggers
 
    I prefer Python language over the C++ language :p :D
        
    Visit my website : thekushalghosh.github.io
"""
import sys,math,cmath,time,itertools
start_time = time.time()



def solve():
    h,w,k = invr()
    a = []
    qq = [i + 1 for i in range(h)]
    ww = [i + 1 for i in range(w)]
    for i in range(h):
        s = insr()
        a.append(s)
    r = [0] * h
    c = [0] * w
    b = transpose(a)
    qwqw = 0
    for i in range(h):
        r[i] = a[i].count("
    for i in range(w):
        c[i] = b[i].count("
    qqww = sum(r)
    for i in range(7):
        q = list(itertools.combinations(qq,i))
        for j in range(len(q)):
            for ii in range(7):
                w = list(itertools.combinations(ww,ii))
                for jj in range(len(w)):
                    qw = 0
                    for ij in range(i):
                        qw = qw + r[q[j][ij] - 1]
                    for ij in range(ii):
                        qw = qw + c[w[jj][ij] - 1]
                    for ij in range(i):
                        for ijij in range(ii):
                            if a[q[j][ij] - 1][w[jj][ijij] - 1] == "
                                qw = qw - 1
                    if qqww - qw == k:
                        qwqw = qwqw + 1
    print(qwqw)
    


 
def main():
    global tt
    if not ONLINE_JUDGE:
        sys.stdin = open("input.txt","r")
        sys.stdout = open("output.txt","w")
    t = 1
    for tt in range(t):
        solve()
    if not ONLINE_JUDGE:
        print("Time Elapsed :",time.time() - start_time,"seconds")
        sys.stdout.close()
    

def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    return(input().strip())
def invr():
    return(map(int,input().split()))
 

def counter(a):
    q = [0] * max(a)
    for i in range(len(a)):
        q[a[i] - 1] = q[a[i] - 1] + 1
    return(q)

def counter_elements(a):
    q = dict()
    for i in range(len(a)):
        if a[i] not in q:
            q[a[i]] = 0
        q[a[i]] = q[a[i]] + 1
    return(q)

def string_counter(a):
    q = [0] * 26
    for i in range(len(a)):
        q[ord(a[i]) - 97] = q[ord(a[i]) - 97],1
    return(q)
 
def factors(n):
    q = []
    for i in range(1,int(n ** 0.5) + 1):
        if n % i == 0: q.append(i); q.append(n // i)
    return(list(sorted(list(set(q)))))
 
def prime_factors(n):
    q = []
    while n % 2 == 0: q.append(2); n = n // 2
    for i in range(3,int(n ** 0.5) + 1,2):
        while n % i == 0: q.append(i); n = n // i
    if n > 2: q.append(n)
    return(list(sorted(q)))

def transpose(a):
    n,m = len(a),len(a[0])
    b = [[0] * n for i in range(m)]
    for i in range(m): 
        for j in range(n): 
            b[i][j] = a[j][i]
    return(b)


        
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
    input = sys.stdin.readline
    
    
main()

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

import numpy as np 

C = np.array([[0 if i=="." else 1 for i in input()] for _ in range(H)])
np.where(C==".",0,1)

from itertools import combinations

counter= 0
for n in range(H):
    for conb_H in combinations(range(H), n):
        for i in range(W):
            for conb_W in combinations(range(W), i):
                D = C.copy()
                
                D[list(conb_H),:]=0
                D[:,list(conb_W)]=0
                
                if np.count_nonzero(D==1)==K:
                    counter += 1

print(counter)

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


h_tmp=[]
for i in range(h):
    h_tmp.append(i)
h_kumi = []
for i in range(h):
    h_kumi.extend(itertools.combinations(h_tmp,i))


w_tmp=[]
for i in range(w):
    w_tmp.append(i)
w_kumi = []
for i in range(w):
    w_kumi.extend(itertools.combinations(w_tmp,i))

c=[]
for i in range(h):
    c.append(list(input()))
ans = 0
for hk in h_kumi:
    for wk in w_kumi:
        counta=0
        for w_ in range(len(c[0])):
            for h_ in range(len(c)):
                
                
                if c[h_][w_]=='
                    counta+=1
        
        if counta == k:
            ans+=1
print(ans)
exit()

Solution (Python):
import copy
from itertools import combinations

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

def check(tb):
    black = 0
    for t in tb:
        for m in t:
            if m == '
                black += 1
    if black == K:
        return True
    else:
        return False

for n in range(H):
    table.append([i for i in input()])

if check(table):
    total += 1

for n in range(H+1):
    for rows in combinations(range(H), n):
        new_table = copy.deepcopy(table)
        for r in rows:
            new_table[r] = ['r']*W
        if check(new_table) and n != 0:
            total += 1
        for k in range(1, W+1):
            for cols in combinations(range(W), k):
                new_new_table = copy.deepcopy(new_table)
                for c in cols:
                    for row in new_new_table:
                        row[c] = 'r'
                if check(new_new_table):
                    total += 1
print(total)

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

Solution (Python):
H, W, K = map(int, input().split())
C = []
for i in range(H):
    c = str(input())
    C.append(c)
from itertools import combinations
from collections import Counter

def subsets(nums):
    n = len(nums)
    out = []
    for i in range(n+1):
        subout = []
        comb(nums, i, subout)
        out += subout
    return out

def comb(seq, k, out):
    _comb(seq, len(seq), k, 0, [], out)

def _comb(seq, n, k, i, elem, out):
    le = len(elem)
    if le == k:
        out.append(elem)
        return
    for i in range(i, n):
        _comb(seq, n, k, i+1, elem + [seq[i]], out)

def powset(H, W, K, C):
    X = subsets(list(range(W)))
    N = len(X)
    A = []
    for j in range(H):
        a = [0]*N
        for k in range(N):
            for ind in X[k]:
                if C[j][ind] == '
                    a[k] += 1
        A.append(a)
    Y = subsets(list(range(H)))
    M = len(Y)
    ans = [0]*(N*M)
    for k in range(N):
        for l in range(M):
            for ind in Y[l]:
                ans[l*N+k] += A[ind][k]
            
    c = Counter(ans)

    if K in c:
        return c[K]
    else:
        return 0
        

def Main(H, W, K, C):
    return powset(H, W, K, C)
                    
out = Main(H, W, K, C)
print(out)

Solution (Python):
import itertools
import numpy as np

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

matrix = np.empty((h,w), dtype = 'str')

for i in range(h):
    matrix[i] = list(input())

if np.count_nonzero(matrix=='
    cnt = 1
else:
    cnt = 0

for n_row in range(h+1):
    for n_col in range(w+1):
        for r in itertools.combinations(range(h), n_row):
            for c in itertools.combinations(range(w), n_col):
                if not r and not c:
                    continue
                chg_matrix = matrix.copy()
                chg_matrix[:,c] = '&'
                chg_matrix[r,:] = '&'
                if np.count_nonzero(chg_matrix=='
                    cnt += 1

print(cnt)

Solution (Python):
import copy
h,w,k=map(int,input().split())
c=[[] for i in range(h)]
for i in range(h):
  S=input()
  for j in range(w):
    c[i].append(S[j])
b1=2**h
b2=2**w
cnt=0
tori=0
for i in range(b1):
  s=(str(bin(i))[2:]).zfill(h)
  for j in range(b2):
    d=[]
    d=copy.deepcopy(c)
    cnt=0
    t=(str(bin(j))[2:]).zfill(w)
    for l in range(h):
      if s[l]=='1':
        for unchi in range(w):
          d[l][unchi]='r'
    for m in range(w):
      if t[m]=='1':
        for unchi in range(h):
          d[unchi][m]='r'
    for ch in range(h):
      cnt+=d[ch].count('
    if cnt==k:
      tori+=1
print(tori)

Solution (Python):
import itertools


def count_black(grid):
    num_blacks = 0

    for row in grid:
        for c in row:
            if c == '
                num_blacks += 1

    return num_blacks


def deep_copy_grid(grid):
    copy = []

    for row in grid:
        temp = []

        for col in row:
            temp.append(col)

        copy.append(temp)

    return copy


def paint_red(grid, select_rows, select_cols):
    for select_row in select_rows:
        for j in range(len(grid[select_row])):
            grid[select_row][j] = 'r'

    for select_col in select_cols:
        for i in range(len(grid)):
            grid[i][select_col] = 'r'

    return


height, width, k = list(map(int, input().split()))

grid = []

for _ in range(height):
    row = list(input())
    grid.append(row)

num_choices = 0

for i in range(height + 1):
    row_combs = itertools.combinations(range(height), i)

    for row_comb in row_combs:
        for j in range(width + 1):
            col_combs = itertools.combinations(range(width), j)

            for col_comb in col_combs:
                copy = deep_copy_grid(grid)

                paint_red(copy, row_comb, col_comb)

                temp_num_blacks = count_black(copy)

                if temp_num_blacks == k:
                    num_choices += 1

print(num_choices)

Solution (Python):

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

def get_unique_list(seq):
    seen = []
    return [x for x in seq if x not in seen and not seen.append(x)]
ans = 0
count = 0
for i in range(h):
    count += s[i].count("

for i in range(2 ** (h+w)):
    bag = []
    for j in range(h+w):  
        if ((i >> j) & 1): 
            bag.append(j)
    d_count = []
    for p in bag:
        
        if p < h:
            for r in range(w):
                if s[p][r] == "
                    d_count.append([p,r])
        else:
            for c in range(h):
                if s[c][p-h] == "
                    d_count.append([c,p-h])
    if count - len(get_unique_list(d_count)) == k:
        ans += 1
print(ans)

Solution (Python):
import sys
import numpy as np
import math
import collections
import copy
from collections import deque 
from functools import reduce
from itertools import product


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

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

cnt = 0
for hi in product((0, 1), repeat=h):
    for wi in product((0, 1), repeat=w):
        cc = copy.deepcopy(c)
        for hc, hii in enumerate(hi):
            if hii == 1:
                for i in range(w):
                    cc[hc][i] = '.'
        for wc, wii in enumerate(wi):
            if wii == 1:
                for j in range(h):
                    cc[j][wc] = '.'
        ss = ""
        for li in cc:
            ss += "".join(li)
        ccc = collections.Counter(ss)



        if ccc["
            cnt += 1
print(cnt)

Solution (Python):
import numpy as np

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

C = []

for h in range(H):
    C.append(list(input()))
    for w in range(W):
        if C[h][w] == "
            C[h][w] = 1
        else:
            C[h][w] = 0
arr = np.array(C)

cC = 0

for i in range(2 ** (H+W)):
    t = arr.copy()
    
    
    red = []
    for j in range(H+W):
        if j < H:
            if ((i >> j) & 1):
                t[j] = 2
        else:
            if ((i >> j) & 1):
                t[:, (j-H)] = 2
    if t[t == 1].sum() == K:
        cC += 1

print(cC)

Solution (Python):
import copy
H,W,K = map(int,input().split())
initial = []
for i in range(H):
    initial.append(list(input()))
def count_black(c):
    counter = 0
    for i in range(len(c)):
        for j in range(len(c[0])):
            if c[i][j] == '
                counter += 1
    return counter
n = H+W
pattern = []
for i in range(2 ** n):
    tmp = [False] * n
    for j in range(n):
        if i >> j & 1:
            tmp[j] = True
    pattern.append(tmp)
counter = 0
for i in range(len(pattern)):
    c = copy.deepcopy(initial)
    for h in range(H):
        if pattern[i][h]:
            c[h] = ['o' for _ in range(W)]
        for w in range(H,H+W):
            if pattern[i][w]:
                for tmp in range(H):
                    c[tmp][w-H] = 'o'
    if count_black(c) == K:
        counter += 1
print(counter)

Solution (Python):

import collections
import copy

def count_black(row):
    ret = 0
    for r in row:
        ret += collections.Counter(list(r))['
    return ret

def flip(row, w, h):
    if w>-1:
        for i in range(len(row)):
            row[i][w] = 'R'
    if h>-1:
        row[h]=['R' for _ in range(len(row[h]))]

    return row



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

    ans = 0
    for i in range(2**(H+W)):
        rr = copy.deepcopy(row)
        for j in range(H+W):
            if ((i >> j) & 1):
                if j<H: 
                    rr = flip(rr, -1, j)
                else:
                    rr = flip(rr, j-H, -1)
        if count_black(rr) == K:
            ans += 1

    print(ans)



if __name__ == '__main__':
    main()

Solution (Python):
import numpy as np
import itertools

H,W,K = map(int,input().split())
arr = []
for i in range(H):
    arr.append(list(input()))
narr = np.array(arr)
counter = 0


r = list(itertools.product([True, False], repeat = H))
c = list(itertools.product([True, False], repeat = W))
for row in r:
    for col in c:
        narrc = np.copy(narr)
        narrc[row, :] = '0'
        narrc[:, col] = '0'
        if np.count_nonzero(narrc == '
            counter += 1
print(counter)

Solution (Python):
import sys
import math
import itertools
import bisect
from copy import copy,deepcopy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(map(int,input().split()))
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

H,W,K = I()
maze = [list(s()) for _ in range(H)]
cnty = 0
for i in range(H):
    for j in range(W):
        if maze[i][j] == '
            cnty += 1
h = [i for i in range(H)]
w = [i for i in range(W)]
ans = 0
for i in range(H):
    for j in range(W):
        mazey = copy(maze)
        hc = list(itertools.combinations(h,i))
        wc = list(itertools.combinations(w,j))
        for k in range(len(hc)):
            for l in range(len(wc)):
                mazey = copy(maze)
                cnt = 0
                if hc[k]:
                    for m in hc[k]:
                        cnt += mazey[m].count('
                        mazey[m] = ['.']*W
                if wc[l]:
                    for m in wc[l]:
                        for n in range(H):
                            if mazey[n][m] == '
                                cnt += 1
                if cnty - cnt == K:
                    ans += 1
print(ans)

Solution (Python):
import itertools

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

def c2i(c):
    if c == '.':
        return 0
    elif c == '
        return 1

m = []
lines = []
rows = [0] * W
total = 0

for idx in range(H):
    c = input()
    m.append([*c])

    black_num = c.count('
    total += black_num
    lines.append(black_num)
    rows = [row + c2i(c[i]) for i, row in enumerate(rows)]

patterns = []
count = 0

for yy in itertools.product([0, 1], repeat=(H)):
    for xx in itertools.product([0, 1], repeat=(W)):
        sub = 0
        r = 0
        l = 0
        for idx_l, line in enumerate(yy):
            if line == 1:
                l += lines[idx_l]

        for idx_r, row in enumerate(xx):
            if row == 1:
                r += rows[idx_r]

        for idx_l, line in enumerate(yy):
            for idx_r, row in enumerate(xx):
                if not line or not row:
                    continue
                if m[idx_l][idx_r] == '
                    sub += 1
        black_num = total - (l + r) + sub
        if black_num == K:
            patterns.append([xx, yy])
            count += 1
print(count)

Solution (Python):
import itertools
h,w,k = map(int,input().split())
s = ["" for _ in range(h)]
for i in range(h):
  si = str(input())
  s[i] = si
lh = [i for i in range(h)]
lw = [j for j in range(w)]
sh = [0 for _ in range(h)]
sw = [0 for _ in range(w)]
for i in range(h):
  for j in range(w):
    if s[i][j] == "
      sh[i] += 1
      sw[j] += 1  
g = sum(sh) - k
c = 0
for i in range(h+1):
  for vh in itertools.combinations(lh,i):
    for j in range(w+1):
      for vw in itertools.combinations(lw,j):
        t = 0
        for hx in vh:
          t += sh[hx] 
        for hy in vw:
          t += sw[hy]
        for hx in vh:
          for hy in vw:
            if s[hx][hy] == "
              t -= 1
        if t == g:
          c += 1
print(c)

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

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

def sw(temp,n,b):
    if n == w:
        count = 0
        for c in temp:
            count += c.count("
        if count == k:
            return 1
        else:
            return 0
    else:
        temp1 = copy.deepcopy(temp)
        temp2 = copy.deepcopy(temp)
        if b == True:
            for i in range(h):
                temp1[i][n] = "2"
                temp2[i][n] = "2"

        return(sw(temp1,n+1,True)+sw(temp2,n+1,False))

def sh(temp,n,b):
    if n == h:
        temp1 = copy.deepcopy(temp)
        temp2 = copy.deepcopy(temp)
        return(sw(temp1,0,True)+sw(temp2,0,False))
    else:
        temp1 = copy.deepcopy(temp)
        temp2 = copy.deepcopy(temp)
        if b == True:
            temp1[n] = ["2"]*w
            temp2[n] = ["2"]*w
        return(sh(temp1,n+1,True)+sh(temp2,n+1,False))

print(int((sh(C,0,True) + sh(C,0,False))/4))

Solution (Python):
import copy

def blackCount(x):
  cc=0
  pp=len(x)
  for l in range(pp):
    cc+=x[l].count('
  return cc

def rowChange(x,row):
  ss=list(x[row])
  for l in range(w):
    ss[l]='.'
  x[row]="".join(ss)
  
def colChange(x,col):
  for l in range(h):
    ss=list(x[l])
    ss[col]='.'
    x[l]="".join(ss)

h,w,k=map(int,input().split())
c=[]
count=0
for i in range(h):
  c.append(input())
  
for i in range(2**h):
  for j in range(2**w):
    c2=copy.deepcopy(c)
    for a in range(h):
      if (i>>a)%2==1:
        rowChange(c2,a)
        
    for b in range(w):
      if (j>>b)%2==1:
        colChange(c2,b)
    
    if blackCount(c2)==k:
      count+=1
      
print(count)

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

h,w, k = [int(n) for n in input().split()]

temp2 = []
for i in range(h):
  temp= []
  for s in input():
    if s == '.':
      temp.append(0)
    else:
      temp.append(1)
  temp2.append(temp)
matrix = np.array(temp2)

comb_h = []
for i in range(h+1):
  for c in combinations(list(range(h)), i):
    comb_h.append(c)
comb_w = []
for i in range(w+1):
  for c in combinations(list(range(w)), i):
    comb_w.append(c)

cnt = 0
for h_seq in comb_h:
  for w_seq in comb_w:
    total = 0
    for h_item in h_seq:
      total += np.sum(matrix[h_item, w_seq])
    if total == k:
      cnt += 1
print(cnt)

Solution (Python):
h,w,k = list(map(int,input().split()))
mr_list = [input() for i in range(h)]
output = 0
import copy
for i in range(2**(h+w)):
  row = []
  m_list = copy.copy(mr_list)
  for j in range(h+w):
    if ((i >> j) & 1):
      row.append(j)
  for r in row:
    if r < h:
      m_list[r] = "r"*w
    else:
      for i,m in enumerate(m_list):
        m_list[i] = m[:r-h] + 'r' + m[r-h+1:]
  out =0
  for m in m_list:
    out += m.count("
  if out == k:
    output += 1
print(output)

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

ans = 0

for i in range(1 << H):
    D = copy.deepcopy(C)
    for ii in range(H):
        if ((i >> ii) & 1):
            
            for l in range(W):
                D[ii][l] = "."
    for j in range(1 << W):
        E = copy.deepcopy(D)
        for jj in range(W):
            if ((j >> jj) & 1):
                
                for k in range(H):
                    E[k][jj] = "."
        if K == sum(E,[]).count("
            ans += 1
print(ans)

Solution (Python):
from copy import deepcopy
from itertools import product

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

s = 0

def num_to_bit_boolean(n):
    return [ bool(n & b) for b in [ 1, 2, 4, 8, 16, 32 ] ]

def del_row_col(rows_num, cols_num, board):
    global s

    for bit, row in zip(num_to_bit_boolean(rows_num), range(h)):
        if bit:
            board[row] = [ '.' ] * w

    for row in board:
        for bit, col in zip(num_to_bit_boolean(cols_num), range(w)):
            if bit:
                row[col] = '.'

    if count_black(board) == k:
        
        

        s += 1

    return board

def count_black(board):
    return sum( row.count('

for row, col in product(range(2 ** h), range(2 ** w)):
    del_row_col(row, col, deepcopy(board))

print(s)

Solution (Python):
import numpy as np
import itertools

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

bw_map = []
row_list = []
for _ in range(H):
    tmp = list(input())
    bw_map.append(tmp)

bw_map = np.array(bw_map)
score = np.sum(bw_map=="


result = 0
"""
if score==K:
    hs = []
    for h in range(H):
        tmph = np.sum(bw_map[h, :]==".")
        if tmph == W:
            hs.append(h)
    ws = []
    for w in range(W):
        tmpw = np.sum(bw_map[w, :]==".")
        if tmpw == H:
            ws.append(w)
    print(1)
"""
if score==K:
    result+=1
if score<K:
    print(0)
else:
    score = 100000
    for h in range(H):
        for w in range(W):
            if h==0 and w==0:
                continue
            h_args = list(itertools.combinations(list(range(H)), h))
            w_args = list(itertools.combinations(list(range(W)), w))
            for hs in h_args:
                for ws in w_args:
                    tmphs=hs
                    tmpws=ws
                    hs = list(hs)
                    ws = list(ws)
                    hs = list(set(list(range(H)))-set(hs))
                    ws = list(set(list(range(W)))-set(ws))
                    if len(hs)==0:
                        score = np.sum(bw_map[:, ws]=="
                    elif len(ws)==0:
                        score = np.sum(bw_map[hs, :]=="
                    else:
                        tmp = bw_map[hs]
                        tmp = tmp[:, ws]
                        score = np.sum(tmp=="

                    if score == K:
                        result+=1
    print(result)

Solution (Python):
def resolve():
    from copy import deepcopy
    h, w, K = list(map(int, input().split()))

    white = 0
    black = 1
    red = 0
    matrix = []
    for i in range(h):
        chars = input()
        line = []
        for char in chars:
            if char == '.':
                line.append(white)
            elif char == '
                line.append(black)
        matrix.append(line)

    count = 0
    for i in range(1 << (h + w)):
        m = deepcopy(matrix)
        for j in range(h):
            if (i >> j) & 1 == 1:
                m[j] = [red for _ in range(w)]

        for j in range(w):
            if (i >> (j + h)) & 1 == 1:
                for k in range(h):
                    m[k][j] = red

        black_count = 0
        for j in range(h):
            for k in range(w):
                if m[j][k] == black:
                    black_count += 1

        if black_count == K:
            count += 1

    print(count)


if 'unittest' not in globals():
    resolve()

Solution (Python):
from math import gcd, sqrt, cos, radians, pi, floor, ceil
from collections import defaultdict as d
from itertools import combinations as c
from string import ascii_lowercase as a

h, w, k = map(int, input().split())
t = []
total = 0
for i in range(h):
	t+=[input()]
	total += t[-1].count('
count = 0
for i in range(h):
	for j in range(w):
		for u in c(list(range(h)), i):
			for v in c(list(range(w)), j):
				cnt = 0
				for x in u:
					cnt += t[x].count('
				for x in v:
					for y in range(h):
						if t[y][x] == '
				if total - cnt == k:
					count += 1
print(count)

Solution (Python):
import sys
import bisect
from functools import lru_cache
from collections import defaultdict
import itertools
inf = float('inf')
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**6)

def read():
  return int(readline())
def reads():
  return map(int, readline().split())
h,w,k1=reads()
c=[]
for i in range(h):
  c.append(input())
res=0
for i in range(2**h):
  for j in range(2**w):
    selrows,selcolumn=[],[]
    k=0
    s=i
    while(True):  
      if s==0:
        break
      if s%2==1:
        selrows.append(k)  
      s//=2
      k+=1
    k=0
    t=j
    while(True):  
      if t==0:
        break
      if t%2==1:
        selcolumn.append(k)     
      t//=2
      k+=1
    blacknumber=0
    for k in range(h):
      for l in range(w):
        if c[k][l]==".":
          continue
        elif k in selrows or l in selcolumn:
          continue
        else:
          blacknumber+=1

    if blacknumber==k1:
      res+=1
print(res)

Solution (Python):

import itertools as it
import numpy as np


def main():
    f = lambda x: 0 if x=='.' else 1
    H, W, K = list(map(int, input().split()))

    mat = np.zeros((H, W))
    for i in range(H):
        row = [c for c  in input()]
        for j in range(W):
            mat[i,j] = f(row[j])

    
    
    H_res = [0] * (H*W +1)
    W_res = [0] * (H*W+1)

    combs = list(range(H+W))
    count= 0
    for L in range(0, H+W+1):
        for subset in it.combinations(combs, L):
            subset = list(subset)
            row_idxs = [x for x in subset if x < H]
            col_idxs = [x-H for x in subset if x >= H]
            
            
            
            
            
            new_mat = mat[row_idxs][: , col_idxs]
            s = np.sum(new_mat)  
            if s == K:
                count += 1
    
    
    
    
    
    
            
    

    
    
    
    
    

    
    

    
    
    
    
    

    print(count)
    pass

if __name__ == '__main__':
    main()

Solution (Python):
def countSharp(s, h):
    tmp = s
    for i in range(len(s)):
        if ((h >> i) & 1) == 0:
            tmp = tmp[:i] + '.' + tmp[min(i+1, len(s)):]
    return len(tmp.replace('.', ''))


def countRes(AR, w, h):
    res = 0
    for i, s in enumerate(AR):
        if ((w >> i) & 1) == 0:
            continue
        res += countSharp(s, h)
    return res

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

for i in range(2**H):
    for j in range(2**W):
        if(countRes(C, i, j) == K):
            res += 1
print(res)

Solution (Python):
import numpy as np
H, W, K = map(int, input().split())
zu = np.zeros((H, W), dtype=int)

for h in range(H):
    zu[h, :] = (np.array(list(input())) == '

MAXX = 2**(H+W)
ans = 0
if np.sum(zu) == K:
    ans += 1

for c in range(1, MAXX):
    zu1 = np.copy(zu)
    for h in range(H):
        if (c & (1<<h)) > 0:
            zu1[h] = 0
    for w in range(W):
        if (c & (1<<(H+w))) > 0:
            zu1[:, w] = 0
    if np.sum(zu1) == K:
        ans += 1

print(ans)

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

kazu = 0

for i in range(2 ** w):
    for s in range(2 ** h):
        count = 0
        for j in range(w):
            if ((i >> j) & 1):
                for t in range(h):
                    if ((s >> t) & 1):
                        if c[t][j] == '
                            count += 1
            
        if count == k:
            kazu += 1

print(kazu)