#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    string str;
    cin >> str;
    bool flag = 0;
    int cnt = 0;
    for (int i = 0; i < n; i++) {
      if (flag) {
        cnt++;
      }
      if (str[i] == '8') {
        flag = 1;
      }
    }
    if (cnt >= 10) {
      cout << "YES\n";
    } else {
      cout << "NO\n";
    }
  }
}
