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