#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, flag = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') flag = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x;
}
string s;
int main() {
  int T = read();
  while (T--) {
    int n = read();
    cin >> s;
    int ans = 0;
    for (int i = 0; i < s.length(); ++i) {
      if (s[i] == '8') {
        ans = s.length() - i;
        break;
      }
    }
    if (ans >= 11)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
