Under construction

Still being built. Things may change

Four Vertices of a Cube

Interview

Time limit1sMemory limit1024 MB

Summary
Given T test cases of four distinct indices of a unit cube's vertices, determine whether each set of four points lies on a single face of the cube.
Level

Easy2 of 10

Topics
Implementation, Brute force
Solved
No attempts yet

Problem

Eight points in three-dimensional coordinate space, P_0=(0,0,0)P\_0 = (0,0,0), P_1=(0,0,1)P\_1 = (0,0,1), P_2=(0,1,0)P\_2 = (0,1,0), P_3=(0,1,1)P\_3 = (0,1,1), P_4=(1,0,0)P\_4 = (1,0,0), P_5=(1,0,1)P\_5 = (1,0,1), P_6=(1,1,0)P\_6 = (1,1,0), and P_7=(1,1,1)P\_7 = (1,1,1), are the vertices of a cube SS.

Determine whether four given vertices lie on one face of the cube SS.

Input

The first line contains the number of test cases TT. (1≤T≤2000)( 1 \le T \le 2 000 )

Each of the following TT lines contains four distinct integers aa, bb, cc, and dd, separated by spaces. Each integer is the index of a vertex of the cube SS. (0≤a,b,c,d<8)(0 \le a, b, c, d \lt 8)

Output

For each test case, print one line. Print YES if P_aP\_a, P_bP\_b, P_cP\_c, and P_dP\_d are four vertices on one face of the cube SS. Otherwise, print NO.

Examples1

  1. Example 1

    Input
    2
    5 0 4 1
    1 2 6 5
    
    Expected output
    YES
    NO