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