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