#include <bits/stdc++.h>
using namespace std;


int main() {
	
	int t;
	cin >> t;
	while(t--){
		int n;
		cin >> n;
		string arr;
		cin >> arr;
		string check="2020";
		int length=0;
		int i=0;
		for(i=0;i<4;i++) {
			if(arr[i]==check[i]) {
				length++;
			}else {
				break;
			}
		}
		int a = 3;
		for(int j=n-1;j>=0;j--) {
			if(length==4) break;
			if(arr[j]==check[a]) {
				length++;
				a--;
			}else {
				break;
			}
		}
		if(length==4) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	return 0;
}