Problem:
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.

Incorrect submission (verdict: Wrong Answer):
H, W, K = map(int, input().split())
c = [input() for i in range(H)]
"""                                                                                                                                  
H = 6                                                                                                                                
W = 6                                                                                                                                
K = 3                                                                                                                                
c = ['...#.#',                                                                                                                       
     '...###',                                                                                                                       
     '#.....',                                                                                                                       
     '...#..',                                                                                                                       
     '...###',                                                                                                                       
     '...##.']                                                                                                                       
"""
ret = 0
for i in range(2**H):
    for j in range(2**W):
        num = 0
        mask_h = str(bin(i))[2:].zfill(H)
        mask_w = str(bin(j))[2:].zfill(W)
        for  k in range(H):
            if mask_h[k] == '0': continue
            for l in range(W):
                if mask_w[l] == '0': continue
                if c[k][l] == '#':
                    num += 1
        if num == K:
            ret += 1
        print('num',num)

print (ret)



Fixed, accepted submission:
H, W, K = map(int, input().split())
c = [input() for i in range(H)]
"""                                                                                                                                  
H = 6                                                                                                                                
W = 6                                                                                                                                
K = 3                                                                                                                                
c = ['...#.#',                                                                                                                       
     '...###',                                                                                                                       
     '#.....',                                                                                                                       
     '...#..',                                                                                                                       
     '...###',                                                                                                                       
     '...##.']                                                                                                                       
"""
ret = 0
for i in range(2**H):
    for j in range(2**W):
        num = 0
        mask_h = str(bin(i))[2:].zfill(H)
        mask_w = str(bin(j))[2:].zfill(W)
        for  k in range(H):
            if mask_h[k] == '0': continue
            for l in range(W):
                if mask_w[l] == '0': continue
                if c[k][l] == '#':
                    num += 1
        if num == K:
            ret += 1

print (ret)