#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (int k = 0; k < t; ++k) {
    int n;
    cin >> n;
    string str;
    cin >> str;
    bool f = true;
    for (int i = 0; i + 10 < n; ++i) {
      if (str[i] == '8') {
        cout << "YES" << endl;
        f = false;
        break;
      }
    }
    if (f) {
      cout << "NO" << endl;
    }
  }
  return 0;
}
