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