#include <bits/stdc++.h>
using namespace std;
int main() {
  int tc;
  cin >> tc;
  while (tc--) {
    int i, s;
    cin >> s;
    char str[s];
    cin >> str;
    for (i = 0; str[i] != '8' && str[i]; i++)
      ;
    if (i + 10 < s)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
  return 0;
}
