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 JavaScript (Node.js 12.16.1) (judge verdict: Accepted)

/*! path: src/contest/atcoder/abc173/c.ts */!function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";(function(e){var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.main=t.calcBitRemaining=void 0;const o=r(n(2)),i=n(3);function u(e,t,n){let r=0;for(let o=0;o<n.length;o++)for(let i=0;i<n[o].length;i++){"#"===n[o][i]&&r++;const u=(1<<o&e)>0,c=(1<<i&t)>0;u&&"#"===n[o][i]&&r--,c&&"#"===n[o][i]&&r--,u&&c&&"#"===n[o][i]&&r++}return r}function c(e){const t=i.getNext(e),n=parseInt(t()),r=parseInt(t()),o=parseInt(t()),c=[];for(let e=0;e<n;e++)c.push(t());const l=function({H:e,W:t,K:n,B:r}){let o=0;for(let i=0;i<1<<e;i++)for(let e=0;e<1<<t;e++)u(i,e,r)===n&&o++;return o}({H:n,W:r,K:o,B:c});console.log(l)}if(t.calcBitRemaining=u,t.main=c,n.c[n.s]===e){c(o.default.readFileSync("/dev/stdin","utf8"))}}).call(this,n(1)(e))},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t){e.exports=require("fs")},function(e,t,n){"use strict";function*r(e){const t=e.split(/\s+/);for(const e of t)yield e}Object.defineProperty(t,"__esModule",{value:!0}),t.getNextBigInt=t.getNextInt=t.getNext=t.getIteratorWithParser=t.getIterator=void 0,t.getIterator=r,t.getIteratorWithParser=function*(e,t){const n=e.split(/\s+/);for(const e of n)yield t(e)},t.getNext=function(e){const t=r(e);return()=>t.next().value},t.getNextInt=function(e){const t=r(e);return()=>parseInt(t.next().value)},t.getNextBigInt=function(e){const t=r(e);return()=>BigInt(t.next().value)}}]);