- Prepare
- Mathematics
- Geometry
- Spheres

# Spheres

# Spheres

Initially, two non-touching spheres of radii *R1* and *R2* are lying in space at rest. Both of them are then given accelerations *a1* and *a2* respectively at time=0. Find whether they will ever come in contact. Their initial positions are represented as *(x1,y1,z1)* and *(x2,y2,z2)* respectively. Accelerations have respective components in 3D. They are represented as *(a1 _{i},a1_{j},a1_{k})* and

*(a2*respectively.

_{i},a2_{j},a2_{k})**Input Format**

The first line contains *T*, the number of test cases.

Each test case consists of five lines, where the first line contains *R1* and *R2*. The next two lines contain position and acceleration of the first sphere. The next two lines after this contain position and acceleration of the second sphere. All numbers in input are integers.

**Output Format**

For each test case, print `YES`

, if the spheres come in contact. Otherwise, print `NO`

(quotes for clarity).

**Constraints**

1 ≤ *T* ≤ 10^{4}

1 ≤ *R1*, *R2* ≤ 10^{2}

-10^{2} ≤ *x1*, *y1*, *z1* , *x2* , *y2* , *z2* ≤ 10^{2}

-10^{2} ≤ *a1 _{i}* ,

*a1*,

_{j}*a1*,

_{k}*a2*,

_{i}*a2*,

_{j}*a2*≤ 10

_{k}^{2}

**Sample input**

```
2
1 2
0 0 0
-1 0 0
4 0 0
1 0 0
1 2
0 0 0
100 0 0
4 0 0
0 0 0
```

**Sample output**

```
NO
YES
```

**Explanation**

For first testcase, both spheres go in opposite directions, so they'll never come in contact.

For second testcase, second sphere is not moving while first sphere is accelerating towards the second sphere. So they come in contact.