#include<bits/stdc++.h>
using namespace std;
int main(){
long long int i,j,x,y,z,n,t,m;
cin>>t;
string s,s1,s2,s3,s4;
while(t--){
    cin>>n;
    cin>>s;
    if(n<=4 && s!="2020" )
    cout<<"NO"<<endl;
    else if(s=="2020")
    cout<<"YES"<<endl;
    else{
        s1="";
        s2="2020";
        i=0;
        j=0;
        while(j<s2.length() && i<s.length() && s[i]==s2[j]){
            s1+=s[i];
            i++;
            j++;
        }

        if(s1==s2){
            cout<<"YES"<<endl;
        }else{
            i=n-1;
            j=3;
            s4="";
            z=0;
            string sf,sr;
            while(i>=0 && j>=s1.length() && s[i]==s2[j]){
               s4+=s[i];
               j--;
               i--;
               sf="";
               sr=s4;
               reverse(sr.begin(),sr.end());
               sf+=s1;
               sf+=sr;
               if(sf==s2){
                   cout<<"YES"<<endl;
                   z=1;
                   break;
               }

            }
            if(z==0)
            cout<<"NO"<<endl;
        }
    }

}
}
