import { readFileSync } from "fs";

// eslint-disable-next-line @typescript-eslint/no-unused-vars
const range = (n: number | bigint) => [...Array(Number(n))].map((_, i) => i);
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const tuple = <T extends unknown[]>(...ts: T) => ts;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const [cin, nCin, biCin] = (() => {
  const inputs = readFileSync("/dev/stdin", "utf-8").split(/[\n|\s]+/);
  let count = 0;
  const cin = () => inputs[count++];
  return tuple(
    cin,
    () => Number(cin()),
    () => BigInt(cin())
  );
})();

type Color = "Black" | "White";
type Grid = Color[][] & {
  height: number;
  width: number;
};
type PickData = {
  index: number;
  isPicked: boolean;
};

const getBlackCnt = (hPicks: PickData[], wPicks: PickData[], grid: Grid) =>
  hPicks
    .filter(({ isPicked }) => isPicked)
    .map(({ index }) => {
      const cs = grid[index];
      return wPicks
        .filter(({ isPicked }) => isPicked)
        .map(({ index }) => (cs[index] === "Black" ? 1 : 0) as number)
        .reduce((acc, x) => acc + x, 0);
    })
    .reduce((acc, x) => acc + x, 0);

const wPickFn = (K: number, grid: Grid, hPicks: PickData[], initialBlackCnt: number) => {
  const wPickFn = (n: number, wPicks: PickData[]): number =>
    n >= grid.width
      ? (() => {
          const hCnt = getBlackCnt(
            range(grid.height).map((i) => ({ index: i, isPicked: true })),
            wPicks,
            grid
          );
          const wCnt = getBlackCnt(
            hPicks,
            range(grid.width).map((j) => ({ index: j, isPicked: true })),
            grid
          );
          const hwCnt = getBlackCnt(hPicks, wPicks, grid);
          return initialBlackCnt - (hCnt + wCnt - hwCnt);
        })() === K
        ? 1
        : 0
      : wPickFn(n + 1, wPicks) +
        wPickFn(
          n + 1,
          wPicks.map(({ index, isPicked }) =>
            index === n ? { index: index, isPicked: true } : { index: index, isPicked: isPicked }
          )
        );
  return wPickFn(
    0,
    range(grid.width).map((j) => ({ index: j, isPicked: false }))
  );
};

const hPickFn = (grid: Grid, K: number) => {
  const initialBlackCnt = getBlackCnt(
    range(grid.height).map((i) => ({ index: i, isPicked: true })),
    range(grid.width).map((j) => ({ index: j, isPicked: true })),
    grid
  );
  const hPickFn = (n: number, hPicks: PickData[]): number =>
    n >= grid.height
      ? wPickFn(K, grid, hPicks, initialBlackCnt)
      : hPickFn(n + 1, hPicks) +
        hPickFn(
          n + 1,
          hPicks.map(({ index, isPicked }) =>
            index === n ? { index: index, isPicked: true } : { index: index, isPicked: isPicked }
          )
        );
  return hPickFn(
    0,
    range(grid.height).map((i) => ({ index: i, isPicked: false }))
  );
};

const getCnt = (K: number, grid: Grid) => hPickFn(grid, K);

{
  const [H, W, K] = [nCin(), nCin(), nCin()];
  const grid: Grid = (() => {
    const grid: Color[][] = range(H).map(() =>
      cin()
        .split("")
        .map((c) => (c === "#" ? "Black" : "White") as Color)
    );
    return { ...grid, height: H, width: W };
  })();
  const cnt = getCnt(K, grid);
  console.log(cnt);
}


Measured memory_bytes: 40340