Getting NZEC Error while submitting Play Piano Problem

flag=0
lst = []
num = int(input(""))
for i in range(0,num):
temp = input("")
#lst.insert(i,temp)
for j in range(0,len(temp),2):
if temp[j] == temp[j+1]:
flag=1
break;

if flag == 1:
    #print("no")
     lst.insert(i,"no")
else:
    #print("yes")
    lst.insert(i,"yes")

for i in lst:
print(i

//