import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

void solve() {
    auto N = readln.chomp.to!int;
    auto S = readln.chomp;
    int pos = -1;
    foreach (i; 0..N) if (S[i] == '8') {
        pos = i;
        break;
    }
    if (pos == -1 || N - pos < 11) {
        writeln("NO");
    } else {
        writeln("YES");
    }
}

void main() {
    auto T = readln.chomp.to!int;
    while (T--) solve;
}