#include <bits/stdc++.h>
using namespace std;
int main() {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
int t;
cin>>t;
for(int k=1;k<=t;k++)
{
cout<<"Case #"<<k<<":"<<endl;
int n;
cin>>n;
vector<vector<char>> a(n,vector<char>(n,' '));
int sr=0,sc=0,er=n-1,ec=n-1;
while(sr<=er && sc<=ec)
{
for(int i=sc;i<=ec;i++)
a[sr][i]='*';
sr++;
for(int i=sr;i<=er;i++)
a[i][ec]='*';
ec--;
if(sc!=0)
sc++;
if(sr<er)
{for(int i=ec;i>=sc;i--)
a[er][i]='*';
er--;
}
sr++;
//er--;
if(sc<ec){
for(int i=er;i>=sr;i--)
a[i][sc]='*';
sc++;
}
ec--;
er--;
//=sc++;
}
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
if(a[i][j]=='*')
cout<<"* ";
else
cout<<" ";
}
cout<<endl;
}
cout<<endl;
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbWFpbigpIHsKICAgIC8qIEVudGVyIHlvdXIgY29kZSBoZXJlLiBSZWFkIGlucHV0IGZyb20gU1RESU4uIFByaW50IG91dHB1dCB0byBTVERPVVQgKi8gIAogICAgaW50IHQ7CiAgICBjaW4+PnQ7CiAgICBmb3IoaW50IGs9MTtrPD10O2srKykKICAgIHsKICAgICAgICBjb3V0PDwiQ2FzZSAjIjw8azw8IjoiPDxlbmRsOwogICAgICAgIGludCBuOwogICAgICAgIGNpbj4+bjsKICAgICAgICB2ZWN0b3I8dmVjdG9yPGNoYXI+PiBhKG4sdmVjdG9yPGNoYXI+KG4sJyAnKSk7CiAgICAgICAgaW50IHNyPTAsc2M9MCxlcj1uLTEsZWM9bi0xOwogICAgICAgIHdoaWxlKHNyPD1lciAmJiBzYzw9ZWMpCiAgICAgICAgewogICAgICAgICAgICBmb3IoaW50IGk9c2M7aTw9ZWM7aSsrKQogICAgICAgICAgICAgICAgYVtzcl1baV09JyonOwogICAgICAgICAgICBzcisrOwogICAgICAgICAgICBmb3IoaW50IGk9c3I7aTw9ZXI7aSsrKQogICAgICAgICAgICAgICAgYVtpXVtlY109JyonOwogICAgICAgICAgICBlYy0tOwogICAgICAgICAgICBpZihzYyE9MCkKICAgICAgICAgICAgICAgIHNjKys7CiAgICAgICAgICAgIGlmKHNyPGVyKQogICAgICAgICAgICB7Zm9yKGludCBpPWVjO2k+PXNjO2ktLSkKICAgICAgICAgICAgICAgIGFbZXJdW2ldPScqJzsKICAgICAgICAgICAgZXItLTsKICAgICAgICAgICAgfQogICAgICAgICAgICBzcisrOwogICAgICAgICAgICAvL2VyLS07CiAgICAgICAgICAgIGlmKHNjPGVjKXsKICAgICAgICAgICAgZm9yKGludCBpPWVyO2k+PXNyO2ktLSkKICAgICAgICAgICAgICAgIGFbaV1bc2NdPScqJzsKICAgICAgICAgICAgc2MrKzsKICAgICAgICAgICAgfQogICAgICAgICAgICBlYy0tOwogICAgICAgICAgICBlci0tOwogICAgICAgICAgICAvLz1zYysrOwogICAgICAgIH0KICAgICAgICBmb3IoaW50IGk9MDtpPG47aSsrKQogICAgICAgIHsKICAgICAgICAgICAgZm9yKGludCBqPTA7ajxuO2orKykKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgaWYoYVtpXVtqXT09JyonKQogICAgICAgICAgICAgICAgICAgIGNvdXQ8PCIqICI7CiAgICAgICAgICAgICAgICBlbHNlCiAgICAgICAgICAgICAgICAgY291dDw8IiAgIjsKICAgICAgICAgICAgfQogICAgICAgICAgICBjb3V0PDxlbmRsOwogICAgICAgIH0KICAgICAgICBjb3V0PDxlbmRsOwogICAgfQogICAgcmV0dXJuIDA7Cn0=