Sneaking Through the Corridor

No attempts yetTime limit5sMemory limit256 MB

Problem

Seunghyun keeps his room under tight security. The only way in runs along a corridor packed with sensors, and a sensor sounds the alarm as soon as a person or an object enters its range.

Hyunseok is a very nimble spy. A client hired him to steal a classified document from Seunghyun's room, so he got hold of the corridor blueprint first. From the blueprint he has to decide whether he can walk in himself, and if he cannot, how small a robot he has to send instead.

Hyunseok treats the corridor as a plane. The two walls are the lines x=0x = 0 and x=wx = w, and sensor ii detects everything inside the circle with center (xi,yi)(x_i, y_i) and radius rir_i. A sensor sits against a wall or in the middle of the corridor. The object that travels down the corridor is a circle as well.

The object starts at y=y = -\infty and has to reach y=+y = +\infty while staying inside the corridor. It must never enter the detection range of a sensor. Touching the boundary of a range is fine.

Given the sensor layout, find the largest radius of a circle that gets through the corridor without setting off an alarm.

Input

The first line has the number of test cases TT. (1T1001 \le T \le 100)

Each test case has this form.

  • One line with the corridor width ww. (1w1000001 \le w \le 100\,000) The two walls are the lines x=0x = 0 and x=wx = w.
  • One line with the number of sensors nn. (0n10000 \le n \le 1\,000)
  • nn lines with integers xx, yy, rr, the center of a sensor and the radius of its range. (0xw0 \le x \le w, 100000y100000-100\,000 \le y \le 100\,000, 1r1000001 \le r \le 100\,000)

The corridor runs forever along yy, and the end the object starts from and the end it leaves through are both far outside every sensor range.

Output

For each test case print on its own line the largest radius of a circular object that passes the corridor undetected. Assume the object moves with unlimited precision. Print 00 when nothing can get through.

Round the answer to six decimal places and always print all six digits after the point. An answer of 1.51.5 prints as 1.500000, and an answer of 00 prints as 0.000000.