Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import sys

def combinationlist(n):
    p_sets = []
    for i in range(2 ** n):
        lst = [x + 1 for x in range(i) if 2 **x & i]
        if lst != []:
            p_sets.append(lst)
    p_sets = sorted(p_sets, key=lambda x: len(x))
    return p_sets


def main():
    data = input().split()
    h = int(data[0])
    w = int(data[1])
    k = int(data[2])
    c = np.empty((h,w),dtype=str)
    for i in range(h):
        s = input()
        c[i,:] = np.array([c for c in s])
    rowset = []
    colset = []
    all_black = 0
    for i in range(h):
        data = c[i,:]
        count = len(data[data == '#'])
        all_black += count
        rowset.append([count, data])
    for j in range(w):
        data = c[:,j]
        count = len(data[data=='#'])
        colset.append([count,data])
    ans = 0
    if k == all_black:
        ans += 1
    combList = combinationlist(h+w)
    for comb in combList:
        count = 0
        if all(np.array(comb) <= h):
            for i in  comb:
                count += rowset[i-1][0]
            if count == all_black - k:
                ans += 1
        elif all(np.array(comb) > h):
            for i in comb:
                count += colset[i-h-1][0]
            if count == all_black - k:
                ans += 1
        else:
            rows = []
            for i in comb:
                if i <= h:
                    count += rowset[i-1][0]
                    rows.append(i-1)
                else:
                    count += colset[i-h-1][0]
                    for j in rows:
                        if '#' == colset[i-h-1][1][j]:
                            count = count -1
            if count == all_black  - k:
                ans += 1
    print(ans)
    return


if __name__ == '__main__':
    main()


Fixed submission:
import numpy as np
import sys

def combinationlist(n):
    p_sets = []
    for i in range(2 ** n):
        lst = [x + 1 for x in range(i) if 2 **x & i]
        if lst != []:
            p_sets.append(lst)
    p_sets = sorted(p_sets, key=lambda x: len(x))
    return p_sets


def main():
    data = input().split()
    h = int(data[0])
    w = int(data[1])
    k = int(data[2])
    c = np.empty((h,w),dtype=str)
    for i in range(h):
        s = input()
        c[i,:] = np.array([c for c in s])
    rowset = []
    colset = []
    all_black = 0
    for i in range(h):
        data = c[i,:]
        count = len(data[data == '#'])
        all_black += count
        rowset.append([count, data])
    for j in range(w):
        data = c[:,j]
        count = len(data[data=='#'])
        colset.append([count,data])
    ans = 0
    if k == all_black:
        ans += 1
    rowList = combinationlist(h)
    colList = combinationlist(w)
    for comb in rowList:
        if w*len(comb) > h*w - k:
            continue
        count = 0
        for i in  comb:
            count += rowset[i-1][0]
        if count == all_black - k:
            ans += 1
        if count <= all_black - k:
            for comb_2 in colList:
                comb_count = count
                for j in comb_2:
                    comb_count += colset[j-1][0]
                    for s in comb:
                        if '#' == colset[j-1][1][s-1]:
                            comb_count = comb_count -1
                if comb_count == all_black - k:
                    ans += 1
    for comb in colList:
        if h*len(comb) > h*w - k:
            continue
        count = 0
        for i in  comb:
            count += colset[i-1][0]
        if count == all_black - k:
            ans += 1
    print(ans)
    return


if __name__ == '__main__':
    main()