#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    string arr;
    cin >> arr;
    int count = n;
    for (int i = 0; i < n; i++) {
      if (arr[i] == '8') {
        count = i;
        break;
      }
    }
    n - count >= 11 ? cout << "YES\n" : cout << "NO\n";
  }
  return 0;
}
