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