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