#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x;
    string s;
    cin >> x >> s;
    size_t found = s.find("8");
    if (found == string::npos) {
      cout << "NO" << endl;
      continue;
    }
    s.erase(0, found);
    if (s.length() >= 11) {
      cout << "YES" << endl;
      continue;
    } else
      cout << "NO" << endl;
  }
}
