A tennis tournament is about to take place with $N$ players participating in it.
Every player plays with every other player exactly once and there are no ties. That is, every match has a winner and a loser. 
With Naman's birthday approaching, he wants to make sure that each player wins the same number of matches so that nobody gets disheartened.  
Your task is to determine if such a scenario can take place and if yes find one such scenario.

-----Input:-----
- First line will contain $T$, number of testcases. Then the testcases follow. 
- Each testcase contains of a single integer $N$ denoting number of players.

-----Output:-----
- If it's impossible for everyone to win the same number of matches, print "NO" (without quotes).
- Otherwise print "YES" (without quotes) and then print $N$ lines , each line should consist of a string containing only 0s and 1s and should be of size $N$. 
- If the jth character in the ith line is 1 then it means in the match between $i$ and $j$ , $i$ wins. 
- You will get a WA if the output does not correspond to a valid tournament, or if the constraints are not satisfied.
- You will get also WA verdict if any 2 lines have contradicting results or if a player beats himself.

-----Constraints-----
- $1 \leq T \leq 100$
- $2 \leq N \leq 100$

-----Subtasks-----
- 10 points : $2 \leq N \leq 6$
- 90 points :  Original Constraints. 

-----Sample Input:-----
2
3
2

-----Sample Output:-----
YES
010
001
100
NO

-----Explanation:-----
One such scenario for $N$ = $3$ is when player $1$ beats player $2$, player $2$ to beats player $3$ and player $3$ beats player $1$. Here all players win exactly $1$ match.

Starter code:

Solutions:
# cook your dish here
a = int(input())
for i in range(a):
 n = int(input())
 if n%2==0:
  print('NO')
 else:
  print('YES')
  for i1 in range(n):
   li = [0]*n
   b = str()
   for i2 in range((n-1)//2):
    li[(i1+i2+1)%n]+=1
   for i3 in range(len(li)):
    b+=str(li[i3])
   print(b)

# cook your dish here

def calc(n) :
 a = n * (n-1)
 a = int(a/2)
 return a

t = int(input())
tt = 0
while tt < t :
 tt = tt + 1
 n = int(input())
 num = calc(n)
 if num%n != 0 :
  print("NO")
 else :
  win = int(num/n)
  print("YES")
  i = 0
  while i < n :
   i = i + 1
   j = i
   str = ""
   k = 0
   while k < n :
    str = str + "0"
    k = k + 1
   k = 0
   while k < win :
    if (j+k)%n==0 :
     str = '1' + str[1:n]
    elif (j+k)%n==(n-1) :
     str = str[:n-1] + "1"
    else :
     kkk = (j+k)%n
     str = str[0:kkk] + "1" + str[kkk+1:]
    k = k + 1
   print(str) 
    
    
    
    
    
    
    
    
    
    
    


T = int(input())
for _ in range(T):
 n = int(input())
 if n%2 == 0:
  print("NO")
 else:
  print("YES")
  count = 0
  for _ in range(n):
   count += 1
   d = [0 for _ in range(n)]
   z = int((n - 1)/2)
   for i in range(z):
    if count + i< n-1:
     d[count + i] = 1
    else:
     d[count + i - n] = 1
   for i in d:
    print(i, end="")
   print()

t=int(input())
for i in range(t):
 n=int(input())
 if (n%2==0 or n==1):
  print("NO")
  continue
 else:
  print("YES")
  p=int((n-1)/2)
  for j in range(n):
   c=p+j-n+1
   for k in range(n):
    if ((j+p)>=n and c>=1):
     print("1", end="")
     c=c-1
    elif (k>=(j+1) and k<=(j+p)):
     print("1", end="")
    else:
     print("0", end="")
   print("\n", end="")



try:
 n = int(input())
 for _ in range(n):
  case = int(input())
  if(case%2==0):
   print("NO")
  else:
   print("YES")
   for i in range((case//2)+1):
    arr = [0]*case
    for j in range(i+1, (case//2)+i+1):
     arr[j] = 1
    print(*arr, sep="")
   for i in range(case//2):
    arr = [0]*case
    for j in range(i+1):
     arr[j] = 1
    for k in range(1, (case//2)-i):
     arr[-k] = 1
    print(*arr, sep="")
except EOFError:
 pass


# cook your dish here
t = int(input())

for e in range(t):
 n = int(input())

 if n % 2 == 0:
  print("NO")
 else:
  print("YES")

  total = 0
  for g in range(n):
   total += g
  num = total // n
  
  for i in range(n):
   l = [0] * n
   for j in range(i+1, i+1+num):
    try:
     l[j] = 1
    except IndexError:
     k = j - n
     l[k] = 1
   for b in range(len(l)):
    print(l[b], end = "")
    
   print()


try:
 for _ in range(int(input())):
  n=int(input())
  if n%2==0:
   print("NO")
  else:
   z=int(((n-1)/2))
   print("YES")
   for i in range(n):
    cnt=0
    N=[]
    while cnt<z:
     N.append((i+1+cnt)%n)
     cnt+=1
    for j in range(n):
     if j in N:
      print(1,end="")
     else:
      print(0,end="")
    print()
  
except EOFError:
 pass

for _ in range(int(input())):
 n = int(input())
 if (n-1)%2 != 0:
  print("NO")
 else:
  print("YES")
  b = [0]*n
  for i in range((n-1)//2):
   b[i+1] = 1
  print(*b,sep="")
  for j in range(n-1,0,-1):
   print(*(b[j:]+b[:j]),sep="")

arr = [[0 for i in range(101)] for i in range(101)]
for i in range(1,100):
 k = 0
 for j in range(i+1,101):
  arr[i][j] = k
  k = 1-k
  arr[j][i] = k

t = int(input())
while t:
 n = int(input())
 if n%2==0:
  print("NO")
 else:
  print("YES")
  a = [arr[i][-n:] for i in range(-n,0)]
  for i in range(0,n):
   print(*a[i],sep='')
 t -= 1

# cook your dish here

arr = [[0 for i in range(101)] for i in range(101)]
for i in range(1,100):
 k = 0
 for j in range(i+1,101):
  arr[i][j] = k
  k = 1-k
  arr[j][i] = k

t = int(input())
while t:
 n = int(input())
 if n%2==0:
  print("NO")
 else:
  print("YES")
  a = [arr[i][-n:] for i in range(-n,0)]
  for i in range(0,n):
   print(*a[i],sep='')
 t -= 1
 


# cook your dish here

arr = [[0 for i in range(101)] for i in range(101)]
for i in range(1,100):
 k = 0
 for j in range(i+1,101):
  arr[i][j] = k
  k = 1-k
  arr[j][i] = k

t = int(input())
while t:
 n = int(input())
 if n%2==0:
  print("NO")
 else:
  print("YES")
  a = [arr[i][-n:] for i in range(-n,0)]
  for i in range(0,n):
   print(*a[i],sep='')
 t -= 1
 


# cook your dish here
t=int(input())
for s in range(t):
 n=int(input())
 if(n%2==0):
  print('NO')
 else:
  print('YES')
  a=[[0 for i in range(n)]for i in range(n)]
  i=0
  j=1
  k=1
  while(k<n):
   i=0
   j=k
   while(i<n and j<n):
    a[i][j]=1
    i+=1
    j+=1
   k+=2
  i=1
  j=0
  k=1
  while(k<n):
   i=k
   j=0
   while(i<n and j<n):
    if(a[j][i]==0):
     a[i][j]=1
    i+=1
    j+=1
   k+=1
  for i in range(n):
   for item in a[i]:
    print(item,end="")
   print(" ")

for t in range(int(input())):
 n=int(input())
 a=n*(n-1)/2
 if a%n==0:
  print("YES")
  r=int(a/n)
  rem = n-r-1
  l ='0'+'1'*r+'0'*rem
  for u in range(n):
   print(l)
   l = l[-1]+l[:-1]
 else:
  print("NO")
 



















t=int(input())
for i in range(t):
 N=int(input())
 L=[0]*N
 if N%2==1:
  print("YES")
  for i in range(0,N):
   for k in range(1,int((N+1)/2)):
    L[(i+k)%N]=1
   for m in L:
    print(m,sep="",end="")
   print("")
   L=[0]*N
 else:
  print("NO")






# cook your dish here
t=int(input())
for i in range(t):
 N=int(input())
 L=[]
 for j in range(N):
  L.append(0)
 if N%2==1:
  print("YES")
  for i in range(0,N):
   for k in range(1,int((N+1)/2)):
    L[(i+k)%N]=1 
   for m in L:
    print(m,sep="",end="")
   print("")
   L=[]
   for j in range(N):
    L.append(0)
 else:
  print("NO")
 
 

# cook your dish here
t=int(input());
for i in range(t):
 n=int(input());
 j=n-1;
 if(j%2!=0):
  print("NO");
 else:
  print("YES");
  for i in range(1,n+1):
   k=1;
   for j in range(1,n+1):
    if(i!=j):
     if(i%2!=0):
      if(k%2!=0):
       print("1",end="");
       k+=1;
      else:
       print("0",end="");
       k+=1;
     else:
      if(k%2==0):
       print("1",end="");
       k+=1;
      else:
       print("0",end="");
       k+=1;
    else:
     print("0" , end = "")
   print();

# cook your dish here
t=int(input())
for _ in range(t):
 n=int(input())
 # A=list(map(int,input().split()))
 a=(n-1)//2
  
 if n%2==0:
  print("NO")
 else:
  print("YES")
  for i in range(n-a):
   print("0"*(i+1)+"1"*a+"0"*(n-i-1-a))
  for i in range(a):
   print("1"*(i+1)+"0"*(n-a)+"1"*(a-i-1))


for _ in range(int(input())):
 n=int(input())
 if(n%2==0):
  print("NO")
 else:
  print("YES")
  for i in range(n):
   l=["0"]*n
   for j in range(i,i+n//2):

    l[((j+1)%n)]="1"
   print("".join(l))

# cook your dish here
t=int(input())
while t>0:
 n=int(input())
 if(n%2!=0):
  print("YES")
  k=n//2
  a=[['0' for _ in range(n)] for _ in range(n)]
  for i in range(n):
   d=0
   for j in range(i+1,n):
    a[i][j]="1"
    d+=1
    if(d==k):
     break
   if(d<k):
    for j in range(k-d):
     a[i][j]="1"
  for u in range(n):
   for p in range(n):
    print(a[u][p],end="")
   print()
 else:
  print("NO")
 t-=1

t=int(input())
for i in range(0,t):
 n=int(input())
 if n%2==0:
  print("NO")
 else:
  print("YES")
  s="0"
  for j in range(0,n//2):
   s+="1"
  for j in range(0,n-(n//2 +1)):
   s+="0"
  for j in range(0,n):
   print(s)
   c=s[n-1]
   s=s[0:n-1]
   s=c+s


# cook your dish here
t = int(input())
for _ in range(t):
 n = int(input())
 
 total = round((n * (n -1)) / 2)
 if total % n == 0:
  print("YES")
  win = round(total / n)
  matches = [['0']*n for _ in range(n)]
  
  s_pos = 1
  for r in range(n):
   c_pos = s_pos
   for c in range(win):
    #print(f'Row : {r}, Col : {c_pos}')
    matches[r][c_pos] = '1'
    #print(matches[r][c_pos])
    #print(matches)
    c_pos = (c_pos + 1) % n
   
   s_pos = (s_pos + 1) % n
  
  for itr in matches:
   print(''.join(itr))
 else:
  print("NO")
  


# cook your dish here
for t in range(int(input())):
 n=int(input())
 if(n%2==0):
  print("NO")
 else:
  print("YES")
  n1=n//2
  for i in range(n):
   s=['0']*n
   c=0
   for j in range(i+1,n):
    s[j]='1'
    c+=1 
    if(c==n1):
     break
   if(c<n1):
    for j in range(n1-c):
     s[j]='1'
   k=''.join(s)
   print(k)
   


import math
from collections import deque, defaultdict
from sys import stdin, stdout
input = stdin.readline
# print = stdout.write
listin = lambda : list(map(int, input().split()))
mapin = lambda : list(map(int, input().split()))
for _ in range(int(input())):
 n = int(input())
 n1 = (n*(n-1))//2
 if n1%n:
  print("NO")
 else:
  print("YES")
  x = [0]
  for i in range(n1//n):
   x.append(1)
  for i in range(n1//n):
   x.append(0)
  for i in range(n):
   print("".join(map(str, x)))
   x = [x[-1]]+x[:-1]

# cook your dish here
t=int(input())
for i in range(t):
 n=int(input())
 if n%2==0:
  print("NO")
 else:
  print("YES")
  s=''
  s=s+'0'
  for j in range(n//2):
   s+='1'
  for j in range(n//2+1,n):
   s+='0'
  print(s)
  k=n-1
  for j in range(n-1):
   s1=s[0:len(s)-1]
   s2=s[len(s)-1:]
   s=s2+s1
   print(s)
  


for _ in range(int(input())):
 n=int(input())
 if n%2==0:
  print("NO")
 else:
  d={}
  k=(n)*(n-1)//2
  r=k//n
  # print(r)
  l=[[0 for i in range(n)] for j in range(n)]
  # print(l)
  for i in range(1,n):
   #print(d.get(i,0))
   for j in range(i+1,n+1):
    if d.get(i,0)<r:
     l[i-1][j-1]=1
     d[i]=d.get(i,0)+1
    else:
     l[j-1][i-1]=1
     d[j]=d.get(j,0)+1
  print("YES")
  for i in range(n):
   for j in range(n):
    print(l[i][j],end="")
   print()