#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 100;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int tc;
  cin >> tc;
  while (tc--) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    bool done = 0;
    for (int i = 0; i < n; i++) {
      if (s[i] == '8') {
        int len = n - i;
        if (len >= 11) {
          cout << "YES" << endl;
        } else {
          cout << "NO" << endl;
        }
        done = true;
        break;
      }
    }
    if (!done) {
      cout << "NO" << endl;
    }
  }
  return 0;
}
