Under construction

Still being built. Things may change

Emergency Room

Time limit1sMemory limit128 MB

Summary
Simulate patients taking the lowest free seat on arrival, track who sits within 2 metres for 20 consecutive minutes, and count infections spreading one day later.
Level

Medium7 of 10

Topics
Simulation, Implementation, Geometry
Solved
No attempts yet

Problem

In the US, many people lack health insurance, which causes several kinds of problems. Most doctors will not treat patients without insurance, so those patients find it hard to get medical care. Emergency rooms, however, must treat every patient, because in their originally intended role they can be the difference between life and death. As a result, since the emergency room is the only place that must accept uninsured patients, uninsured people go there even for non-life-threatening conditions such as the flu or measles. Because the emergency room has to handle life-and-death cases first, these patients are not treated right away, and people carrying infectious diseases end up waiting together for many hours in a crowded emergency room. It is not clear that this is the best way to stop such diseases from spreading. In this problem we simulate how a disease spreads among the visitors of an emergency room.

The emergency room has SS seats, whose coordinates are given. You are given every arrival and departure of patients over time. When a patient arrives, they take the lowest-numbered seat that is free at that moment and stay in it until they leave. The same patient may come back later, and will then pick a new seat.

Initially, only patient 1 has the disease. The disease is transmitted from patient AA to patient BB when they sit within a distance of 2 metres of each other for at least 20 consecutive minutes (for example, from time 5 until time 25 is enough, but from time 5 until time 24 is not). If either of them leaves, the shared time is counted again from 0 (sitting next to each other twice for 10 minutes each does not count).

Once a patient is infected, they begin to transmit the disease the next day, that is, 1440 minutes after the moment of infection, and stay infectious forever afterward. Patient 1 is treated as having been infected the previous day, so patient 1 is infectious from time 0. Determine how many patients have the disease when the whole process ends.

Input

The first line contains the number KK of data sets. It is followed by KK data sets, each in the following form.

The first line of a data set contains three integers P,S,VP, S, V. 1≤P≤10001 \le P \le 1000 is the number of patients (only patient 1 is infected at the start), 1≤S≤1001 \le S \le 100 is the number of seats in the emergency room, and 1≤V≤1000001 \le V \le 100000 is the number of patient visits.

This is followed by SS lines, each containing two real numbers xi,yix_i, y_i, the coordinates (in metres) of the ii-th seat. Then come VV lines, each containing three integers pj,aj,djp_j, a_j, d_j: pjp_j is the patient making the jj-th visit, aja_j is the arrival time (in minutes, from time 0), and dj>ajd_j > a_j is the departure time. The visits are sorted by non-decreasing arrival time. The input guarantees that at no moment are there more than SS patients in the emergency room at the same time. Also, if a patient ii arrives at exactly the departure time of another patient jj, then jj is considered to have already vacated the seat, so patient ii may sit there.

Output

For each data set, print "Data Set x:" on its own line, where xx is the number of the data set. Then, on the next line, print the total number of patients who are sick when the process ends. Print one blank line between two consecutive data sets.

Examples4

  1. Example 1

    Input
    1
    6 4 10
    -0.5 0
    0.5 1
    1.5 2
    -0.3 2
    1 0 60
    2 20 50
    3 50 120
    2 90 120
    5 1440 1620
    2 1460 1520
    6 1501 1600
    3 1510 1600
    1 1530 1540
    4 1800 2000
    
    Expected output
    Data Set 1:
    3
    
  2. Example 2

    Input
    1
    1 1 1
    0 0
    1 0 100
    
    Expected output
    Data Set 1:
    1
    
  3. Example 3

    Input
    1
    2 2 2
    0 0
    1 0
    1 0 100
    2 0 20
    
    Expected output
    Data Set 1:
    2
    
  4. Example 4

    Input
    2
    1 1 1
    0 0
    1 0 100
    2 2 2
    0 0
    1 0
    1 0 100
    2 0 20
    
    Expected output
    Data Set 1:
    1
    
    Data Set 2:
    2