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):
##a = int(stdin.readline().rstrip())
##b, c = [int(x) for x in stdin.readline().rstrip().split()]
##s = stdin.readline().rstrip()

##a = list(map(int,[int(x) for x in stdin.readline().rstrip().split()])) a[0, 1, 2, ...]
##a = [[0] * 2 for _ in range(n)]  a[0,0]






# -*- coding: utf-8 -*-
from sys import stdin
from operator import itemgetter
from collections import deque, Counter
import math
import pprint
from functools import reduce
import numpy as np
import random
import bisect
import copy



MOD = 1000000007
INF = float('inf')
alpha = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]

def keta(kazu): 
    kazu_str = str(kazu)
    kazu_list = [int(kazu_str[i]) for i in range(0, len(kazu_str))]
    return kazu_list

def gcd(*numbers): 
    return reduce(math.gcd, numbers)

def combination(m,n): # mCn
    
    if n > m:
        return 'すまん'
    return math.factorial(m) // (math.factorial(m-n) * math.factorial(n))

def pow_k(x,n):  
    if n == 0:
        return 1
    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        n //= 2
    return K * x

def fact(n): 
    arr = {}
    temp = n
    for i in range(2,int(n**0.5)+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr[i] = cnt
    if temp != 1:
        arr[temp] = 1
    if arr == {}:
        arr[n] = 1
    return arr


    
def main():
    h, w, k = [int(x) for x in stdin.readline().rstrip().split()]
    board = []
    kuro = 0
    pattern_h = [[0]*h for _ in range(2 ** h)]
    pattern_w = [[0]*w for _ in range(2 ** w)]
    ans = 0
    nokori = 0
    
    for _ in range(h):
        s = stdin.readline().rstrip()
        v = [s[i] for i in range(0, len(s))]
        kuro += v.count("#")
        board.append(v)
    memo = copy.deepcopy(board)
    
    for i in range(2 ** h):
        for j in range(h):
            if (i >> j) & 1:
                pattern_h[i][j] = j + 1
    for i in range(2 ** w):
        for j in range(w):
            if (i >> j) & 1:
                pattern_w[i][j] = j + 1
                
    for i in range(2 ** w):
        for j in range(w):
            if pattern_w[i][j] != 0:
                for l in range(h):
                    memo[l][j] = "x"
        print(memo)
        for i2 in range(2 ** h):
            for j2 in range(h):
                if pattern_h[i2][j2] == 0:
                    nokori += memo[j2].count("#")
            if k == nokori:
                ans += 1
            nokori = 0
        memo = copy.deepcopy(board)
                        
    print(ans)
                                        
main()

Fixed, accepted submission:
##a = int(stdin.readline().rstrip())
##b, c = [int(x) for x in stdin.readline().rstrip().split()]
##s = stdin.readline().rstrip()

##a = list(map(int,[int(x) for x in stdin.readline().rstrip().split()])) a[0, 1, 2, ...]
##a = [[0] * 2 for _ in range(n)]  a[0,0]






# -*- coding: utf-8 -*-
from sys import stdin
from operator import itemgetter
from collections import deque, Counter
import math
import pprint
from functools import reduce
import numpy as np
import random
import bisect
import copy



MOD = 1000000007
INF = float('inf')
alpha = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]

def keta(kazu): 
    kazu_str = str(kazu)
    kazu_list = [int(kazu_str[i]) for i in range(0, len(kazu_str))]
    return kazu_list

def gcd(*numbers): 
    return reduce(math.gcd, numbers)

def combination(m,n): # mCn
    
    if n > m:
        return 'すまん'
    return math.factorial(m) // (math.factorial(m-n) * math.factorial(n))

def pow_k(x,n):  
    if n == 0:
        return 1
    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        n //= 2
    return K * x

def fact(n): 
    arr = {}
    temp = n
    for i in range(2,int(n**0.5)+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr[i] = cnt
    if temp != 1:
        arr[temp] = 1
    if arr == {}:
        arr[n] = 1
    return arr


    
def main():
    h, w, k = [int(x) for x in stdin.readline().rstrip().split()]
    board = []
    kuro = 0
    pattern_h = [[0]*h for _ in range(2 ** h)]
    pattern_w = [[0]*w for _ in range(2 ** w)]
    ans = 0
    nokori = 0
    
    for _ in range(h):
        s = stdin.readline().rstrip()
        v = [s[i] for i in range(0, len(s))]
        kuro += v.count("#")
        board.append(v)
    memo = copy.deepcopy(board)
    
    for i in range(2 ** h):
        for j in range(h):
            if (i >> j) & 1:
                pattern_h[i][j] = j + 1
    for i in range(2 ** w):
        for j in range(w):
            if (i >> j) & 1:
                pattern_w[i][j] = j + 1
                
    for i in range(2 ** w):
        for j in range(w):
            if pattern_w[i][j] != 0:
                for l in range(h):
                    memo[l][j] = "x"
        for i2 in range(2 ** h):
            for j2 in range(h):
                if pattern_h[i2][j2] == 0:
                    nokori += memo[j2].count("#")
            if k == nokori:
                ans += 1
            nokori = 0
        memo = copy.deepcopy(board)
                        
    print(ans)
                                        
main()