#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 1;
map<long long, long long> mp, pm;
deque<long long> v, vc, ve;
deque<char> p, pe;
deque<string> st;
long long a, b, c, d, e, f, cnt, ans, r, n;
float q, t, cnt1;
string g, h, w, o, z, m, s;
char y, u;
vector<pair<long long, long long> > pr, rp;
int main() {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(0);
  cin >> a;
  for (int i = 0; i < a; i++) {
    cin >> b >> g;
    c = b;
    for (int j = 0; j < g.size(); j++) {
      if (g[j] == '8') {
        c = j;
        break;
      }
    }
    if (g.size() - c >= 11)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}
