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