#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
#define double long double
using namespace std;
const ll inf = 1000000000000000000;

ll t, n, uc1, uc2, kol;
string s, obr = "2020";

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> t;
    for (ll o = 1; o <= t; ++o) {
        cin >> n;
        cin >> s;
        if (s == "2020") {
            cout << "YES\n";
            continue;
        }
        kol = 0;
        uc1 = 0;
        while (uc1 < 4 && s[uc1] == obr[uc1]) {
            ++kol;
            ++uc1;
        }
        uc2 = n - 1;
        while (uc2 >= 0 && s[uc2] == obr[4 - (n - uc2)]) {
            --uc2;
            ++kol;
        }
        if (kol < 4)
            cout << "NO";
        else
            cout << "YES";
        cout << endl;
    }
    return 0;
}
