#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 * 1 + 2, inf = 1e9 + 5;
int t;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> t;
  for (int n; t > 0; t--) {
    string s;
    cin >> n >> s;
    int i = 0;
    for (; i < n; i++)
      if (s[i] == '8') break;
    (i <= n - 11) ? cout << "YES" : cout << "NO";
    cout << endl;
  }
  return 0;
}
