{"trustable":true,"prependHtml":"\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\" type\u003d\"text/javascript\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv class\u003d\"panel_content\"\u003eThese are N cities in Spring country. Between each pair of cities there may be one transportation track or none. Now there is some cargo that should be delivered from one city to another. The transportation fee consists of two parts: \u003cbr\u003eThe cost of the transportation on the path between these cities, and\u003cbr\u003e\u003cbr\u003ea certain tax which will be charged whenever any cargo passing through one city, except for the source and the destination cities.\u003cbr\u003e\u003cbr\u003eYou must write a program to find the route which has the minimum cost.\u003cbr\u003e\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"First is N, number of cities. N \u003d 0 indicates the end of input.\u003cbr\u003e\u003cbr\u003eThe data of path cost, city tax, source and destination cities are given in the input, which is of the form:\u003cbr\u003e\u003cbr\u003ea11 a12 ... a1N\u003cbr\u003ea21 a22 ... a2N\u003cbr\u003e...............\u003cbr\u003eaN1 aN2 ... aNN\u003cbr\u003eb1 b2 ... bN\u003cbr\u003e\u003cbr\u003ec d\u003cbr\u003ee f\u003cbr\u003e...\u003cbr\u003eg h\u003cbr\u003e\u003cbr\u003ewhere aij is the transport cost from city i to city j, aij \u003d -1 indicates there is no direct path between city i and city j. bi represents the tax of passing through city i. And the cargo is to be delivered from city c to city d, city e to city f, ..., and g \u003d h \u003d -1. You must output the sequence of cities passed by and the total cost which is of the form:\u003cbr\u003e"}},{"title":"Output","value":{"format":"HTML","content":"From c to d :\u003cbr\u003ePath: c--\u0026gt;c1--\u0026gt;......--\u0026gt;ck--\u0026gt;d\u003cbr\u003eTotal cost : ......\u003cbr\u003e......\u003cbr\u003e\u003cbr\u003eFrom e to f :\u003cbr\u003ePath: e--\u0026gt;e1--\u0026gt;..........--\u0026gt;ek--\u0026gt;f\u003cbr\u003eTotal cost : ......\u003cbr\u003e\u003cbr\u003eNote: if there are more minimal paths, output the lexically smallest one. Print a blank line after each test case.\u003cbr\u003e\u003cbr\u003e"}},{"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\u003e5\r\n0 3 22 -1 4\r\n3 0 5 -1 -1\r\n22 5 0 9 20\r\n-1 -1 9 0 4\r\n4 -1 20 4 0\r\n5 17 8 3 1\r\n1 3\r\n3 5\r\n2 4\r\n-1 -1\r\n0\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eFrom 1 to 3 :\r\nPath: 1--\u0026gt;5--\u0026gt;4--\u0026gt;3\r\nTotal cost : 21\r\n\r\nFrom 3 to 5 :\r\nPath: 3--\u0026gt;4--\u0026gt;5\r\nTotal cost : 16\r\n\r\nFrom 2 to 4 :\r\nPath: 2--\u0026gt;1--\u0026gt;5--\u0026gt;4\r\nTotal cost : 17\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}