#include <bits/stdc++.h>
using namespace std;
const long long N = 1e6 + 10;
const long long mod = 1e9 + 7;
const long long INF = 1e18 + 10;
int main() {
  long long n, m, i;
  string s;
  cin >> n;
  while (n--) {
    cin >> m >> s;
    if (s.size() < 11)
      cout << "NO\n";
    else {
      for (i = 0; i < s.size(); ++i) {
        if (s[i] == '8') break;
      }
      if (i == s.size())
        cout << "NO\n";
      else {
        if (s.size() - i >= 11)
          cout << "YES\n";
        else
          cout << "NO\n";
      }
    }
  }
}
