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