#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; ++i) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int flag = 0, pos = -1;
    for (int j = 0; j < n; ++j) {
      if (s[j] == '8') {
        flag = 1;
        pos = j;
        break;
      }
    }
    if (flag == 1 && n - pos - 1 >= 10) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}
