#include <bits/stdc++.h>
using namespace std;
void cre(vector<vector<int> > &vv, int n, int idx, vector<int> v, int m) {
  if (m == 0) {
    vv.push_back(v);
    return;
  }
  if (idx == n) {
    if (m == 0) vv.push_back(v);
    return;
  }
  v[idx] = 1;
  cre(vv, n, idx + 1, v, m - 1);
  v[idx] = 0;
  cre(vv, n, idx + 1, v, m);
}
void crefac(vector<vector<int> > &vv, int n, int idx, vector<int> v,
            set<int> s) {
  if (idx == n) {
    vv.push_back(v);
    return;
  }
  for (auto it = s.begin(); it != s.end(); it++) {
    int x = *it;
    v[idx] = x;
    set<int> xx = s;
    xx.erase(x);
    crefac(vv, n, idx + 1, v, xx);
  }
}
long long gcd(long long a, long long b) {
  if (a % b == 0) return b;
  return gcd(b, a % b);
}
long long bsearch(vector<long long> &v, int l, int r, long long val) {
  if (l >= r) return r;
  int mid = (l + r) / 2;
  if (v[mid] > val) {
    return bsearch(v, l, mid, val);
  }
  return bsearch(v, mid + 1, r, val);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    bool isok = false;
    for (int i = 0; i < n; i++) {
      if (s[i] == '8') {
        if (n - i >= 11) {
          isok = true;
          break;
        }
      }
    }
    if (isok) {
      cout << "YES" << endl;
    } else
      cout << "NO" << endl;
  }
  return 0;
}
