#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cout.precision(10);
  int t, n;
  string s;
  cin >> t;
  while (t--) {
    cin >> n >> s;
    bool b = false;
    for (int i = 0; i < n - 10; ++i) {
      if (s[i] == '8') {
        cout << "YES" << endl;
        b = true;
        break;
      }
    }
    if (!b) cout << "NO" << endl;
  }
  return 0;
}
