#include <set>
#include <map>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <complex>
#include <iostream>
#include <algorithm>
#include <ctime>
#include <deque>
#include <bitset>
#include <cctype>
#include <utility>
#include <cassert>
using namespace std;
#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define FORD(i,a,b) for(int i=(a),_b=(b); i>=_b; i--)
#define REP(i,a) for(int i=0,_a=(a); i<_a; i++)
#define EACH(it,a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define DEBUG(x) { cout << #x << " = " << x << endl; }
#define PR(a,n) { cout << #a << " = "; FOR(_,1,n) cout << a[_] << ' '; cout << endl; }
#define PR0(a,n) { cout << #a << " = "; REP(_,n) cout << a[_] << ' '; cout << endl; }
#define TWO(X) (1<<(X))
#define CONTAIN(S,X) (S & TWO(X))
long double c[111][111];
int n, k;
char a[11][11];
bool need[11][11];
void fill(int x) {
if (x < n) {
int i = x + 1;
FOR(j,1,n) need[i][j] = true;
}
else if (x < 2*n) {
int j = x - n + 1;
FOR(i,1,n) need[i][j] = true;
}
else if (x == 2*n) {
FOR(i,1,n) need[i][i] = true;
}
else {
FOR(i,1,n) need[i][n+1-i] = true;
}
}
int main() {
ios :: sync_with_stdio(false); cin.tie(NULL);
cout << (fixed) << setprecision(9);
FOR(i,0,100) {
c[i][0] = 1;
FOR(j,1,i) c[i][j] = c[i-1][j-1] + c[i-1][j];
}
int test; cin >> test;
while (test--) {
cin >> n >> k;
int num = 0;
FOR(i,1,n) FOR(j,1,n) {
cin >> a[i][j];
if (a[i][j] == '.') ++num;
}
if (k > num) k = num;
double res = 0;
REP(mask,TWO(n+n+2)) if (mask) {
FOR(i,1,n) FOR(j,1,n) need[i][j] = false;
double cur = 0;
REP(x,n+n+2)
if (CONTAIN(mask,x)) {
fill(x);
}
int sumNeed = 0;
FOR(i,1,n) FOR(j,1,n) if (need[i][j] && a[i][j] == '.') ++sumNeed;
if (sumNeed > k) cur = 0;
else cur = c[num - sumNeed][k - sumNeed] / c[num][k];
if (__builtin_popcount(mask) & 1) res += cur;
else res -= cur;
}
cout << 100.0 * res << endl;
}
return 0;
}
I2luY2x1ZGUgPHNldD4KI2luY2x1ZGUgPG1hcD4KI2luY2x1ZGUgPGxpc3Q+CiNpbmNsdWRlIDxjbWF0aD4KI2luY2x1ZGUgPHF1ZXVlPgojaW5jbHVkZSA8c3RhY2s+CiNpbmNsdWRlIDxjc3RkaW8+CiNpbmNsdWRlIDxzdHJpbmc+CiNpbmNsdWRlIDx2ZWN0b3I+CiNpbmNsdWRlIDxjc3RkbGliPgojaW5jbHVkZSA8Y3N0cmluZz4KI2luY2x1ZGUgPHNzdHJlYW0+CiNpbmNsdWRlIDxpb21hbmlwPgojaW5jbHVkZSA8Y29tcGxleD4KI2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8YWxnb3JpdGhtPgoKI2luY2x1ZGUgPGN0aW1lPgojaW5jbHVkZSA8ZGVxdWU+CiNpbmNsdWRlIDxiaXRzZXQ+CiNpbmNsdWRlIDxjY3R5cGU+CiNpbmNsdWRlIDx1dGlsaXR5PgojaW5jbHVkZSA8Y2Fzc2VydD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCiNkZWZpbmUgRk9SKGksYSxiKSBmb3IoaW50IGk9KGEpLF9iPShiKTsgaTw9X2I7IGkrKykKI2RlZmluZSBGT1JEKGksYSxiKSBmb3IoaW50IGk9KGEpLF9iPShiKTsgaT49X2I7IGktLSkKI2RlZmluZSBSRVAoaSxhKSBmb3IoaW50IGk9MCxfYT0oYSk7IGk8X2E7IGkrKykKI2RlZmluZSBFQUNIKGl0LGEpIGZvcihfX3R5cGVvZihhLmJlZ2luKCkpIGl0ID0gYS5iZWdpbigpOyBpdCAhPSBhLmVuZCgpOyArK2l0KQoKI2RlZmluZSBERUJVRyh4KSB7IGNvdXQgPDwgI3ggPDwgIiA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ai0xXSArIGNbaS0xXVtqXTsKICAgIH0KICAgIGludCB0ZXN0OyBjaW4gPj4gdGVzdDsKICAgIHdoaWxlICh0ZXN0LS0pIHsKICAgICAgICBjaW4gPj4gbiA+PiBrOwogICAgICAgIGludCBudW0gPSAwOwogICAgICAgIEZPUihpLDEsbikgRk9SKGosMSxuKSB7CiAgICAgICAgICAgIGNpbiA+PiBhW2ldW2pdOwogICAgICAgICAgICBpZiAoYVtpXVtqXSA9PSAnLicpICsrbnVtOwogICAgICAgIH0KICAgICAgICBpZiAoayA+IG51bSkgayA9IG51bTsKCiAgICAgICAgZG91YmxlIHJlcyA9IDA7CiAgICAgICAgUkVQKG1hc2ssVFdPKG4rbisyKSkgaWYgKG1hc2spIHsKICAgICAgICAgICAgRk9SKGksMSxuKSBGT1IoaiwxLG4pIG5lZWRbaV1bal0gPSBmYWxzZTsKICAgICAgICAgICAgZG91YmxlIGN1ciA9IDA7CiAgICAgICAgICAgIFJFUCh4LG4rbisyKQogICAgICAgICAgICAgICAgaWYgKENPTlRBSU4obWFzayx4KSkgewogICAgICAgICAgICAgICAgICAgIGZpbGwoeCk7CiAgICAgICAgICAgICAgICB9CgogICAgICAgICAgICBpbnQgc3VtTmVlZCA9IDA7CiAgICAgICAgICAgIEZPUihpLDEsbikgRk9SKGosMSxuKSBpZiAobmVlZFtpXVtqXSAmJiBhW2ldW2pdID09ICcuJykgKytzdW1OZWVkOwoKICAgICAgICAgICAgaWYgKHN1bU5lZWQgPiBrKSBjdXIgPSAwOwogICAgICAgICAgICBlbHNlIGN1ciA9IGNbbnVtIC0gc3VtTmVlZF1bayAtIHN1bU5lZWRdIC8gY1tudW1dW2tdOwoKICAgICAgICAgICAgaWYgKF9fYnVpbHRpbl9wb3Bjb3VudChtYXNrKSAmIDEpIHJlcyArPSBjdXI7CiAgICAgICAgICAgIGVsc2UgcmVzIC09IGN1cjsKICAgICAgICB9CiAgICAgICAgY291dCA8PCAxMDAuMCAqIHJlcyA8PCBlbmRsOwogICAgfQogICAgcmV0dXJuIDA7Cn0KCgk=