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 itertools
import copy

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

ans = 0
for htuple in itertools.product([0, 1], repeat=h):
    temp = copy.deepcopy(lst)
    for i in range(h):
        if htuple[i] == 1:
            temp[i] = ['r'] * w
    for wtuple in itertools.product([0, 1], repeat=w):
        wtemp = copy.deepcopy(temp)
        for j in range(w):
            if wtuple[j] == 1:
                for l in range(h):
                    wtemp[l][j] = 'r'
        current = 0
        for i in range(h):
            for j in range(w):
                if wtemp[i][j] == '
                    current += 1
        if current == k:
            ans += 1
print(ans)

Solution (Python):
H, W, K = map(int, input().split())
row_sum = [0] * H
column_sum = [0] * W
A = []
for i in range(H):
  a = input()
  b = [0] * W
  for j in range(W):
    if a[j] == '
      row_sum[i] += 1
      column_sum[j] += 1
      b[j] = 1
  A.append(b)
A_sum = sum(column_sum)
ans = 0
for h in range(2**H):
  h_bit = format(h, 'b').zfill(H)
  row = []
  row_judge = 0
  for h_num, bit in enumerate(h_bit, 0):
    if bit == '1':
      row.append(h_num)
      row_judge += row_sum[h_num]
  for w in range(2**W):
    w_bit = format(w, 'b').zfill(W)
    column = []
    column_judge = 0
    for w_num, bit2 in enumerate(w_bit, 0):
      if bit2 == '1':
        column.append(w_num)
        column_judge += column_sum[w_num]
    matrix_judge = 0
    if row and column:
      for i in row:
        for j in column:
          matrix_judge -= A[i][j]
    if A_sum - (row_judge + column_judge + matrix_judge) == K:
      ans += 1
    
    
print(ans)

Solution (Python):
import itertools as itr
import numpy as np

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




pattern_count = 0

for i in range(h):
    for j in range(w):
        r_combi = itr.combinations(range(h), i)
        for r in r_combi:
            c_combi = itr.combinations(range(w), j)
            for c in c_combi:
                row_deleted = np.delete(field, r, axis=0)
                deleted = np.delete(row_deleted, c, axis=1)
                count = np.sum(np.char.count(deleted, '
                
                if count == k:
                    pattern_count += 1

print(pattern_count)

Solution (Python):
import copy
H, W, K = list(map(int, input().split()))
matrix = [[0 for j in range(W)] for i in range(H)]
matrix2 = [[0 for j in range(W)] for i in range(H)]
for i in range(H):
    c_i = input()
    for j in range(W):
        if c_i[j] == '
            matrix[i][j] = 1
            matrix2[i][j] = 1
COUNT = 0
for i in range(2**(H+W)):
    x_i = []
    y_i = []
    count = 0
    for j in range(H+W):
        if ((i >> j) & 1):
            if j < H:
                x_i.append(j)
            else:
                y_i.append(j-H)
    for k in x_i:
        for l in range(W):
            matrix[k][l] = -1
    for k in range(H):
        for l in y_i:
            matrix[k][l] = -1
    for k in range(H):
        for l in range(W):
            if matrix[k][l] == 1:
                count += 1
    if count == K:
        COUNT += 1
    matrix = copy.deepcopy(matrix2)
print(COUNT)

Solution (Python):
from itertools import product

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

for i in range(h):
    tmp = list(str(input()))
    c[i] = tmp

nh = 1 << h
nw = 1 << w

ans = 0

import copy
for i in range(nh):
    for j in range(nw):
        arr = copy.deepcopy(c)
        for x in range(h):
            if (i >> x) & 1:
                for t in range(w):
                    arr[x][t] = 'r'
        for y in range(w):
            if (j >> y) & 1:
                for t in range(h):
                    arr[t][y] = 'r'
        count = 0
        for x in range(h):
            for y in range(w):
                if arr[x][y] == '
                    count += 1
        if count == k:
            ans += 1
print(ans)

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

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

print(ans)

Solution (Python):

from itertools import product
import numpy as np

def main():
	h,w,k = map(int, input().split())
	c = np.array([[ 1 if j=='
	ans = 0
	for row in product(range(2), repeat=h):
		for col in product(range(2), repeat=w):
			
			e = np.array([[i*j for j in col] for i in row])
			if np.sum(c*e) == k:
				ans += 1
	print(ans)	

if __name__ == '__main__':
	main()

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

c = [input() for i in range(h)]
count = 0

for a in range(2**(h)):
    for x in range(2**w):
        black = 0
        for b in range(h):
            for y in range(w):
                if ((a >> b) & 1) and (x >> y & 1) and c[b][y] == '
                    black += 1
        if black == k:
            count += 1

print(count)

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

calc_table = [[0 for i in range(w)] for j in range(h)]
calc_total = 0
for i in range(h):
    line = [1 if x == '
    for j in range(w):
        calc_table[i][j] = line[j]
        calc_total += line[j]

num = 0
for hb in range(2**h):
    for wb in range(2**w):
        total = calc_total

        for i in range(h):
            selected_h = True if ((hb >> i) & 1) == 1 else False
            for j in range(w):
                selected_w = True if ((wb >> j) & 1) == 1 else False
                if selected_h or selected_w:
                    total -= calc_table[i][j]

        if total == k:
            num += 1

print(num)

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):
        c = 0
        for ci in range(H):
            for cj in range(W):
                if ((i >> ci) & 1) and ((j >> cj) & 1) and C[ci][cj] == '
                    c += 1
        if c == K:
            ans += 1

print(ans)

Solution (Python):
import sys
import numpy as np

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
mo = 10**9+7

def main():
    H,W,K=MI()
    pixels = np.array([[0 for w in range(W)] for h in range(H)])
    tob = 0
    for h in range(H):
        C = IS()
        for w,c in enumerate(C):
            if c=='
                pixels[h][w] = 1
                tob+=1
    N=H+W
    M=2
    ans = 0
    r = np.array([0]*N)
    for i in range(M**N):
        ii = i
        for j in range(N):
            r[j] = ii % M;
            ii //= M
        if K==np.sum(pixels[np.ix_(r[0:H]>=1, r[H:]>=1)]):
            ans+=1
    print(ans)
            
if __name__ == '__main__':
    main()

Solution (Python):
H,W,K = map(int,input().split())
c,ch,cw,a=[],[],[0]*6,0

for _ in range(H):
	t = input()
	c.append(t)
	ch.append(sum([x=='
for j in range(W):
	for i in range(H):
		if c[i][j] == '
			cw[j] += 1

for i in range(1<<H):
	for j in range(1<<W):
		s,si,sj=0,[],[]
		for d in range(H):
			if i & 1<<d:
				si.append(d)
				s += ch[d]
		for d in range(W):
			if j & 1<<d:
				sj.append(d)
				s += cw[d]
		for p in si:
			for q in sj:
				if c[p][q] == '
					s -= 1
		if sum(ch)-s == K:
			a += 1
print(a)

Solution (Python):
from itertools import product
import copy
h,w,k=map(int,input().split())
c = [[0]*w for i in range(h)]
for i in range(h):
    line = list(input())
    for j in range(w):
        if line[j]=='
            c[i][j]=1

ans = 0
for bit in product(range(2), repeat=h+w):
    cc = copy.deepcopy(c)
    
    for i in range(h):
        if bit[i]==1:
            for j in range(w):
                cc[i][j] = 0
    for j in range(w):
        if bit[j+h]==1:
            for i in range(h):
                cc[i][j] = 0
    res = 0
    for i in range(h):
        res += sum(cc[i])
    
    if res==k:
        ans+=1
        
print(ans)

Solution (Python):
import math
def facts(n):
    ans = []
    for  i in range(1, int(math.sqrt(n)+1)):
        if(n%i==0):
            ans.append(i)
            ans.append(n//i)
    ans = sorted(list(dict.fromkeys(ans)))
    if(ans[-1]==n):
        ans = ans[:-1]
    return ans
h,w,k = map(int, input().split())
grid =[]
ans = 0
for i in range(h):
    grid.append(list(input()))
for mask1 in range(2**(h)):
    for mask2 in range(2**w):
        count = 0
        for r in range(h):
            for c in range(w):
                if(grid[r][c]!= '
                    continue
                elif(((mask1>>r)&1) or((mask2>>c)&1)):
                    continue
                else:
                    count+=1
        if(count==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())
ans = 0
for maskR in range(1 << H):
    for maskC in range(1 << W):
        black = 0
        for i in range(H):
            for j in range(W):
                if ((maskR >> i) & 1) == 0 and ((maskC >> j) & 1) == 0 and c[i][j] == '
                        black = black + 1
        if black == K:
            ans = ans + 1
print(ans)

Solution (Python):
import itertools
h,w,n=map(int, input().split())
l=[str(input())for _ in range(h)]
ans = 0

for i in list(itertools.product([0,1], repeat= h)):
    for j in list(itertools.product([0,1], repeat= w)):
        b = 0
        for k in range(h):
            for m in range(w):
                if i[k] == 0 and j[m] == 0 and l[k][m] == '
                    b +=1
        if b == n:
            ans += 1
print(ans)

Solution (Python):
import numpy as np

H, W, K = map(int, input().split())
cells = np.zeros((H, W), dtype=np.int)

for i in range(H):
    tmp = input()
    for j in range(W):
        if tmp[j] == '
            cells[i][j] = 1

ans = 0

for mask_h in range(2**H):
    for mask_w in range(2**W):
        counter = 0
        for h in range(H):
            for w in range(W):
                if ((mask_h >> h) & 1) == 0 and ((mask_w >> w) & 1) == 0 and cells[h][w] == 1:
                    counter += 1

        if counter == K:
            ans += 1

print(ans)

Solution (Python):
H,W,K = map(int, input().split())
L=[]
for i in range(H):
    L.append(list(input()))
HH = 2**H
WW = 2**W

C=0

for i in range(HH):
    for i2 in range(WW):
        c=0
        hh = str(format(i,"b").zfill(H))
        ww = str(format(i2,"b").zfill(W))
        for h in range(H):
            for w in range(W):
                if hh[h]=="0" and ww[w]=="0":
                    if L[h][w]=="
                        c+=1
        if c==K:
            C+=1
print(C)

Solution (Python):
H, W, K = map(int, input().split())
cw = []
black_all = 0
for _ in range(H):
  s = input()
  cw.append(s)
  black_all += s.count("

ans = 0
for i in range(2 ** H):
  for j in range(2 ** W):
    bl = black_all
    for h in range(H):
      for w in range(W):
        if cw[h][w] == "
          bl -= 1
    if bl == K:
      ans += 1
print(ans)

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

import itertools
HH = list(range(H))
WW = list(range(W))
ans = 0
totalblack = sum([x.count('

HHH = [list(itertools.combinations(HH, i)) for i in range(H+1)]
WWW = [list(itertools.combinations(WW, i)) for i in range(W+1)]

for hh in HHH:
    for ww in WWW:
        for h in hh:
            count = 0
            for i in h:
                count += c[i].count('
            
            for w in ww:
                ccount = 0
                for j in w:
                    for i, l in enumerate(c):
                        if i in h:
                            continue
                        ccount += l[j] == '
                ans += totalblack - (count+ccount) == K

print(ans)

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

ans = 0

for row_bin in range(2**h):
  for col_bin in range(2**w):
    cnt = 0
    for i in range(h):
      for j in range(w):
        if c[i][j] == '
          cnt += 1
    if cnt == k:
      ans += 1

print(ans)

Solution (Python):
import itertools
import numpy as np
h, w, k = list(map(int, input().split()))
a = np.zeros((h, w))
c = 0
for i in range(h):
    s = input()
    for j in range(w):
        if s[j] ==  '
            a[i, j] = 1
for i in itertools.product([0, 1], repeat = h):
    for j in itertools.product([0, 1], repeat = w):
        if sum(sum((a.T * i).T * j)) == k:
            c += 1
print(c)

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

ans = 0
for mask_h in range(2**h):
    for mask_w in range(2**w):
        ctr = 0
        for i in range(h):
            for j in range(w):
                if((mask_h >> i) &1) ==0 and ((mask_w >> j) &1) ==0 \
                    and c[i][j]=='
                    ctr +=1
        if ctr == k:
            ans+=1

print(ans)

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


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

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

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

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

Solution (Python):
H, W, K = map(int, input().split())
li_color = []
b_max = 0
for i in range(H):
    li_color.append(input())
    b_max = b_max + li_color[-1].count("

proc_cnt = 0

for w_bin in range(2**W):
    for h_bin in range(2**H):
        b_cnt = 0
        for w in range(W):
            for h in range(H):
                if (h_bin & (1 << h)) or (w_bin & (1 << w)) :
                    if "
        if b_max - b_cnt == K:
            proc_cnt = proc_cnt + 1

print(proc_cnt)

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

count = 0
for row in range(2 ** h):
    for col in range(2 ** w):
        s = 0
        for i in range(h):
            for j in range(w):
                if (row >> i) & 1 == 0 and (col >> j) & 1 == 0 and c[i][j] == "
                    s += 1
        if s == k:
            count += 1
print(count)

Solution (Python):
from itertools import product

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

ans = 0

for rowb in product(range(2),repeat = H):
    for colb in product(range(2),repeat = W):
        count = 0
        
        for r in range(H):
            for w in range(W):
                
                if c[r][w] == '
                    count += 1
                    
        if count == K:
            ans += 1
            
print(ans)

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


def main():
    H,W,K = map(int,input().split())
    grid = []
    for _ in range(H):
        row = input().strip()
        grid.append(row)
    
    ans = 0
    
    for maskH in range((1<<H)-1):
        for maskW in range((1<<W)-1):
            blacks = 0
            for i in range(H):
                for j in range(W):
                    if (maskH >> i & 1)==0 and (maskW >> j & 1)==0 and grid[i][j] == '
                        blacks += 1
            if blacks == K:
                ans += 1
    print(ans)
    
    
main()

Solution (Python):
import itertools

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

data = [0, 1]
all_lists = list(itertools.product(data, repeat=h+w))

count = 0
for each in all_lists:
  
  x_list = []
  y_list = []
  number = 0
  for i in range(h + w):
    if each[i] == 1:
      if i < h:
        x_list.append(i)
      elif i < h + w:
        y_list.append(i - h)
  
  
  for i in range(h):
    if i not in x_list:
      lst_h = lst[i]
      for j in range(w):
        if j not in y_list:
          lst_hw = lst_h[j]
          if lst_hw == '
            number += 1
  
  if number == k:
    count += 1
print(count)

Solution (Python):
import numpy as np

H, W, K = [int(i) for i in input().split()]
A = np.zeros([H, W], dtype=bool)
for i in range(H):
    A[i] = np.array([False if i=="." else True for i in input()])

T = A.sum()
T_row = A.sum(1)
T_col = A.sum(0)

def calc(I, J):
    return T - T_row[I].sum() - T_col[J].sum() + A[I][:,J].sum()

def repr(i, W):
    s = np.binary_repr(i, width=W)[::-1]
    return [i for i, j in enumerate(s) if j == "1"]

count = 0
for i in range(2**H-1):
    for j in range(2**W-1):
        row = repr(i, H)
        col = repr(j, W)
        if calc(row, col) == K:
            count += 1

print(count)

Solution (Python):

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

ans=0

M=[]

yoko=[0 for i in range(H)]
tate=[0 for i in range(W)]

for i in range(H):
    l=list(input())
    cnt=0
    for j in range(W):
        if l[j]=="
            cnt+=1
    M.append(l)
    yoko[i]=cnt

for i in range(W):
    cnt=0
    for j in range(H):
        if M[j][i]=="
            cnt+=1
    tate[i]=cnt

B=sum(yoko)

for i in range(2**H):
    for j in range(2**W):
        num=B
        y=[]
        t=[]
        for a in range(H):
            if i>>a&1:
                num-=yoko[a]
                y.append(a)
                
        for b in range(W):
            if j>>b&1:
                num-=tate[b]
                t.append(b)
        
        for a in range(len(y)):
            for b in range(len(t)):
                if M[y[a]][t[b]]=="
                    num+=1
        if num==K:
            ans+=1

print(ans)

Solution (Python):
from itertools import combinations
import copy
H, W, K=list(map(int,input().split()))
def conv(m):
    if m=='
        return 1
    else:
        return 0
c=[]
for i in range(H):
    c.append([conv(s) for s in input()])
items = [(0,i) for i in range(H)]+[(1,j) for j in range(W)]
subsets=[]
for i in range(len(items) + 1):
    for e in combinations(items, i):
        subsets.append(e)
count=0
for e in subsets:
    M=copy.deepcopy(c)
    for p in e:
        if p[0]==0:
            for j in range(W):
                M[p[1]][j]=0
        else:
            for i in range(H):
                M[i][p[1]]=0
    if sum([sum(u) for u in M])==K:
        count+=1
print(count)

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

    counter = 0
    for mask_row in range(int(1 << H) - 1):
        for mask_col in range(int(1 << W) - 1):
            black = 0
            for x in range(H):
                if f'{mask_row:b}'.zfill(H)[x] == '1':
                    continue
                for y in range(W):
                    if f'{mask_col:b}'.zfill(W)[y] == '1':
                        continue
                    if c[x][y] == '
                        black += 1
            if black == K:
                counter += 1
    print(counter)

if __name__ == "__main__":
    resolve()

Solution (Python):
















































































def abc173_c(lines):
    H, W, K = map(int, lines[0].split(' '))
    pattern_h = get_pattern(H)
    pattern_w = get_pattern(W)
    answers = 0
    for h in pattern_h:
        for w in pattern_w:
            tmp = list()
            for i in range(1, len(lines)):
                tmp.append(lines[i])
            
            for n_row in range(H):
                if h[n_row] == '1':
                    tmp[n_row] = '*' * W
            for n_col in range(W):
                if w[n_col] == '1':
                    for n_row in range(H):
                        tmp[n_row] = replace_string_xy(tmp[n_row], n_col, '*')
            if count_char_from_lines(tmp, '
                answers += 1
    return [answers]



def replace_string_xy(line, pos, char):
    ret = ''
    for i, x in enumerate(line):
        if i == pos:
            ret += char
        else:
            ret += line[i]
    return ret



def count_char_from_line(line, char):
    n_char = 0
    for i in line:
        if i == char:
            n_char += 1
    return n_char



def count_char_from_lines(lines, char):
    n_char = 0
    for line in lines:
        n_char += count_char_from_line(line, char)
    return n_char



def get_pattern(n):
    _, patter = get_pattern_internal(n-1, ['0', '1'])
    return patter



def get_pattern_internal(n, lst):
    if n == 0:
        return 0, lst
    else:
        ret = list()
        for item in lst:
            ret.append('0' + item)
            ret.append('1' + item)
        m, ret = get_pattern_internal(n-1, ret)
        return m, ret



def get_input_lines_1stline1stblock_as_n_lines():
    lines = list()
    lines.append(input())
    H, W, K = map(int, lines[0].split(' '))
    for _ in range(H):
        lines.append(input())
    return lines



def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['2 3 2', '..
        lines_export = [5]
    elif pattern == 2:
        lines_input = ['2 3 4', '..
        lines_export = [1]
    elif pattern == 3:
        lines_input = ['2 2 3', '
        lines_export = [0]
    elif pattern == 4:
        lines_input = ['6 6 8', '..
        lines_export = [208]
    return lines_input, lines_export



def get_mode():
    import sys
    args = sys.argv
    if len(args) == 1:
        mode = 0
    else:
        mode = int(args[1])
    return mode



def main():
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines_1stline1stblock_as_n_lines()
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = abc173_c(lines_input)

    for line_result in lines_result:
        print(line_result)

    
    
    
    
    
    
    
    



if __name__ == '__main__':
    main()

Solution (Python):


import copy

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

ans_cnt = 0
for deh in range(2 ** H):
    htable = copy.deepcopy(table)
    
    for h in range(H):
        if deh & (1 << h):
            for ch in range(W):
                htable[h][ch] = "."
    for dew in range(2 ** W):
        wtable = copy.deepcopy(htable)
        for w in range(W):
            if dew & (1 << w):
                for cw in range(H):
                    wtable[cw][w] = "."
        cnt = 0
        for cnth in range(H):
            for cntw in range(W):
                if wtable[cnth][cntw] == "
                    cnt = cnt + 1
        if cnt == K:
            ans_cnt = ans_cnt + 1
        
        
print(ans_cnt)

Solution (Python):
def main():
    H, W, K = map(int, input().split())
    c=[input() for i in range(H)]
    c=list(map(list,c))
    ans = 0
    
    number = 0
    for i in range(H):
        for j in range(W):
            if c[i][j] == '
                number += 1
    
    for i in range(2**H):
        for j in range(2**W):
            count = 0
            for l in range(H):
                for m in range(W):
                    
                    if not i>>l&1 and not j>>m&1 and c[l][m] == "
                        
                        count+=1

            if count==K:
                
                ans+=1
    print(ans)

main()

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

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

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


C = [list(input()) for _ in range(H)]

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 2**h & i > 0 and 2**w & j > 0:
                    if C[h][w] == "
                        cnt += 1
        if cnt == K:
            ans += 1
print(ans)

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

Solution (Python):
a = list(map(int, input().split()))
h = a[0]
w = a[1]
k = a[2]

cols = ([input() for i in range(h)])

ans = 0

for col_mask in range(1 << (h + 1) - 1):
    for row_mask in range(1 << (w + 1) - 1):
        black = 0
        for i in range(h):
            for j in range(w):
                if ((1 << i) & col_mask) == 0 and ((1 << j) & row_mask) == 0 and cols[i][j] == '
                        black = black + 1
        if black == k:
            ans = ans + 1
print(ans)

Solution (Python):
from itertools import product as pd

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

ans = 0
for i, j in pd(range(1 << h), range(1 << w)):
    temp = 0
    for x, y in pd(range(h), range(w)):
        if 1 << x & i and 1 << y & j:
            if c[x][y] == "
                temp += 1
    ans += temp == k
print(ans)

Solution (Python):
from copy import deepcopy as dc

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

ans = 0
for h_i in range(2 ** h):
    temp = dc(c)
    for h_j in range(h):
        if (h_i >> h_j) & 1:
            temp[h_j] = ["+"] * w
    for w_i in range(2 ** w):
        temp2 = dc(temp)
        for w_j in range(w):
            if (w_i >> w_j) & 1:
                for i in range(h):
                    temp2[i][w_j] = "+"
        temp_ans = 0
        for i in range(h):
            temp_ans = temp_ans + "".join(temp2[i]).count("
        if temp_ans == k:
            ans = ans + 1
print(ans)

Solution (Python):

import math
import copy





target_1 = [int(x) for x in input().split()]

H = target_1[0]
W = target_1[1]
K = target_1[2]






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


def count_sharp(target):
    return sum([x.count("


def bin_code(value, keta):
    return list(("{:0" + str(keta) + "b}").format(value))



result = 0

for i in range(2 ** H):
    for j in range(2 ** W):
        bin_i = bin_code(i, H)
        bin_j = bin_code(j, W)
        tmp = copy.deepcopy(target)
        
        for idx_i, ik in enumerate(bin_i):
            if ik == "1":
                tmp[idx_i] = [0] * W
            for idx_j, jk in enumerate(bin_j):
                if jk == "1":
                    tmp[idx_i][idx_j] = 0

        
        if count_sharp(tmp) == K:
            result += 1
            



print(result)

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

import copy

ar = [[0 for _ in range(w)] for _ in range(h)]


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


d = {}
for i in range(h):
    for j in range(w):
        d[(i+1,j+1)] = ar[i][j]


sm = 0
for i in d.values():
    if(i == "
        sm += 1

gl = sm - k


ans = 0
def ch_red(x):
    d_tmp = copy.deepcopy(d)
    
    cnt = 0
    x_ar_bin = [0 for _ in range(h+w)]
    v = h+w
    for i in range(h+w):
        x_ar_bin[i] = int(bin(x >> i),2)%2
    
    

    for i in range(h):
        if(x_ar_bin[i] == 0):
            continue
        else:
            for j in range(w):
                key = (i+1,j+1)
                if(d_tmp[key] == "
                    d_tmp[key] = "$"
                    cnt += 1
    
    for i in range(h,h+w):
        if(x_ar_bin[i] == 0):
            continue
        else:
            for j in range(h):
                key = (j+1,i+1-h)
                if(d_tmp[key] == "
                    d_tmp[key] = "$"
                    cnt += 1
    
    
    if(cnt == gl):
        return 1
    else:
        return 0

    

mx = 2**(h+w)


for i in range(mx):
    ans += ch_red(i)

print(ans)

Solution (Python):
h, w, k = map(int, input().split())
C = [list(input()) for _ in range(h)]
cnt = 0
for I in range(2 ** h):
    I_lst = []
    for i in range(h):
        if (not((I >> i) & 1)):
            I_lst.append(i)
    for J in range(2 ** w):
        J_lst = []
        sum_black = 0
        for j in range(w):
            if (not((J >> j) & 1)):
                J_lst.append(j)
        
        for I_nokori in I_lst:
            for J_nokori in J_lst:
                if C[I_nokori][J_nokori] == '
                    sum_black += 1
        if sum_black == k:
            cnt += 1
            

print(cnt)

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

p = itertools.product([True,False],repeat = h+w)
ans = 0
for i in p:
    c_cut = c[np.ix_(i[:h],i[h:])]
    if np.count_nonzero(c_cut == '
        ans += 1
print(ans)