#include <bits/stdc++.h>
int main() {
  using namespace std;
  ios_base::sync_with_stdio(false), cin.tie(nullptr);
  int tt;
  cin >> tt;
  while (tt--) {
    int N;
    cin >> N;
    string s;
    cin >> s;
    auto solve = [&](void) -> void {
      for (int i = 0; i < N - 10; ++i) {
        if (s[i] == '8') {
          cout << "YES\n";
          return;
        }
      }
      cout << "NO\n";
    };
    solve();
  }
}
