P11839 [AOJ] Cat Burglar and Friday House
普及
题目描述

Natsume loves big cats. On Natsume's school road, there is a house commonly known as a cat mansion. The house is famous for having a lot of cats, and Natsume often encountered her cats in front of this house on her way to school and played with them. One day, Natsume learned a shocking fact. It was that the owner of the cat house often abused his cats when he was in a bad mood. Natsume, who couldn't forgive the owner of the cat house, decided to steal the cats while he was away in order to save them.

Natsume observed the behavior pattern of the owner of the cat mansion and decided to steal the cats at the timing when he went out every week. The cat mansion is represented as a two-dimensional plane, and the position of each cat at the time when the jujube sneaks into the mansion is known. The cats are always traveling on a fixed route at a speed of 50 meters per minute. On the other hand, jujube can move at speeds of up to 80 meters per minute. Natsume invades from a certain place in the mansion, moves in the mansion, and exits from the escape exit by the time the master returns. When you reach the same point as the cat, you can hold the cat. The time it takes to do this is negligible. Natsume can carry as many cats as she wants, and even if she holds any number of cats, her movement speed will not slow down, but she must escape from the mansion before her husband returns.

Unfortunately, Natsume may not be able to steal all the cats in the cat house. However, in order to make as many cats happy as possible, I decided to steal as many cats as possible. Also, if you can steal the same number of cats, escape from the mansion as soon as possible to reduce the risk of being caught by the mansion owner.

Given the time and location of the jujube invading the mansion, the time of the mansion owner's return, the location of the escape exit, and the initial location and patrol route of the cat. Write a program that tells you how many cats Natsume can steal and at what time you can escape the mansion.

Notes on Submission

Multiple datasets are given in the above format. The first line of input data gives the number of datasets. Create a program that outputs the output for each data set in order in the above format.

Input

On the first line of input, the x and y coordinates of the entry point are given, separated by a single space character. The second line is also given the location of the escape exit. The third line gives the time when Natsume entered the mansion, and the fourth line gives the time when the owner of the mansion returns in the 24-hour HH: MM: SS format.

The fifth line is the total number of cats m, and the following m lines are given the behavior pattern of each cat. Line 5 + i (i = 1, 2, ..., m) corresponds to the i-th cat's patrol route. The natural number ki is given at the beginning of each line, followed by the traverse route of the cat as a sequence of ki x, y coordinate values. The cat's patrol route is a line segment connecting these consecutive points and the last and first points. When Natsume invades the mansion, the cat is at the first point given and will continue to move at a constant speed on the patrol route. Consecutive points on a given route cannot have the same coordinates.

The start time and goal time are guaranteed to be on the same day. There is always a way for Natsume to escape before her husband returns. All numbers on the same line are separated by a single space character.

The number of cats is 1 or more and 14 or less, the number of points representing the cat's patrol route is 2 or more and 1000 or less, and all coordinate values ​​are guaranteed to be integers whose absolute values ​​do not exceed 100000. The unit of coordinate values ​​is all meters.

Output

On the first line, print the maximum number of cats that Natsume can steal. On the second line, answer in the form of HH MM SS.nnnnnn (blank delimited) the time when you can reach the escape exit earliest among the methods for stealing as many cats as possible. Output 6 digits after the decimal point of the second. There should be no error exceeding 10-6 seconds.

It is guaranteed that the maximum number of encounters will not change even if the return time of the master changes by ± 1 ms.

Example

Input

2
0 0
0 0
15:00:00
18:00:00
1
4 0 7199 1125 7199 1125 8324 0 8324
0 0
0 0
15:00:00
18:00:00
1
4 0 7201 1125 7201 1125 8326 0 8326

Output

1
17 59 59.076923
0
15 00 00.000000

输入格式

见题面

输出格式

见题面

样例输入
2 0 0 0 0 15:00:00 18:00:00 1 4 0 7199 1125 7199 1125 8324 0 8324 0 0 0 0 15:00:00 18:00:00 1 4 0 7201 1125 7201 1125 8326 0 8326
样例输出
1 17 59 59.076923 0 15 00 00.000000