#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    bool fa = 0;
    cin >> n;
    string a;
    cin >> a;
    int l = a.size();
    for (int j = 0; j < l; j++) {
      if (a[j] == '8' && l - j >= 11) {
        fa = 1;
        break;
      }
    }
    if (fa) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}
