#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int tt, n;
  cin >> tt;
  while (tt--) {
    int count = 0, flag = 0;
    string s;
    cin >> n;
    cin >> s;
    for (int i = 0; i < n; ++i) {
      if (s[i] == '8') {
        count = i;
        flag = 1;
        break;
      }
    }
    if (n - count >= 11 && flag == 1)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
  return 0;
}
