Autobus

아직 제출이 없습니다시간 제한1초메모리 제한512 MB

문제

In a country there are nn cities. The cities are connected by mm bus routes, where the ii-th route starts in city a_ia\_i, ends in city b_ib\_i and takes t_it\_i minutes.

Ema loves to travel, but doesn’t like transferring between buses. On her trip she wants to use at most kk different bus routes.

Help her answer qq questions of the form ‘What is the shortest travel time to get from city c_jc\_j to city d_jd\_j (using at most kk different bus routes)?’.

입력

The first line contains two positive integers nn and mm (2n702 ≤ n ≤ 70, 1m1061 ≤ m ≤ 10^6), the number of cities and the number of bus routes.

The ii-th of the next mm lines contains positive integers a_ia\_i, b_ib\_i and t_it\_i (1a_i,b_in1 ≤ a\_i , b\_i ≤ n, 1t_i1061 ≤ t\_i ≤ 10^6), the terminal cities and the travel time of the ii-th bus route.

The next line contains two positive integers kk and qq (1k1091 ≤ k ≤ 10^9, 1qn21 ≤ q ≤ n^2), the maximum number of used routes and the number of queries.

The jj-th of the next qq lines contains positive integers c_jc\_j and d_jd\_j (1c_j,d_jn1 ≤ c\_j , d\_j ≤ n), the cities from the jj-th query.

출력

Print qq lines. In the jj-th line print the shortest travel time from the jj-th query, or -1 if there is no trip that satisfies the requirements.

힌트

Clarification of the examples:

The answer to the first query from each example is marked on the graph.