{"trustable":true,"sections":[{"title":"","value":{"format":"MD","content":"Alice wants to send Bob some confidential messages. But their internet connection is not secured enough. As their names have been used in many networking schemes, they are very rich now. So, they don\u0027t want to send encoded messages, they want to use secured dedicated connection for them. So, they talked to some ISPs (Internet Service Providers) about their problem. Only they get is that there are **N** routers in the network, some of them share bidirectional links. Each link has a capacity, and for each KB of data passing through this link, they have to pay some money. Assume that Alice is connected with the **1\u003csup\u003est\u003c/sup\u003e** router and Bob is connected to the **N\u003csup\u003eth\u003c/sup\u003e** router.\n\n![Network](CDN_BASE_URL/31f6f5de0aeec2d373862105825a447c?v\u003d1715782988)\n\nFor example, in the picture, Alice wants to send 4 KB data from router 1 to router 6. Each link is identified by two integers in the form **(a, b)** where **\u0027a\u0027** denotes the capacity of the link and **\u0027b\u0027** denotes per KB cost of the link. So, Alice can send 1KB of data through 1 - 2 - 3 - 4 - 6 (cost 8), 2KB data through 1 - 5 - 6 (cost 2 * 9\u003d18) and 1KB data through 1 - 3 - 4 - 6 (cost 11). So, the total cost is 37 units.\n\nNow Alice wants to send **P** KB of data to Bob. You have to find the minimum amount of money they have to pay to achieve their goal."}},{"title":"Input","value":{"format":"MD","content":"Input starts with an integer **T (\u0026le; 50)**, denoting the number of test cases.\n\nEach case starts with a blank line. Next line contains three integers **N (2 \u0026le; N \u0026le; 50)**, **M (0 \u0026le; M \u0026le; N*(N-1)/2)** and **P (1 \u0026le; P \u0026le; 1000)**, where **M** denotes the number of bidirectional links. Each of the next **M** lines contains four integers **u v w c (1 \u0026le; u, v \u0026le; N, u \u0026ne; v, 1 \u0026le; w, c \u0026le; 100)**, meaning that there is a link between router **u** and **v**, and at most **c KB** data can be sent through this link, and each KB of data through this link will cost **w**. You can assume that there will be at most one connection between a pair of routers."}},{"title":"Output","value":{"format":"MD","content":"For each case, print the case number and the minimum amount of money required or `impossible` if it\u0027s not possible to send **P** KB of data."}},{"title":"Sample","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e3\n\n6 9 4\n3 1 9 8\n1 2 1 2\n1 5 6 1\n5 6 2 8\n6 4 2 2\n4 2 7 6\n2 6 7 9\n3 4 5 1\n3 2 2 3\n\n6 9 9\n3 1 9 8\n1 2 1 2\n1 5 6 1\n5 6 2 8\n6 4 2 2\n4 2 7 6\n2 6 7 9\n3 4 5 1\n3 2 2 3\n\n4 4 20\n1 3 1 3\n3 4 1 4\n1 2 1 2\n2 4 1 5\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eCase 1: 37\nCase 2: 139\nCase 3: impossible\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}