Help me in solving LOGICIAN problem

My issue

t = int(input())
for _ in range(t):
n = int(input())
s = input()

x = 0
for reply in s:
    if int(reply) == 1:
        x += 1

    if x == n and int(reply) == 1:
        print('YES')
    else:
        if int(reply) == 1:
            print('IDK')
        else:
            print('NO')

Please help me with the logic. Dont know where i am going wrong. Also only one sample example is making hard for me.

My code

t = int(input())
for _ in range(t):
    n = int(input())
    s = input()

    x = 0
    for reply in s:
        if int(reply) == 1:
            x += 1

        if x == n and int(reply) == 1:
            print('YES')
        else:
            if int(reply) == 1:
                print('IDK')
            else:
                print('NO')

Problem Link: 3 Logicians Walk into a Bar Practice Coding Problem - CodeChef

@anon59105852
plzz refer my c++ code for better understanding of the logic.
ping me in case u don’t get the logic

#include <iostream>
using namespace std;

int main() {
	// your code goes here
	int t;
	cin>>t;
	while(t--)
	{
	    int n;
	    cin>>n;
	    string s;
	    cin>>s;
	    int ch=0;
	    for(int i=0;i<n-1;i++)
	    {
	        if(s[i]=='1'&&!ch)
	        {
	        cout<<"IDK";
	        }
	        else
	        {
	        cout<<"NO";
	        ch=1;
	        }
	        cout<<endl;
	    }
	    if(ch)
	    cout<<"NO";
	    else
	    {
	        if(s[n-1]=='1')
	        cout<<"YES";
	        else
	        cout<<"NO";
	    }
	    cout<<endl;
	    
	}
	return 0;
}

After one zero comes in string, every answer is “No”.