/*
  [BAPC'07] LINGO
  by: Jan Kuipers
*/

using namespace std;

#include <iostream>
#include <iomanip>
#include <vector>
#include <string>

int N,K,E;
vector<string> b;
vector<double> cache;

double go(int ver, int hor, int diag1, int diag2, int y, int x, int k) {
  if (y==N) return 0;
  
  if (x==N) {
    if (hor) return 1;
    return go(ver,1,diag1,diag2,y+1,0,k);
  }
  
  if (b[y][x]=='*') {
    if (y==N-1) {
      if (ver & (1<<x)) return 1;
      if (diag1 && y==x) return 1;
      if (diag2 && x==0) return 1;
    }
    return go(ver,hor,diag1,diag2,y,x+1,k);
  }
  
  double &res = cache[(((((ver*2+hor)*2+diag1)*2+diag2)*N+y)*N+x)*(K+1)+k];
  if (res!=-1) return res;

  double prob = 1.0 * k / E;
  E--;
  
  double lingo;
  if (y==N-1 && (ver & (1<<x))) lingo=1;
  else if (y==N-1 && diag1 && y==x) lingo=1;
  else if (y==N-1 && diag2 && x==0) lingo=1;
  else if (k>0) lingo = go(ver,hor,diag1,diag2,y,x+1,k-1);
  else lingo=0;
  
  res = prob * lingo;

  if (ver&(1<<x)) ver-=1<<x;
  hor=0;
  if (y==x) diag1=0;
  if (y==N-1-x) diag2=0;

  if (prob<1) res += (1-prob) * go(ver,hor,diag1,diag2,y,x+1,k);

  E++;
  
  return res;  
}

int main () {

  int runs;
  cin>>runs;
  while (runs--) {

    cin>>N>>K;
    b=vector<string>(N);
    for (int i=0; i<N; i++) cin>>b[i];

    E=0;
    for (int i=0; i<N; i++)
      for (int j=0; j<N; j++)
	if (b[i][j]=='.') E++;
    
    cache=vector<double>((1<<N)*2*2*2*N*N*(K+1), -1);
    cout<<setprecision(10)<<(100*go((1<<N)-1,1,1,1,0,0,K))<<endl;
  }
  
  return 0;
}
