#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int i = 0;
    for (; i < s.length(); i++)
      if (s[i] == '8') break;
    if (s.length() - i >= 11)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
}
