#include <iostream>
#include <string.h>
#include <stdio.h>
#include <vector>
#include <queue>
using namespace std;
int n,k;
const int MAXSIZE = 8;
char road[MAXSIZE][MAXSIZE];
int visit[MAXSIZE][MAXSIZE];
int sum;
bool ismatch(int x, int y){
for (int i = 0; i < x; ++i) {
if (visit[i][y])
return false;
}
return true;
}
void getans(int row, int count){
if (count == k){
sum ++;
return;
}
for (int i = row; i < n; ++i) {
for (int j = 0; j < n; ++j) {
if (road[i][j]=='.')
continue;
if (ismatch(i, j)){
visit[i][j] = 1;
getans(i+1, count+1);
visit[i][j] = 0;
}
}
}
}
int main(){
while (true){
memset(visit, false, sizeof(visit));
cin>>n>>k;
if (n==-1)break;
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
cin>>road[i][j];
}
}
sum = 0;
getans(0, 0);
cout<<sum<<endl;
}
}