#include <bits/stdc++.h>
using namespace std;
int main() {
  int no_cases;
  cin >> no_cases;
  for (int p = 0; p < no_cases; p++) {
    int ln;
    cin >> ln;
    string num;
    cin >> num;
    if (ln < 8)
      cout << "NO" << endl;
    else {
      int o = num.find('8');
      if (o != (-1) && (ln - o) >= 11)
        cout << "YES" << endl;
      else
        cout << "NO" << endl;
    }
  }
}
