#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  long long t;
  cin >> t;
  while (t--) {
    long long n, p, x, xx = 0;
    cin >> n;
    string s;
    cin >> s;
    for (long long i = 0; i < n; i++) {
      if (s[i] == 56) {
        xx = n - i;
        break;
      }
    }
    if (xx >= 11)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
}
