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