#include <bits/stdc++.h>
using namespace std;
const double PI = 3.14159265358979323846;
void solve() {
  long long n, m, a, b, k, x, y, queries;
  string s;
  cin >> n >> s;
  s = 'G' + s;
  long long i = 1;
  while (i <= n) {
    if (s[i] == '8') break;
    i++;
  }
  if (i + 10 <= n)
    cout << "YES";
  else
    cout << "NO";
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long t;
  cin >> t;
  while (t--) {
    solve();
    cout << endl;
  }
  return 0;
}
