Vacation Planning

No attempts yetTime limit1sMemory limit128 MB

Problem

Air Bovinia connects the NN farms where the cows live. The farms are numbered 11 through NN, and farms 11 through KK are hubs.

The airline currently runs MM one-way flights. Flight ii goes from farm uiu_i to farm viv_i and costs did_i dollars.

Air Bovinia has taken QQ requests for one-way trips. Trip ii starts at farm aia_i and ends at farm bib_i. A route is any sequence of direct flights and may visit the same farm several times, but it has to include at least one hub. A hub at the start or at the destination satisfies that requirement. When the start and the destination are the same farm, the route that takes no flight at all counts as a route, and it satisfies the requirement only if that farm is a hub.

Because of this requirement, a trip from aia_i to bib_i may have no route at all. For every trip that does have one, find the minimum cost.

1N2001 \le N \le 200, 1K1001 \le K \le 100, KNK \le N, 1M100001 \le M \le 10\,000, 1di10000001 \le d_i \le 1\,000\,000, and 1Q100001 \le Q \le 10\,000. Several flights may connect the same pair of farms, and a flight may start and end at the same farm.

Input

  • The first line contains NN, MM, KK, and QQ.
  • Line ii of the next MM lines contains uiu_i, viv_i, and did_i for flight ii.
  • Line ii of the next QQ lines contains aia_i and bib_i for trip ii.

Output

  • On the first line, print how many trips have a valid route.
  • On the second line, print the sum of the minimum costs of those trips. Print 00 when no trip has a valid route.

Hint

The example input has three farms, and farm 11 is the hub. A flight runs from farm 33 to farm 11 for 1010 dollars, and the other flights read the same way.

The cheapest route from farm 33 to farm 22 passes through farm 11 and costs 10+7=1710 + 7 = 17. No flight leaves farm 22, so the trip from farm 22 to farm 33 has no route. The trip from farm 11 to farm 22 has a single route, costing 77.