#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m, i, j, len, temp = 0;
  string s;
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> len;
    cin >> s;
    if (len > 11) {
      temp = 0;
      j = 0;
      while (j <= len - 11) {
        if (s[j] == '8') {
          temp = 1;
        }
        j++;
      }
      if (temp == 1)
        cout << "YES" << endl;
      else
        cout << "NO" << endl;
    } else if (len < 11) {
      cout << "NO" << endl;
    } else {
      if (s[0] == '8')
        cout << "YES" << endl;
      else
        cout << "NO" << endl;
    }
  }
}
