module cf1167a;
import std.stdio;
import std.string : indexOf, strip;
import std.conv : to;
void main() {
	int n;
	char[] buf;
	readln(buf);
	n = buf.strip.to!int;
	debug writeln(n);
	foreach(i; 0..n) {
		int x;
		readln(buf);
		x = buf.strip.to!int;
		readln(buf);
		immutable eight = buf.indexOf('8');
		debug writeln(eight, " ", x);
		if (eight >= 0 && eight + 11 <= x) {
			writeln("YES");
		}else {
			writeln("NO");
		}
	}
}
