{"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\"\u003eOne day , Kiki wants to visit one of her friends. As she is liable to carsickness , she wants to arrive at her friend’s home as soon as possible . Now give you a map of the city’s traffic route, and the stations which are near Kiki’s home so that she can take. You may suppose Kiki can change the bus at any station. Please find out the least time Kiki needs to spend. To make it easy, if the city have n bus stations ,the stations will been expressed as an integer 1,2,3…n.\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"There are several test cases. \u003cbr\u003eEach case begins with three integers n, m and s,(n\u0026lt;1000,m\u0026lt;20000,1\u003d\u0026lt;s\u0026lt;\u003dn) n stands for the number of bus stations in this city and m stands for the number of directed ways between bus stations .(Maybe there are several ways between two bus stations .) s stands for the bus station that near Kiki’s friend’s home.\u003cbr\u003eThen follow m lines ,each line contains three integers p , q , t (0\u0026lt;t\u0026lt;\u003d1000). means from station p to station q there is a way and it will costs t minutes .\u003cbr\u003eThen a line with an integer w(0\u0026lt;w\u0026lt;n), means the number of stations Kiki can take at the beginning. Then follows w integers stands for these stations.\u003cbr\u003e"}},{"title":"Output","value":{"format":"HTML","content":"The output contains one line for each data set : the least time Kiki needs to spend ,if it’s impossible to find such a route ,just output “-1”."}},{"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 8 5\r\n1 2 2\r\n1 5 3\r\n1 3 4\r\n2 4 7\r\n2 5 6\r\n2 3 5\r\n3 5 1\r\n4 5 1\r\n2\r\n2 3\r\n4 3 4\r\n1 2 3\r\n1 3 4\r\n2 3 2\r\n1\r\n1\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e1\r\n-1\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}