#include <bits/stdc++.h>
using namespace std;
int tele(string str, int l);
int main() {
  int t;
  cin >> t;
  while (t--) {
    int l;
    cin >> l;
    string str;
    cin >> str;
    int x = tele(str, l);
    if (x == 1)
      cout << "YES"
           << "\n";
    if (x == -1)
      cout << "NO"
           << "\n";
  }
  return 0;
}
int tele(string str, int l) {
  int i;
  for (i = 0; i < l; i++) {
    if (str[i] == '8' && (l - i) >= 11) return 1;
  }
  return -1;
}
