import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.random;

void main() {
  int nt = readln.strip.to!int;
  foreach (tid; 0 .. nt) {
    int n = readln.strip.to!int;
    auto s = readln.take (n).array;
    auto res = "NO";
    foreach (i; 0 .. n) {
      if (s[i] == '8' && (n - 1) - i >= 10) {
        res = "YES";
        break;
      }
    }
    writeln (res);
  }
}

