#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
int main() {
  ios_base::sync_with_stdio(false);
  int T;
  cin >> T;
  while (T--) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    while (!s.empty() && s.back() != '8') s.pop_back();
    reverse(s.begin(), s.end());
    while (s.size() > 11) s.pop_back();
    if (s.size() == 11)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
  return 0;
}
