{"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\u003e给定一棵包含$$$n$$$个顶点的树。选择一个顶点作为根顶点,满足以下条件。\u003c/p\u003e\u003cul\u003e \u003cli\u003e对于所有的顶点$$$v_{1}$$$和$$$v_{2}$$$,如果$$$distance$$$($$$root$$$, $$$v_{1}$$$) $$$\u003d distance$$$($$$root$$$, $$$v_{2})$$$),那么$$$degree$$$($$$v_{1}$$$) $$$\u003d degree$$$($$$v_{2}$$$),其中$$$degree$$$表示与该顶点相连的顶点数,$$$distance$$$表示两个顶点之间的边数。\u003c/li\u003e\u003c/ul\u003e\u003cp\u003e确定并找出是否存在这样的根顶点。如果有多个答案,找出其中任意一个。\u003c/p\u003e"}},{"title":"输入","value":{"format":"HTML","content":"\u003cp\u003e第一行包含一个整数$$$n$$$($$$1 \\le n \\le 10^{5}$$$)— 顶点数。\u003c/p\u003e\u003cp\u003e接下来的$$$n-1$$$行,每行包含两个整数$$$v_{i}$$$和$$$u_{i}$$$($$$1 \\le v_{i} \\lt u_{i} \\le n$$$)— 表示存在一条边连接$$$v_{i}$$$和$$$u_{i}$$$。保证图形成一棵树。\u003c/p\u003e"}},{"title":"输出","value":{"format":"HTML","content":"\u003cp\u003e如果存在这样的根顶点,打印任意一个。否则,打印$$$-1$$$。\u003c/p\u003e"}},{"title":"样例1","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\u003e7\n1 2\n2 3\n3 4\n4 5\n3 6\n6 7\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e3\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e"}},{"title":"样例2","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\u003e6\n1 3\n2 3\n3 4\n4 5\n4 6\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e-1\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e"}},{"title":"注意","value":{"format":"HTML","content":"\u003cp\u003e这是第一个样例的图片。$$$1$$$、$$$5$$$、$$$7$$$也可以是有效答案。\u003c/p\u003e\u003ccenter\u003e \u003cimg class\u003d\"tex-graphics\" src\u003d\"CDN_BASE_URL/bffac00b649183bda02d2436e0a8a717?v\u003d1711259914\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e \u003c/center\u003e\u003cp\u003e这是第二个样例的图片。你可以看到,找不到这样的根顶点是不可能的。\u003c/p\u003e\u003ccenter\u003e \u003cimg class\u003d\"tex-graphics\" src\u003d\"CDN_BASE_URL/f87a5622c37402a9ce3768ab63aadbca?v\u003d1711259914\" style\u003d\"max-width: 100.0%;max-height: 100.0%;\"\u003e \u003c/center\u003e"}}]}