{"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\"\u003eThis class is on chess. Baby Volcano is playing a special chess game with his friend, Baby Evil. \u003cbr\u003e\u003cbr\u003eIn this chess game, there is a directed graph $G \u003d (V,E)$. Vertices are indexed from $1$ to $n$. It is guaranteed that every vertex has at least one out-going edge, i.e. $\\forall v\\in V, \\exists w\\in V, (v,w)\\in E$, Baby Volcano takes control of a subset of vertices $X\\subseteq V$, Baby Evil takes control of $V\\setminus X$. Every vertex $v$ is assigned a weight $W(v)$. \u003cbr\u003e\u003cbr\u003eThere is a chess, positioning at $s\\in V$ initially. The game consists of three phases.\u003cbr\u003e\u003cbr\u003e1. For every $p\\in X$, Baby Volcano chooses an out-going edge $(p,q)\\in E$ and delete other out-going edges of vertex $p$. \u003cbr\u003e\u003cbr\u003e2. After Volcano\u0027s operation, Baby Evil would similarly choose an out-going edge $(p\u0027,q\u0027)\\in E$ and delete other out-going edges of $p\u0027$ for every $p\u0027 \\notin X$. Both two babies make decisions based on chess\u0027s initial position $s$.\u003cbr\u003e\u003cbr\u003e3. After two processes above, every vertex would remain only one out-going edge. The chess starts moving along the unique path in the processed graph, resulting in an infinite path $L \u003d v_0v_1v_2\\cdots$, where $v_0\u003ds$. Baby Volcano gains score $CV$ at last, which is computed below:\u003cbr\u003e$$CV:\u003d \\max\\left\\{W\\left(v_i\\right) \\ |\\ v_i \\text{ appears in }L\\right\\}$$ \u003cbr\u003e\u003cbr\u003eBaby Volcano wants to maximize $CV$, while Baby Evil wants to minimize it. \u003cbr\u003e\u003cbr\u003eYour task is to determine, for every $s,1\\leq s\\leq n$, compute $CV$ under the circumstance that the chess is put at $s$ initially. \u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"In the first line there is a number $T$, denotes the number of test cases.\u003cbr\u003e\u003cbr\u003eThen there are $T$ parts of input, each part describes a test case. Each parts begins with $n,m,R,B$, denotes the number of vertices, edges, the range of $W(v)$, and the size of $X$, the set which baby volcano takes control.\u003cbr\u003e\u003cbr\u003eThen there is a line consists of $B$ numbers, denotes elements in $X$.\u003cbr\u003e\u003cbr\u003eThen there is a line with $n$ numbers, the $i$-th number, denotes $W(i), 1\\leq W(i)\\leq R$.\u003cbr\u003e\u003cbr\u003eThen there are $m$ lines, each line consists of $2$ numbers, $u,v$, showing that there is an edge from $u$ to $v$ in $G$.\u003cbr\u003e\u003cbr\u003e$1\\leq T\\leq 100$\u003cbr\u003e\u003cbr\u003e$1\\leq m,R\\leq 5\\times 10^5$\u003cbr\u003e\u003cbr\u003e$1\\leq B\\leq n\\leq 5\\times 10^5$\u003cbr\u003e\u003cbr\u003e$1\\leq \\sum{n},\\sum{m},\\sum{R}\\leq 10^6$\u003cbr\u003e"}},{"title":"Output","value":{"format":"HTML","content":"For each test case, you should first output \u0027\u0027Case #t:\u0027\u0027(without quotes), denotes the test number.\u003cbr\u003e\u003cbr\u003eThen you need to output $n$ numbers in the next line, the $i$-th number is $CV$ under the circumstance that the chess is put at $i$ initially. "}},{"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\u003e2\r\n3 3 2 1\r\n3\r\n1 1 2\r\n1 2\r\n2 3\r\n3 3\r\n4 6 10 1\r\n4\r\n8 7 3 2\r\n1 3\r\n2 4\r\n3 2\r\n4 2\r\n2 1\r\n2 2\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eCase #1:\r\n2 2 2\r\nCase #2:\r\n8 7 7 7\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}