#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1000000007, inf = -1e18;
long long n, i, j, cnt, a[500005], b[500005], t, c, f;
map<string, bool> mp;
vector<pair<long long, long long> > v;
string s;
int main() {
  cin >> t;
  while (t--) {
    cin >> n;
    cin >> s;
    c = 0;
    for (i = 0; i < n; i++) {
      if (s[i] == '8') {
        if (n - i >= 11) {
          c = 1;
          break;
        } else {
          break;
        }
      }
    }
    if (c == 1) {
      cout << "YES" << endl;
    } else
      cout << "NO" << endl;
  }
  return 0;
}
