{"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\"\u003eRecently Tom is playing an interesting game. The game contains a social network, so players can make friends with each other. The friend relation is symmetric, which means if A is a friend of B, B is also a friend of A.\u003cbr\u003ePlayers’ ratings are distinct from each other, which means there are no two players sharing a same rating. Each player owns a ranklist containing all his friends’ rating (including himself) and there is one leader who has the highest rating in each player’s ranklist.\u003cbr\u003eTom has N friends. During the communications with these friends, he knows some pairs of friends are also friends. But he doesn’t know all the such pairs. In other words, some friends maybe are friends but Tom doesn’t know it.\u003cbr\u003eOne day, Tom noticed that the system started showing the number of leaders for every friend.\u003cbr\u003eE.g. the system may says Peter is leader on 3 players’ ranklist.\u003cbr\u003eNow Tom can see the number of leaders for every friend. He would like to know the least number of strangers’ ranklist leader are his friends.\u003cbr\u003e\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The first line of the input gives the number of test cases, T. T test cases follow. Each test case starts with a line consists of 3 integers, N, M and R representing the number of people on Tom’s ranklist(including Tom), the number of friendships Tom knows and the rank of Tom in his ranklist(1-indexed). The next line consists of N integers, the $i^{th}$ integer $C_i$ represents the number of leaders for the friend on rank i. The following M lines each consists of 2 integers $X_i$ , $Y_i$ , means that the friend on rank $X_i$ is a friend of friend on rank $Y_i$.\u003cbr\u003e"}},{"title":"Output","value":{"format":"HTML","content":"For each test case, output one line containing “Case #x: y”, where x is the test case number (starting from 1) and y is the least number of ranklists that not owned by Tom’s friend but the leader is Tom’s friend.\u003cbr\u003e\u003ch2\u003elimits\u003c/h2\u003e\u003cbr\u003e$\\bullet 1 ≤ T ≤ 100.$\u003cbr\u003e$\\bullet 1 ≤ N, M ≤ 10^5.$\u003cbr\u003e$\\bullet 1 ≤ X_i ≤ N.$\u003cbr\u003e$\\bullet 1 ≤ Y_i ≤ N.$\u003cbr\u003e$\\bullet 1 ≤ R ≤ N.$\u003cbr\u003e$\\bullet R \\neq X_i .$\u003cbr\u003e$\\bullet R \\neq Y_i .$\u003cbr\u003e$\\bullet X_i \\neq Y_i .$\u003cbr\u003e$\\bullet 0 ≤ C_i ≤ 10^9.$\u003cbr\u003e$\\bullet$ It’s guaranteed that the data is valid.\u003cbr\u003e\u003cbr\u003e"}},{"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\n4 0 3\r\n1 0 0 2\r\n4 1 4\r\n1 0 2 0\r\n1 3\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eCase #1: 2\r\nCase #2: 2\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}