/**
 *    author:  Anchord
 *    created: 16.12.2020 10:36:35      
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int tt;
  cin >> tt;
  while (tt--) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    string w = "2020";
    bool possible = false;
    for(int first = 0; first <= 4; first++){
     int second = 4 - first;
     if(s.substr(0, first) + s.substr(n - second) == "2020"){
      possible = true;
     }
    }
    cout << (possible ? "YES" : "NO") << '\n';
  }
  return 0;
}
