import std.algorithm, std.array, std.container, std.conv, std.math, std.range, std.stdio, std.typecons; void main() { auto Q = readln[0 .. $-1].to!uint; bool[] ans; foreach (q; 0 .. Q) { auto I = readln[0 .. $-1].to!long; auto tmp1 = readln.split.to!(long[]), tmp2 = readln.split.to!(long[]); auto A1 = tmp1[0], B1 = tmp1[1], X1 = tmp1[2], Y1 = tmp1[3]; auto A2 = tmp2[0], B2 = tmp2[1], X2 = tmp2[2], Y2 = tmp2[3]; ans ~= A1*X1 + B1*Y1 <= I && A2*X2 + B2*Y2 <= I && (I - A1*X1) <= B1*Y1 && (I - A2*X2) <= B2*Y2; } foreach (a; ans) { writeln(a ? "Yes" : "No"); } }