Problem on EXUNB

the problem says "Your task is to determine if such a scenario can take place and if yes find one such scenario."Except for n=2, all the cases have at least one condition in which each of them win same number of matches, that is 1 wins 2, 2 wins 3 , and so on upto n, and n wins 1. i.e., every team wins only one match of all they played.However my solution giving the same result is marked wrong.Here is my python code finally subbmitted:
########################
for t in range(int(input())):
n=int(input())
if n==2:
print(“NO”)
continue
print(“YES”)
for i in range(n):
l=[0]*n
l[(i+1)%n]=1
print(*l,sep=’’)
########################