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