{"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\"\u003eBessie and her friend Elsie decide to have a meeting. However, after Farmer John decorated his\u003cbr\u003efences they were separated into different blocks. John\u0027s farm are divided into $n$ blocks labelled from $1$ to $n$.\u003cbr\u003eBessie lives in the first block while Elsie lives in the $n$-th one. They have a map of the farm\u003cbr\u003ewhich shows that it takes they $t_i$ minutes to travel from a block in $E_i$ to another block\u003cbr\u003ein $E_i$ where $E_i~(1\\le i\\le m)$ is a set of blocks. They want to know how soon they can meet each other\u003cbr\u003eand which block should be chosen to have the meeting.\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"The first line contains an integer $T~(1\\le T\\le 6)$, the number of test cases. Then $T$ test cases\u003cbr\u003efollow.\u003cbr\u003e\u003cbr\u003eThe first line of input contains $n$ and $m$. $2 \\leq n \\leq 10^5$. The following $m$ lines describe the sets $E_i~(1\\le i\\le m)$. Each line will contain two integers $t_i(1 \\leq t_i \\leq 10^9)$ and $S_i~(S_i\u0026gt;0)$ firstly. Then $S_i$ integer follows which are the labels of blocks in $E_i$. It is guaranteed that $\\sum_{i\u003d1}^m{S_i} \\leq 10^6$."}},{"title":"Output","value":{"format":"HTML","content":"For each test case, if they cannot have the meeting, then output \"Evil John\" (without quotes) in one line.\u003cbr\u003e\u003cbr\u003eOtherwise, output two lines. The first line contains an integer, the time it takes for they to meet.\u003cbr\u003eThe second line contains the numbers of blocks where they meet. If there are multiple\u003cbr\u003eoptional blocks, output all of them in ascending order."}},{"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\n5 4\r\n1 3 1 2 3\r\n2 2 3 4\r\n10 2 1 5\r\n3 3 3 4 5\r\n3 1\r\n1 2 1 2\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eCase #1: 3\r\n3 4\r\nCase #2: Evil John\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Hint","value":{"format":"HTML","content":"\u003cbr\u003eIn the first case, it will take Bessie 1 minute travelling to the 3rd block, and it will take Elsie 3 minutes travelling to the 3rd block. It will take Bessie 3 minutes travelling to the 4th block, and it will take Elsie 3 minutes travelling to the 4th block. In the second case, it is impossible for them to meet.\u003cbr\u003e"}}]}