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