#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int numdigits;
  string tel;
  for (int i = 0; i < n; i++) {
    cin >> numdigits;
    cin >> tel;
    int len = 0;
    bool c = 0;
    for (int j = 0; j < numdigits; j++) {
      if (tel[j] == '8') c = 1;
      if (c) {
        len++;
      }
    }
    if (len >= 11) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}
