#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e10;
const long long MAXN = 1e8;
const double pi = acos(-1);
long long binpow(long long a, long long n) {
  long long res = 1;
  while (n) {
    if (n & 1) res *= a;
    a *= a;
    n >>= 1;
  }
  return res;
}
long long n, i, x, l, r, j;
string s;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> x;
    cin >> s;
    l = -1;
    r = s.size();
    for (j = 0; j < s.size(); j++) {
      if (s[j] == '8') {
        l = j;
        break;
      }
    }
    if (r - l >= 11 and l != -1)
      cout << "YES" << endl;
    else {
      cout << "NO" << endl;
    }
  }
  return 0;
}
