import java.util.Scanner; public class Main { public static int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); } public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); while (n-- > 0) { int x = in.nextInt(); int y = in.nextInt(); int a = in.nextInt(); int b = in.nextInt(); int c = in.nextInt(); int d = in.nextInt(); int gcd = gcd(a, b); if (y % gcd != 0) a = 0; gcd = gcd(c, d); if (x % gcd != 0) a = 0; if (a == 0) System.out.println("NO"); else System.out.println("YES"); } in.close(); } }