Gas Station
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

ZYT loves driving. One day he found some islands, and wanted to go on a tour.

These  islands are connected  by bi-directed roads.The road connects island u_i,v_i, and takes w_i liter(s) of gasoline to pass.And on each island there is a gas station,which can add at most a_i liter(s) of gasoline to his car.

ZYT has  plans,the is that:
  1. He will start from x_i,and has d_i liter(s) of gasoline initially.
  2. There's an island p_i he does not like to pass in this plan.
For each plan, he wants to know how many different islands he can reach in this plan(including x_i). We say he can reach the island  if and if only there exists a available simple path starts from x_i and ends at , and he always has at least  liter of gasoline during the whole tour.

A simple path is a path that passes each island at most once.

输入描述:

The first line of input contains two integers  — number of islands, number of tour plans.

Then  lines ,each line containing three integers u_i,v_i,w_i, describing a road.

Then a line with  integers  — the gas stations' fuel limits.

Last  lines, each contains three integers x_i,d_i,p_i, describing a tour plan.

输出描述:

Output  lines — the number of reachable islands in each plan.
示例1

输入

复制
5 5
1 2 9
1 3 1
3 4 10
1 5 2
7 2 2 2 2 
2 7 4
2 2 3
1 5 4
3 6 5
3 0 2

输出

复制
4
1
4
3
3
示例2

输入

复制
10 10
1 2 38
1 3 55
1 4 35
4 5 4
2 6 60
5 7 61
5 8 54
1 9 17
9 10 99
9 77 56 59 79 45 51 96 71 18 
10 4 1
8 28 4
7 0 6
5 28 1
8 63 2
8 12 4
6 84 8
8 26 4
1 38 4
6 14 10

输出

复制
1
3
1
4
8
3
9
3
5
1

备注:

It's guaranteed that .