#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    if (n < 11) {
      cout << "NO\n";
      continue;
    }
    int ind = -1, i = 0;
    while (i < n && s[i] != '8') i++;
    if (n - i >= 11)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
}
