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 in C (GCC 9.2.1) (judge verdict: Accepted)

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
int main(){
    int h,i,j,w,k,count=0,ans=0,rh[6]={},rw[6]={};
    char c[7][7]={},d[7][7]={};
    scanf("%d %d %d\n",&h,&w,&k);
    for(i=0; i<h; i++){
        for(j=0; j<w; j++){
            scanf("%c\n",&c[i][j]);
            d[i][j]=c[i][j];
        }
    }
    for(rh[0]=0; rh[0]<=1; rh[0]++){
        for(rh[1]=0; rh[1]<=1; rh[1]++){
            if(rh[1]==1 && h<=1)continue;
            for(rh[2]=0; rh[2]<=1; rh[2]++){
                if(rh[2]==1 && h<=2)continue;
                for(rh[3]=0; rh[3]<=1; rh[3]++){
                    if(rh[3]==1 && h<=3)continue;
                    for(rh[4]=0; rh[4]<=1; rh[4]++){
                        if(rh[4]==1 && h<=4)continue;
                        for(rh[5]=0; rh[5]<=1; rh[5]++){
                            if(rh[5]==1 && h<=5)continue;
                            for(rw[0]=0; rw[0]<=1; rw[0]++){
                                for(rw[1]=0; rw[1]<=1; rw[1]++){
                                    if(rw[1]==1 && w<=1)continue;
                                    for(rw[2]=0; rw[2]<=1; rw[2]++){
                                        if(rw[2]==1 && w<=2)continue;
                                        for(rw[3]=0; rw[3]<=1; rw[3]++){
                                            if(rw[3]==1 && w<=3)continue;
                                            for(rw[4]=0; rw[4]<=1; rw[4]++){
                                                if(rw[4]==1 && w<=4)continue;
                                                for(rw[5]=0; rw[5]<=1; rw[5]++){
                                                    if(rw[5]==1 && w<=5)continue;
                                                    for(i=0; i<h; i++){
                                                        for(j=0; j<w; j++){
                                                            if(rh[i]==1 || rw[j]==1){
                                                                c[i][j]='.';
                                                            }
                                                            if(c[i][j]=='#')count++;
                                                        }
                                                    }
                                                    if(count==k)ans++;
                                                    for(i=0; i<h; i++){
                                                        for(j=0; j<w; j++){
                                                            c[i][j]=d[i][j];
                                                        }
                                                    }
                                                    count=0;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    printf("%d",ans);
    return 0;
}