This page is still under construction.

Parts of this page are still being built. What you see may change.

Attack of the Giant n-pus

Interview

Time limit1sMemory limit128 MB

Summary
Assign p pirates to n tentacles so the captain can reach the head as early as possible; each pirate pins one tentacle, the captain starts when all are pinned.
Level

Medium7 of 10

Topics
Binary search, Greedy, Sorting, Math
Solved
No attempts yet

Problem

A pirate ship is under attack by a giant n-pus — a creature like an octopus, but with nn tentacles. Its nn tentacles and its head have punched through the deck and are tearing the ship apart. To stop it, the captain charges at the head, but a tentacle instantly knocks him back: he cannot reach the head while the tentacles can move freely.

The captain is not alone. There are pp pirates (p≥np \ge n) scattered across the deck, ready to follow his orders. His plan: send one pirate to pin down each tentacle. The captain will start moving toward the head only once every tentacle is being held by a pirate, and the instant he reaches the head the creature dies.

Each pirate and the captain travel in a straight line to their target at their own constant speed, unobstructed by anyone or anything. A tentacle counts as pinned the moment its assigned pirate reaches it, and the captain may start moving as soon as the last tentacle is pinned.

Assign the pirates to the tentacles so the captain kills the n-pus as early as possible, and report that earliest time.

Input

The first line contains a single integer TT: the number of test cases. Each test case has the following format:

  • One line with two integers nn and pp (1≤n≤p≤1001 \le n \le p \le 100): the number of tentacles and the number of pirates (not counting the captain).
  • One line with three integers xcx_c, ycy_c and vcv_c: the captain's coordinates and speed.
  • pp lines, each with three integers xix_i, yiy_i and viv_i: the coordinates and speed of one pirate.
  • One line with two integers xhx_h and yhy_h: the coordinates of the n-pus's head.
  • nn lines, each with two integers xjx_j and yjy_j: the coordinates of one tentacle.

All coordinates satisfy 0≤x,y≤100000 \le x, y \le 10000 and all speeds satisfy 1≤v≤1001 \le v \le 100. The captain, the pirates, the head and the tentacles are point-like (they have no size) and their positions are all distinct. Everyone moves in a straight line toward their target at their given speed.

Output

For each test case, print on its own line the minimum time for the captain to kill the n-pus, rounded to exactly 6 digits after the decimal point (for example, 1.500000).

Examples1

  1. Example 1

    Input
    3
    3 3
    2 0 1
    0 0 2
    1 0 3
    3 0 4
    2 3
    0 1
    1 1
    4 1
    1 3
    0 0 1
    3 0 1
    4 0 1
    7 0 2
    0 1
    4 2
    3 3
    0 0 2
    2 0 3
    3 0 1
    4 0 2
    0 1
    3 1
    4 1
    5 1
    
    Expected output
    3.500000
    2.802776
    1.500000