#include <bits/stdc++.h>
using namespace std;
char s[100];
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    bool c = 1;
    scanf("%d%s", &n, s);
    for (int i = 0; i < n; ++i) {
      if (s[i] == '8') {
        c = 0;
        if (n - i > 10)
          cout << "YES";
        else
          cout << "NO";
        break;
      }
    }
    if (c) cout << "NO";
    cout << '\n';
  }
}
