|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|1 초||256 MB||282||40||18||9.137%|
Sheldon is a physicist who studies high-energy particles movement and reactions. Sheldon developed a brilliant machine, named ICPC (Integrated Cool Particle Capturer) that can capture a single particle in a 2-dimensional rectangle R of size W × H in its hull. After a particle gets captured by ICPC, its movement is limited in the rectangle R while retaining its original speed. More specifically, any particle P captured by ICPC obeys the following rules:
Sheldon is doing his experiments with his machine ICPC. He captured a particle P in ICPC. When he has first observed the particle P, P was located at (x0,y0) in R, moving in direction vector (a,b). Note that the coordinate of a location in the rectangle R is represented by (x,y) with 0 ≤ x ≤ W and 0 ≤ y ≤ H. In the rectangle R, there are two special locations A and B whose coordinates are (x1,y1) and (x2,y2), respectively. Sheldon would like to know which of A and B is first reached by P, or if P does reach neither A nor B. You can help Sheldon by your programming skills.
Given all necessary values variables W, H, x0, y0, x1, y1, x2, y2, a, b your program is to decide one of the three possibilities: P first reaches A before B, P first reaches B before A, or P can reach none of them. To make things simpler, assume that the particle P is very small as just a point. In addition, all the variables W, H, x0, y0, x1, y1, x2, y2, a, b appeared above will be given as integers.
Your program is to read from standard input. The input consists of T test cases. The number of test cases T is given in the first line of the input. Each test case consists of a single line with 10 integers separated by a single space that represent W, H, x0, y0, x1, y1, x2, y2, a, b in order. Each of the 10 integers falls into the following range: 2 ≤ W, H ≤ 1,000,000, 0 < x0 < W, 0 < y0 < H, 0 ≤ x1, x2 ≤ W, 0 ≤ y1, y2 ≤ H, and -10,000 ≤ a, b ≤ 10,000. Also, note that (x0,y0) ≠ (x1,y1), (x0,y0) ≠ (x2,y2), (x1,y1) ≠ (x2,y2), and (a,b) ≠ (0,0).
Your program is to write to standard output. Print exactly one line for each test case. The line should consist only of A if P reaches A before P reaches B, B if P reaches B before P reaches A, or O if P can reach none of A and B forever.
3 5 5 1 3 4 2 2 1 1 1 5 3 1 2 0 2 3 0 3 2 5 3 2 2 2 1 3 2 1 3
A B O