#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int t, n;
  cin >> t;
  int temp;
  while (t--) {
    cin >> n;
    cin >> s;
    if (n < 11) {
      cout << "NO" << endl;
      continue;
    }
    if (n == 11) {
      if (s[0] != '8')
        cout << "NO" << endl;
      else
        cout << "YES" << endl;
      continue;
    }
    int f = 0;
    for (int x = 0; x < n; x++) {
      if (s[x] == '8') {
        if (n - x >= 11) {
          f = 1;
          cout << "YES" << endl;
          break;
        }
      }
    }
    if (f == 0) cout << "NO" << endl;
  }
}
