Can someone please tell where my code goes wrong?

q=int(input())
for i in range(q):
n=int(input())
s=list(input())
t=list(input())
x=y=0
ans=0
while x<n and y<n:
if s[x]==t[y]:
if s[x]==str(1):
ans+=1
x+=1
y+=1
continue
if s[x]==str(1) and t[y]==str(0):
y+=1
continue
if t[y]==str(1) and s[x]==str(0):
x+=1
print(ans)