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