using System; using System.Collections.Generic; using System.Linq; public struct Point { public double X; public double Y; public Point(Point p) { X = p.X; Y = p.Y; } public Point(int x, int y) { X = x; Y = y; } public Point(double x, double y) { X = x; Y = y; } public static bool operator ==(Point a, Point b) { if ((object)a == null || (object)b == null) { if ((object)a == null && (object)b == null) { return true; } return false; } return (a.X == b.X && a.Y == b.Y); } public static bool operator !=(Point a, Point b) { if ((object)a == null || (object)b == null) { if ((object)a == null && (object)b == null) { return false; } return true; } return (a.X != b.X || a.Y != b.Y); } public static Point operator *(Point a, double i) { return new Point(a.X * i, a.Y * i); } public static Point operator /(Point a, double i) { return new Point(a.X / i, a.Y / i); } //objと自分自身が等価のときはtrueを返す public override bool Equals(object obj) { if (obj == null || GetType() != obj.GetType()) { return false; } Point p = (Point)obj; return (X == p.X && Y == p.Y); } //Equalsがtrueを返すときに同じ値を返す public override int GetHashCode() { int prime = 31; int result = 1; long temp; temp = BitConverter.DoubleToInt64Bits(X); result = prime * result + (int)(temp ^ (temp >> 32)); temp = BitConverter.DoubleToInt64Bits(Y); result = prime * result + (int)(temp ^ (temp >> 32)); return result; } public Point Clone() { return new Point(X, Y); } public void Reverse() { X = -X; Y = -Y; } public static Point operator +(Point a, Point b) { return new Point(a.X + b.X, a.Y + b.Y); } public static Point operator -(Point a, Point b) { return new Point(a.X - b.X, a.Y - b.Y); } public static Point operator +(Point a) { return new Point(+a.X, +a.Y); } public static Point operator -(Point a) { return new Point(-a.X, -a.Y); } // 直線ABと直線CDの交点を求める // onlySegment:trueで線分ABと線分CDの交点を求める public static Point? GetCrossPoint(Point a, Point b, Point c, Point d, bool onlySegment = false) { double delta = (b.X - a.X) * (d.Y - c.Y) - (b.Y - a.Y) * (d.X - c.X); // 平行線 if (delta == 0) { return null; } double u = ((c.X - a.X) * (d.Y - c.Y) - (c.Y - a.Y) * (d.X - c.X)) / delta; double v = ((c.X - a.X) * (b.Y - a.Y) - (c.Y - a.Y) * (b.X - a.X)) / delta; if (onlySegment) { // 線分AB内で交わらない if (u < 0.0 || u > 1.0) { return null; } // 線分CD内で交わらない if (v < 0.0 || v > 1.0) { return null; } } Point cross; cross.X = a.X + u * (b.X - a.X); cross.Y = a.Y + u * (b.Y - a.Y); // 誤差対策 if (a.X == b.X) { cross.X = a.X; } else if (c.X == d.X) { cross.X = c.X; } if (a.Y == b.Y) { cross.Y = a.Y; } else if (c.Y == d.Y) { cross.Y = c.Y; } return cross; } } class Solution { static bool WillPineDecoration(int[] array) { var start = array.Take(3).ToArray(); var grow = array.Skip(3).ToArray(); var line = new Tuple[3]; for (int i = 0; i < 3; i++) { line[i] = new Tuple(new Point(0, start[i]), new Point(1, start[i] + grow[i])); } var time = new List { 0 }; foreach (int i in new int[] { 0, 2 }) { var cross = Point.GetCrossPoint(line[i].Item1, line[i].Item2, line[1].Item1, line[1].Item2); if (cross != null && ((Point)cross).X > 0) { var e = 0.000001; time.Add(((Point)cross).X - e); time.Add(((Point)cross).X + e); } } foreach (var t in time) { var len = Enumerable.Range(0, 3).Select(i => start[i] + grow[i] * t).ToArray(); if (len.Max() == len[1] || len.Min() == len[1]) { if (len[0] != len[1] && len[1] != len[2]) { return true; } } } return false; } static void Main() { var n = int.Parse(Console.ReadLine()); for (int i = 0; i < n; i++) { var array = Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); if (WillPineDecoration(array)) { Console.WriteLine("Yes"); } Console.WriteLine("No"); } } }