#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, n, i, j;
  cin >> t;
  string s;
  vector<string> v;
  for (i = 0; i < t; i++) {
    cin >> n;
    cin >> s;
    for (j = 0; j < n; j++) {
      if (s[j] == '8') break;
    }
    if (j < n && j <= n - 11)
      v.push_back("YES");
    else
      v.push_back("NO");
  }
  for (i = 0; i < t; i++) cout << v[i] << endl;
  return 0;
}
