{"trustable":false,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\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 type\u003d\"text/javascript\" async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS_HTML-full\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"成都有n家火锅店,编号从1到n,第i家火锅店提供一定辣度的火锅。较高的辣度表示更辣的味道,而较低的辣度则更温和(但仍然需要非常小心)。\n\n我们可以将这 n 家餐厅视为具有 m 条边的无向图上的节点。现在我们有q个游客想尝试一下火锅。给定游客当前的位置和他们所能承受的最大辣味值,你的任务是计算游客和他能接受的最近餐厅之间的最短距离。\n\n在这个问题中,我们将路径的距离定义为路径中的边数。"}},{"title":"Input","value":{"format":"HTML","content":"每个测试文件中只有一个测试用例。\n\n第一行包含三个整数 n、m 和 q (1≤n,m≤105,1≤q≤5×105) 表示餐厅数量、边数和游客数量。\n\n第二行包含 n 个整数 w1,w2,⋯,wn (1≤wi≤100) 其中 wi 表示第 i 家餐厅的辣味值。\n\n对于接下来的 m 行,第 i 行包含两个整数 ui 和 vi(1≤ui,vi≤n,ui≠vi)表示连接餐厅 ui 和 vi 的边。\n\n对于以下q行,第i行包含两个整数pi和ai(1≤pi≤n,1≤ai≤100),表示第i个游客当前在餐厅pi,他可以吃的最大辣味值接受是ai。"}},{"title":"Output","value":{"format":"HTML","content":"输出 q 行,其中第 i 行包含一个整数,表示第 i 位游客和他可以接受的最近餐厅之间的最短距离。如果没有这样的餐厅,则输出“-1”。 "}},{"title":"Example","value":{"format":"HTML","content":"\u003cdiv class\u003d\"sample-test\"\u003e\n \u003cdiv class\u003d\"input\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n Input\n \u003c/div\u003e\n \u003cpre\u003e4 4 5\n5 4 2 3\n1 2\n2 3\n3 4\n4 1\n1 1\n1 2\n1 3\n1 4\n1 5\n\u003c/pre\u003e\n \u003c/div\u003e\n \u003cdiv class\u003d\"output\"\u003e\n \u003cdiv class\u003d\"title\"\u003e\n Output\n \u003c/div\u003e\n \u003cpre\u003e-1\n2\n1\n1\n0\n\u003c/pre\u003e\n \u003c/div\u003e\n\u003c/div\u003e"}}]}