/* Question: Queen's problem, board problem, simple DFS. You just need to pay attention to a detailed solution: traverse through rows directly. However, DFS (I + 1, POS) can be used to identify this vulnerability with his first test data. */# Include <iostream> # include <cstring> # include <cstdio> using namespace STD; int A [10] [10], sum, N, K; int Visi [10]; void DFS (int I, int POS) {If (Pos = k) {sum ++; return ;}if (I> N) return; int XJ; For (XJ = 1; XJ <= N; XJ ++) {if (a [I] [XJ] &! Visi [XJ]) {Visi [XJ] = 1; DFS (I + 1, POS + 1); Visi [XJ] = 0 ;}} DFS (I + 1, pos); // This requires another DFS return;} int main () {char P [10]; int I, j; while (~ Scanf ("% d", & N, & K) {If (n =-1 & K =-1) break; memset (A, 0, sizeof (a); memset (Visi, 0, sizeof (Visi); int SUT = 0; for (I = 1; I <= N; I ++) {scanf ("% s", P); For (j = 0; j <n; j ++) if (P [J] = '#') {A [I] [J + 1] = 1; SUT ++ ;}} if (SUT <k) printf ("0 \ n"); else {sum = 0; DFS (); printf ("% d \ n", sum) ;}} return 0 ;}