#include <bits/stdc++.h>
using namespace std;
const int N = 10010;
vector<int> vec;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  ;
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    cin.ignore();
    string str;
    getline(cin, str);
    bool flag = false;
    for (int i = n - 11; i >= 0; i--) {
      if (str[i] == '8') {
        flag = true;
        break;
      }
    }
    if (flag == true)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
