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# (.NET Core 3.1.201) (judge verdict: Accepted)

using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var h = input[0];
            var w = input[1];
            var k = input[2];

            var grid = new string[6, 6];

            for (int i = 0; i < h; i++)
                for (int j = 0; j < w; j++)
                    grid[i, j] = "";

            for (int i = 0; i < h; i++)
            {
                var input1 = Console.ReadLine();
                for (int j = 0; j < w; j++)
                    grid[i, j] = input1[j].ToString();
            }

            var c1 = new List<string> { "", "1", "2", "3", "4", "5", "6" };
            var c2 = new List<string> { "12", "13", "14", "15", "16", "23", "24", "25", "26", "34", "35", "36", "45", "46", "56" };
            var c3 = new List<string> { "123", "124", "125", "126", "134", "135", "136", "145", "146", "156", "234", "235", "236", "245", "246","256", "345", "346", "356", "456" };
            var c4 = new List<string> { "1234", "1235", "1236", "1245", "1246", "1256", "1345", "1346", "1356", "1456", "2345", "2346", "2356", "2456", "3456" };
            var c5 = new List<string> { "12345", "12346", "23456","12356", "12456", "13456" };
            var c6 = new List<string> { "123456" };

            int res = 0;

            var totalh = new List<string> { };
            totalh.AddRange(c1);
            if (h > 1)
                totalh.AddRange(c2);
            if (h > 2)
                totalh.AddRange(c3);
            if (h > 3)
                totalh.AddRange(c4);
            if (h > 4)
                totalh.AddRange(c5);
            if (h > 5)
                totalh.AddRange(c6);

            var totalw = new List<string> { };
            totalw.AddRange(c1);
            if (w > 1)
                totalw.AddRange(c2);
            if (w > 2)
                totalw.AddRange(c3);
            if (w > 3)
                totalw.AddRange(c4);
            if (w > 4)
                totalw.AddRange(c5);
            if (w > 5)
                totalw.AddRange(c6);


            for (int i = 0; i < totalh.Count(); i++)
            {
                for (int j = 0; j < totalw.Count(); j++)
                {
                    var sweeph = totalh[i];
                    var sweepw = totalw[j];

                    bool check = true;

                    for (int l = 0; l < sweeph.Length; l++)
                    {
                        int thish = int.Parse(sweeph[l].ToString()) - 1;
                        if (thish >= h)
                            check = false;
                    }

                    for (int l = 0; l < sweepw.Length; l++)
                    {
                        int thisw = int.Parse(sweepw[l].ToString()) - 1;
                        if (thisw >= w)
                            check = false;
                    }

                    if (!check)
                        continue;

                    var thisgrid = new string[6, 6];
                    for (int l = 0; l < h; l++)
                        for (int q = 0; q < w; q++)
                            thisgrid[l, q] = grid[l, q];

                    for (int l = 0; l < sweeph.Length; l++)
                    {
                        //if (sweeph[i].ToString() == "") continue;
                        int thish = int.Parse(sweeph[l].ToString()) - 1;
                        for (int q = 0; q < w; q++)
                            thisgrid[thish, q] = "";
                    }

                    for (int l = 0; l < sweepw.Length; l++)
                    {
                        //if (sweepw[i].ToString() == "") continue;
                        int thisw = int.Parse(sweepw[l].ToString()) - 1;
                        for (int q = 0; q < h; q++)
                            thisgrid[q, thisw] = "";
                    }

                    int cnt = 0;
                    for (int l = 0; l < h; l++)
                        for (int q = 0; q < w; q++)
                            if (thisgrid[l, q] == "#")
                                cnt++;

                    if (k == cnt)
                        res++;
                }
            }

            Console.WriteLine(res);

        }


    }
}