The chef is trying to solve some pattern problems, Chef wants your help to code it. Chef has one number K to form a new pattern. Help the chef to code this pattern problem.

-----Input:-----
- First-line will contain $T$, the number of test cases. Then the test cases follow. 
- Each test case contains a single line of input, one integer $K$. 

-----Output:-----
For each test case, output as the pattern.

-----Constraints-----
- $1 \leq T \leq 50$
- $1 \leq K \leq 50$

-----Sample Input:-----
5
1
2
3
4
5

-----Sample Output:-----
*
*
***
*
* *
*****
*
* *
*   *
*******
*
* *
*   *
*     *
*********   

-----EXPLANATION:-----
No need, else pattern can be decode easily.

Difficulty: interview

Starter code:

Solutions:
from sys import stdin, stdout
from collections import Counter
n = int(stdin.readline())
#l = list(map(int, stdin.readline().split()))
#l = [int(stdin.readline()) for _ in range(n)]
#a, b = map(int, stdin.readline().split())
for _ in range(n):
    n1 = int(stdin.readline())
    if n1==1:
        print('*')
    else:
        a = n1+(n1-1)
        s = 0
        for x in range(1,n1):
            if x==1:
                print(' '*(n1-1)+'*'+' '*(n1-1))
                s+=1
            else:
                print(' '*(n1-x)+'*'+' '*(s)+'*')
                s+=2
            #print()
        print('*'*(a))
    


for _ in range(int(input())):
    n=int(input())
    if n==1:
        print('*')
        print()
        continue
    for i in range(n-1):
        if i==0:
            for j in range(2*n-1):
                if j==n-1:
                    print('*',end='')
                else:
                    print(end=' ')
            print()
            print()
            continue
        for j in range(2*n-1):
            if(j==n-1-i or j==n-1+i):
                print('*',end='')
            else:
                print(end=' ')
        print()
        print()
    for j in range(2*n-1):
        print('*',end='')
    print()
    print()

testcases=int(input())
for i in range(testcases):
    n=int(input())
    j=n-1
    space=-1
    for i in range(1, n):
        print(' '*j, end="")
        print("*", end="")
        print(" "*(2*space+1), end="")
        if(i!=1):
            print("*", end="")
        j-=1
        space+=1
        print()
    print("*"*(2*n-1), end="")
    print()

def fxn(n):
    k=2*n-1
    half=k//2
    print(half*" "+"*")
    if n==1:
        return 
    for i in range(2,n):
        j=2*i-1
        p=j-2
        r=j//2
        d=half-r
        print(d*" "+"*"+" "*p+"*")
    print(k*"*")
        





t=int(input())
for i in range(t):
    n=int(input())
    fxn(n)

# cook your dish here
for k in range(int(input())):
	n = int(input())
	ans = "*"*(2*n-1)
	ar = [ans]
	l = 1
	m = 2*n - 5
	for p in range(n-2):
		ar.append(" "*l + "*" + " "*m + "*" + " "*l)
		l += 1
		m -= 2
	if n != 1: ar.append(" "*l + "*")
	ar = ar[::-1]
	for p in ar:
		print(p)

# cook your dish here
t = int(input())
while t>0:
    k = int(input())
    for i in range(0, k-1):
        print(' '*(k-i-1), end="")
        print('*', end="")
        if(i!=0):
            print(' '*(2*i-1), end="")
            print('*',end="")
        print('\r')
    print('*'*(2*k-1))
    t-=1

# cook your dish here

for _ in range(int(input())):
    k=int(input())
    if k==1:
        print("*")
        continue
    for i in range(k):
        for j in range(2*(k-1)):
            if i==0:
                print(" "*(k-2),end=" ")
                print("*",end="")
                break
            elif i==k-1:
                print("*"*(2*k-1))
                break
            if j==k-i-1 or j==k+i-1:
                print("*",end="")
            else:
                print(end=" ")
        print()

t=int(input())
for i in range(0,t):
    n = int(input())
    for i in range(n):
        for a in range(n-i-1):
            print(' ',end="")
        for j in range(2*(i+1)-1):
            if j == 0 or j == 2*i:
                print('*',end="")
            elif i == n-1:
                print('*',end="")
            else:
                print(' ',end="")
        print()

def printPattern(n) : 
    for i in range(1,n+1):
        for j in range(1,n-i+1):
            print(" ",end='')
        if (i==1 or i==n):
            for j in range(1,i*2):
                print("*",end='')
        else:
            for j in range(1,i*2):
                if (j==1 or j==i*2-1):
                    print("*",end='')
                else:
                    print(" ",end='')
        print()

t = int(input())

for _ in range(t):
    printPattern(int(input()))

for _ in range(int(input())):
    k = int(input())
    if k == 1:
        print("*")
    else:
        for a in range(k-1):
            print(" ", end = "")
        print("*")
        i = 2
        temp = k
        while(i<k):
            for m in range(temp - i):
                print(" ", end = "")
            print("*", end = "")
            for j in range(i+i-3):
                print(" ", end = "")
            print("*")
            i = i+1
            
        for i in range(2*k-1):
            print("*",end = "")
        print("\r")
                
            

t = int(input())
numbers = list()

for _ in range(t):
    numbers.append(int(input()))

for n in numbers:
    for i in range(1, n):
        print(" "*(n-i), end="")
        for j in range(1, i+1):
            if i==1 or j==1 or j==i or i==n:
                print("* ", end="")
            else:
                print("  ", end="")
        print()
    print("*" * (2*n - 1))
    

t = int(input())
while(t):
    n = int(input())
    for i in range(1,n+1):
        if(i==n):
            print("*" * (2*i-1), end = "")
            print()
            continue
        if(i==1):
            print(" "* (n-1), end = "")
            print("*", end = "")
            print()
            continue
        for j in range(n-i):
            print(" ", end = "")
        print("*" +  " "*(2*i-3) + "*", end = "")
        print()
    
    t -= 1

# cook your dish here
t = int(input())
for _ in range(t):
    row = int(input())
    for i in range(row):
        for j in range(row-i):
            print(' ', end='')
        for j in range(2*i+1):
            if j==0 or j==2*i or i==row-1:
                print('*',end='')
            else:
                print(' ', end='')
        print()

# cook your dish here
t = int(input())
for _ in range(t):
    row = int(input())
    for i in range(row):
        for j in range(row-i):
            print(' ', end='')
        for j in range(2*i+1):
            if j==0 or j==2*i or i==row-1:
                print('*',end='')
            else:
                print(' ', end='')
        print()

# cook your dish here
t=int(input())
for _ in range(t):
    a=int(input())
    if(a==1):
        print('*')
    else:
        print(' '*(a-1),end="")
        print('*')
        j=1
        for i in range(2,a):
            print(' '*(a-i),end="")
            print('*',end="")
            print(' '*((2*(j))-1),end="")
            print('*',end="")
            print()
            j+=1
        print('*'*(2*a-1))
                


for _ in range(int(input())):
    n=int(input())
    if n==1:
        print('*')
        print()
        continue
    for i in range(n-1):
        if i==0:
            for j in range(2*n-1):
                if j==n-1:
                    print('*',end='')
                else:
                    print(end=' ')
            print()
            print()
            continue
        for j in range(2*n-1):
            if(j==n-1-i or j==n-1+i):
                print('*',end='')
            else:
                print(end=' ')
        print()
        print()
    for j in range(2*n-1):
        print('*',end='')
    print()
    print()

try:
    t=int(input())
    for _ in range(t):
        n=int(input())
        i=1
        while(i<=n):
            j=i
            while(j<=n-1):
                print(" ",end="")
                j+=1
            print("*",end="")
            if i>1 and i<n:
                for j in range((i-1)*2-1):
                    print(" ",end="")
                print("*",end="")
            if(i==n):
                for j in range(2*(i-1)):
                    print("*",end="")
            print()
            
            i+=1
except EOFError:
    pass

def solve(n):
    if n == 1:
        print('*')
        return
    for i in range(1, n + 1):
        s = n - i
        p = '*'
        if 1 < i < n:
            m = 2 * i - 3
            p = p.ljust(m + 1)
            p += '*'
        elif i == n:
            t = 2 * i - 1
            p = p * t
        p = p.rjust(s + len(p))
        print(p)
def main():
    t = int(input())
    for i in range(t):
        n = int(input())
        solve(n)
main()


t = int(input())
for _ in range(t):
    k = int(input())
    for i in range(k):
        for j in range(2*k-1):
            if i<k-1:
                
                if i+j < k-1:
                    print(' ',end='')
                elif i+j == k-1:
                    print('*',end = '')
                elif i+j > k-1 and i+j < k-1 + (2*i):
                    print(' ',end='')
                elif i+j == k-1+(2*i):
                    print('*',end='')
            else:
                print('*',end='')
        print()


# cook your dish here
for u in range(int(input())):
    n = int(input())
    for i in range(n):
        for space in range(n-i-1):
            print(' ',end="")
        for j in range(2*(i+1)-1):
            if j == 0 or j == 2*i:
                print('*',end="")
            elif i == n-1:
                print('*',end="")
            else:
                print(' ',end="")
        print()

for _ in range(int(input())):
	n = int(input())
	for i in range(n):
	    for j in range(n-i):
	        print(' ', end='')
	    for j in range(2*i+1):
	        if j==0 or j==2*i or i==n-1:
	            print('*',end='')
	        else:
	            print(' ', end='')
	    print()

# cook your dish here
T=int(input())
for i in range(T):
    K=int(input())
    if K==1:
        print("*")
    else:
        print("*")
        L=K-1
        while(L>0):
            i=1
            if L==1:
                print("*"*(2*K-1))
            else:
                print("*"+" "*i+"*")
                i+=2
            L=L-1


for _ in range(int(input())):
    K = int(input())
    if K == 1:
        print('*')
    elif K == 2:
        print(" * ")
        print("***")
    else:
        a = K - 1
        s = K - 2
        print(" "*(s+1) + "*")
        for i in range(1, K-1):
            print(" "*s + "*" + " "*((a-s)*2-1) +  "*")
            s -= 1
        print("*" * (K*2-1))