#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int a, t, b, c, m, n, ck = 0, ans = 0, sum = 0;
  cin >> t;
  cin.ignore();
  while (t--) {
    ck = 0;
    cin >> a;
    cin.ignore();
    string s;
    cin >> s;
    b = a - 10;
    for (int i = 0; i < b; i++) {
      if (s[i] == '8') {
        ck = 1;
      }
    }
    if (ck == 1) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}
