Logo Daimayuan Online Judge

Home

时间限制:3 s 空间限制:1024 MB

#380. CCPC Harbin 2021 G, Damaged Bicycle

附加文件 统计

Ring Ring Ring ... The bell rang at half past six in the morning. After turning off the alarm, George went on to sleep again. When he woke up again, it was seven fifty and there were ten minutes left for class!

George immediately got up from bed, dressed, packed his backpack, brushed his teeth and washed his face. Then, he immediately rushed out of the dormitory and embarked on the road to the teaching building. On the way, he turned on his mobile phone to locate and saw several yellow shared bicycles nearby. Therefore, he headed to a bicycle and took out his mobile phone to scan the QR code on the bicycle. Unfortunately, the bicycle wasn't unlocked, and a line of words "this bicycle is damaged and can't be unlocked" was displayed on the screen.

Without riding a bicycle, he was late. What a bad day!

Indeed, some bicycles in the school are damaged, but their location will still be displayed on the app. George always rides faster than he walks, but considering that some bicycles are damaged, if George tries one by one, it may take a long time! In this regard, he has made some modeling, and hopes you can help him find the best strategy.

The campus can be modeled as a graph of $n$ vertices and $m$ bidirected edges, where the $i$-th edge is $w_i$ meters long. George's dormitory is located at vertex $1$ and Guanghua Tower (the teaching building) is at vertex $n$, so George has to go from vertex $1$ to vertex $n$ to take classes. His walking speed is $t$ meters per second and his riding speed is $r$ meters per second. According to the bicycle sharing app, there are $k$ parked bicycles in the campus. The $i$-th bicycle is located at vertex $a_i$, and of probability $\frac{p_i}{100}$ to be damaged according to George's experience. However, only when George arrives at vertex $a_i$ and scans the QR code, can he determine whether the $i$-th bicycle is damaged or not. As soon as a bicycle is confirmed to be undamaged, George will get on it immediately and will not get off until he reaches vertex $n$.

Now George wants to save time to get to the classroom. So you, George's roommate, should help him find an optimal strategy to minimize the mathematical expectation of the time cost on the way, and then output this value. Or you can let him continue sleeping if vertex $n$ is not reachable.

In this problem, you should only consider the time of walking and cycling, and you can assume that the other actions(scanning QR code, getting on, getting off, $\cdots$) cost no time.

简单中文翻译:校园可以被看成$n$个点,$m$条无向边的图,其中第$i$条边的长度是$w_i$。你的宿舍在$1$号点,教学楼在$n$号点,你想从宿舍去教学楼。你的走路速度是每秒$t$,骑车速度是每秒$r$。根据共享单车app,校园内一共有$k$个停车点。第$i$个停车点在$a_i$点,但是有$\frac{p_i}{100}$的概率,车可能是坏的。但是你只有到达$a_i$点,然后扫描二维码之后才能知道第$i$辆车是不是好的。如果车是好的,那就可以骑到终点。

问你最优策略下,你最小的到达终点的期望时间是多少。如果到达不了$n$号点,输出-1

Input

The first line contains two integers $t,r\,(1\le t\le r\le 10^4)$ — the speed of walking and the speed of riding, respectively.

The second line contains two integers $n,m\,(1\le n,m\le 10^5)$ — the number of vertices and the number of bidirected edges in the given graph.

Following $m$ lines each contains three integers $u_i,v_i,w_i\,(1\le u_i,v_i \le n, u_i \neq v_i, 1 \le w_i\le 10^4)$, denoting that vertices $u,v$ are connected by a $w_i$-meter-long bidirected edge.

The next line contains a single integer $k\,(0\le k\le 18)$, denoting the number of bicycles in campus.

Following $k$ lines each contains two integers $a_i,p_i\,(1\le a_i \le n, 0\le p_i \le 100)$, denoting the locations of the bicycles and the percentages of damage probabilities respectively.

It is guaranteed that no two bicycles are in the same vertex.

Output

If George cannot reach vertex $n$, output one line containing one integer -1, or output one line containing one real number, denoting the minimum expectation of the time cost on the way.

As long as the relative or absolute error between your answer and the standard answer is within $10^{-6} $, your answer will be considered correct.

Examples

input

3 15
4 3
1 2 600
1 3 300
2 4 900
1
3 50

output

460.000000

input

3 15
5 4
1 2 600
1 3 300
2 5 900
3 4 3
2
3 50
4 0

output

220.600000

input

3 15
5 4
1 2 600
1 3 300
4 5 900
3 2 300
2
3 50
4 0

output

-1

Note

For the first test case, one possible strategy is:

  • Go along the route $1\rightarrow 3$ and try to ride the only bicycle in the campus.

  • If the bicycle is damaged, go along the route $3 \rightarrow 1 \rightarrow 2 \rightarrow 4$ on foot, or go by bicycle.

Considering the time cost on the way:

  • If the bicycle is damaged, George should go along the route $1\rightarrow 3 \rightarrow 1 \rightarrow 2 \rightarrow 4$ on foot, whose total length is 2100 meters. So the time cost is $\frac{2100}{3} = 700$ seconds.

  • If the bicycle is undamaged, George should go along the route $1\rightarrow 3$ on foot, whose total length is 300 meters, and then go along the route $3 \rightarrow 1 \rightarrow 2 \rightarrow 4$ by bicycle, whose total length is 1800 meters. So the time cost is $\frac{300}{3} + \frac{1800}{15} = 220$ seconds.

As given in the input, the only bicycle has $\frac{50}{100}$ probability to be damaged. So the expectation time cost is $\frac{50}{100}\times 700 + (1 - \frac{50}{100})\times 220 = 460$