{"trustable":true,"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":"\u003cp\u003eThere are $$$n$$$ hotpot restaurants numbered from $$$1$$$ to $$$n$$$ in Chengdu and the $$$i$$$-th restaurant serves hotpots of a certain spicy value $$$w_i$$$. A higher spicy value indicates a hotter taste, while a lower spicy value is more gentle (still need to be very careful, though).\u003c/p\u003e\u003cp\u003eWe can consider these $$$n$$$ restaurants as nodes on an undirected graph with $$$m$$$ edges. Now we have $$$q$$$ tourists who want to give the hotpots a try. Given the current positions of the tourists and the maximum spicy value they can bear, your task is to calculate the shortest distance between a tourist and the closest restaurant he can accept.\u003c/p\u003e\u003cp\u003eIn this problem we define the distance of a path as the number of edges in the path.\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThere is only one test case in each test file.\u003c/p\u003e\u003cp\u003eThe first line contains three integers $$$n$$$, $$$m$$$ and $$$q$$$ ($$$1 \\le n, m \\le 10^5,1 \\le q \\le 5 \\times 10^5$$$) indicating the number of restaurants, the number of edges and the number of tourists.\u003c/p\u003e\u003cp\u003eThe second line contains $$$n$$$ integers $$$w_1, w_2, \\cdots, w_n$$$ ($$$1 \\le w_i \\le 100$$$) where $$$w_i$$$ indicates the spicy value of the $$$i$$$-th restaurant.\u003c/p\u003e\u003cp\u003eFor the following $$$m$$$ lines, the $$$i$$$-th line contains two integers $$$u_i$$$ and $$$v_i$$$ ($$$1 \\le u_i, v_i \\le n$$$, $$$u_i \\ne v_i$$$) indicating an edge connecting restaurant $$$u_i$$$ and $$$v_i$$$.\u003c/p\u003e\u003cp\u003eFor the following $$$q$$$ lines, the $$$i$$$-th line contains two integers $$$p_i$$$ and $$$a_i$$$ ($$$1 \\le p_i \\le n$$$, $$$1 \\le a_i \\le 100$$$) indicating that the $$$i$$$-th tourist is currently at restaurant $$$p_i$$$ and that the maximum spicy value he can accept is $$$a_i$$$.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003eOutput $$$q$$$ lines where the $$$i$$$-th line contains one integer indicating the shortest distance between the $$$i$$$-th tourist and the closest restaurant he can accept. If there is no such restaurant, output \u0027-1\u0027 instead.\u003c/p\u003e"}},{"title":"Examples","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\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\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e-1\n2\n1\n1\n0\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}