//#pragma GCC optimize("Ofast") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma") //#pragma GCC optimize("unroll-loops") #include #define N 15 #define inf 2147483647 #define LL long long #define DB double using namespace std; int T,n;char s[N][N];bool vis[N][N]; inline bool dfs(int x,int y){ if(x==n&&y==n) return 1;vis[x][y]=1;if(!vis[x][y+1]&&s[x][y+1]=='.'&&y> (char&ch){while(ch=nc(),ch==' '||ch=='\n');return *this;} templateFastIO& operator >> (T&ret){ ret=0;int f=1;char ch=nc();while(ch<'0'||ch>'9'){if(ch=='-')f=-f;ch=nc();} while(ch>='0'&&ch<='9'){ret=ret*10+ch-'0';ch=nc();}ret*=f;return *this; } FastIO& operator >> (char* s){int Len=0;char ch=nc();while(ch!='\n'){*(s+Len)=ch;Len++;ch=nc();}} templateFastIO& operator << (T x){ if(x<0){pc('-');x=-x;}do{stk[++stk[0]]=x%10;x/=10;}while(x); while(stk[0]) pc('0'+stk[stk[0]--]);return *this; } FastIO& operator << (char ch){pc(ch);return *this;} FastIO& operator << (string str){int Len=str.size()-1;for(stk[0]=0;Len>=0;Len--) stk[++stk[0]]=str[Len];while(stk[0]) pc(stk[stk[0]--]);return *this;} }fin,fout; int main(){ // freopen("data.in","r",stdin); // freopen("jxc.out","w",stdout); cin>>T;while(T--){scanf("%d",&n);for(register int i=1;i<=n;i++) scanf("%s",s[i]+1);if(s[1][1]!='.'){puts("0");continue;}for(register int i=1;i<=n;i++) for(register int j=1;j<=n;j++) vis[i][j]=0;int ans=0;while(dfs(1,1)) ans++;cout<