PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#FW0000096. Chuyến đi mua sắm tiết kiệm (Shopping Trip)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Chuyến đi mua sắm tiết kiệm (Shopping Trip)

Shopping Trip

Source: UVa

Version: Phuoc Hung OJ Extended

Problem Statement

Daniel lives at node 00 and there are nn stores 1..n1..n. Each bidirectional road has a travel cost in dollars. Each DVD offer at store uu yields a saving relative to ordering online. Daniel may skip offers, but any shopping route starts and ends at home. Maximize total shopping savings minus fuel costs, in exact cents. Multiple offers at one store can be collected on a single visit.

Input

First n,mn,m, then mm roads u,v,cu,v,c with costs having two decimal places. Next kk and kk lines u,su,s giving available savings.

Output

Print Don't leave the house if no positive net saving is possible; otherwise Daniel can save $X.YY.

Subtasks

  • Subtask 1 (40 points): 2≤n≤6,  1≤k≤42\le n\le 6,\;1\le k\le 4. All input-format and graph conditions above apply.

  • Subtask 2 (60 points): 2≤n≤16,  1≤k≤82\le n\le 16,\;1\le k\le 8. All input-format and graph conditions above apply.

Examples

Input

1 1
0 1 1.00
1
1 5.00

Output

Daniel can save $3.00

Explanation

Travel from home 0 to store 1 and back costs 1.00+1.00=2.001.00+1.00=2.00. The item saves 5.005.00, leaving a net benefit of 5.00−2.00=3.005.00-2.00=3.00.