import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;

void main ()
{
	auto tests = readln.strip.to !(int);
	foreach (test; 0..tests)
	{
		auto a = readln.splitter.map !(to !(int)).array;
		auto total = sum (a);
		bool ok = (total % 9 == 0);
		total /= 9;
		ok &= (a.minElement >= total);
		writeln (ok ? "Yes" : "No");
	}
}
