{"trustable":false,"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":"MD","content":"某一天,Carered想去找GsjzTle请教问题。由于时间紧迫,他只想尽快到达GsjzTle的家。现在有一张公交线路图,上面有n个公交站,这些公交站从1到n编号。Carered可以在任何站换乘公交,他的运气比较好,总是能在下车后立马坐上想坐的公交车。Carered知道G神家附近有哪些公交站,他想知道他最快能在多少分钟内到达?\n注:只要到达G神家附近的公交站即可视为到达他家。"}},{"title":"输入格式","value":{"format":"MD","content":"多组数据输入\n第一行三个整数 n,m 和 s,(n \u003c1000,m \u003c20000,1 \u003d \u003cs \u003c\u003d n)\nn代表该城市的公交车站数量,m代表之间的有向车道数量公交车站。(也许在两个公交车站之间有不同的方式可以到达。) s 代表Carered出发的公交车站。\n然后跟随m行,每行包含三个整数u,v,cost(0 \u003ct \u003c\u003d 1000)。意思是从车站u到车站v的一种方式,它将花费cost分钟。\n然后,一行具有整数q(0 \u003cq \u003cn)的行表示G神家附件的站点数。然后,q个整数代表这些站的编号。"}},{"title":"输出格式","value":{"format":"MD","content":"每组输出包含一行:Carered需要花费的最少时间,如果无法到达,只需输出“ -1”即可。"}},{"title":"样例输入","value":{"format":"MD","content":"\u003cpre\u003e5 8 5\n1 2 2\n1 5 3\n1 3 4\n2 4 7\n2 5 6\n2 3 5\n3 5 1\n4 5 1\n2\n2 3\n4 3 4\n1 2 3\n1 3 4\n2 3 2\n1\n1\u003c/pre\u003e"}},{"title":"样例输出","value":{"format":"MD","content":"\u003cpre\u003e1\n-1\u003c/pre\u003e"}}]}