#include <iostream>
using namespace std;
const int N = 10;
char c[N][N];
int row[N];
int col[N];
int res;
int dfs(int, int, int);
int n, k;
int main()
{
while ((cin >> n >> k) && (n != -1) && (k != -1))
{
res = 0;
for (int i=0; i<n; i++)
{
row[i] = 0;
col[i] = 0;
for (int j=0; j<n; j++)
{
cin >> c[i][j];
}
}
cout << dfs(0, 0, k) << endl;
}
return 0;
}
int dfs(int i, int j, int k)
{
if (!k)
{
res++;
return res;
}
if (j == n)
{
j=0;
i++;
}
if (i == n)
{
return res;
}
if ((c[i][j] == '#') && (!row[i]) && (!col[j]))
{
row[i] = 1;
col[j] = 1;
dfs(i+1, 0, k-1);
row[i] = 0;
col[j] = 0;
}
dfs(i, j+1, k);
return res;
}