{"trustable":true,"prependHtml":"\u003cstyle type\u003d\"text/css\"\u003e\n section pre {\n display: block;\n padding: 9.5px;\n margin: 0 0 10px;\n font-size: 13px;\n line-height: 1.42857143;\n word-break: break-all;\n word-wrap: break-word;\n color: #333;\n background: rgba(255, 255, 255, 0.5);\n border: 1px solid #ccc;\n border-radius: 6px;\n }\n\u003c/style\u003e\n\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027\\\\(\u0027, right: \u0027\\\\)\u0027, display: false},\n {left: \u0027\\\\[\u0027, right: \u0027\\\\]\u0027, display: true}\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"Problem Statement","value":{"format":"HTML","content":"\r\n\u003csection\u003e\r\n\u003cp\u003eWe have a tree with \u003cvar\u003e\\(N\\)\u003c/var\u003e vertices. The vertices are numbered \u003cvar\u003e\\(1, 2, ..., N\\)\u003c/var\u003e. The \u003cvar\u003e\\(i\\)\u003c/var\u003e-th (\u003cvar\u003e\\(1 ≦ i ≦ N - 1\\)\u003c/var\u003e) edge connects the two vertices \u003cvar\u003e\\(A_i\\)\u003c/var\u003e and \u003cvar\u003e\\(B_i\\)\u003c/var\u003e.\u003c/p\u003e\r\n\u003cp\u003eTakahashi wrote integers into \u003cvar\u003e\\(K\\)\u003c/var\u003e of the vertices. Specifically, for each \u003cvar\u003e\\(1 ≦ j ≦ K\\)\u003c/var\u003e, he wrote the integer \u003cvar\u003e\\(P_j\\)\u003c/var\u003e into vertex \u003cvar\u003e\\(V_j\\)\u003c/var\u003e. The remaining vertices are left empty. After that, he got tired and fell asleep.\u003c/p\u003e\r\n\u003cp\u003eThen, Aoki appeared. He is trying to surprise Takahashi by writing integers into all empty vertices so that the following condition is satisfied:\u003c/p\u003e\r\n\u003cul\u003e\r\n\u003cli\u003eCondition: For any two vertices directly connected by an edge, the integers written into these vertices differ by exactly \u003cvar\u003e\\(1\\)\u003c/var\u003e.\u003c/li\u003e\r\n\u003c/ul\u003e\r\n\u003cp\u003eDetermine if it is possible to write integers into all empty vertices so that the condition is satisfied. If the answer is positive, find one specific way to satisfy the condition.\u003c/p\u003e\r\n\u003c/section\u003e\r\n"}},{"title":"Constraints","value":{"format":"HTML","content":"\r\n\u003csection\u003e\r\n\u003cul\u003e\r\n\u003cli\u003e\u003cvar\u003e\\(1 ≦ N ≦ 10^5\\)\u003c/var\u003e\u003c/li\u003e\r\n\u003cli\u003e\u003cvar\u003e\\(1 ≦ K ≦ N\\)\u003c/var\u003e\u003c/li\u003e\r\n\u003cli\u003e\u003cvar\u003e\\(1 ≦ A_i, B_i ≦ N\\)\u003c/var\u003e (\u003cvar\u003e\\(1 ≦ i ≦ N - 1\\)\u003c/var\u003e)\u003c/li\u003e\r\n\u003cli\u003e\u003cvar\u003e\\(1 ≦ V_j ≦ N\\)\u003c/var\u003e (\u003cvar\u003e\\(1 ≦ j ≦ K\\)\u003c/var\u003e) (21:18, a mistake in this constraint was corrected)\u003c/li\u003e\r\n\u003cli\u003e\u003cvar\u003e\\(0 ≦ P_j ≦ 10^5\\)\u003c/var\u003e (\u003cvar\u003e\\(1 ≦ j ≦ K\\)\u003c/var\u003e)\u003c/li\u003e\r\n\u003cli\u003eThe given graph is a tree.\u003c/li\u003e\r\n\u003cli\u003eAll \u003cvar\u003e\\(v_j\\)\u003c/var\u003e are distinct.\u003c/li\u003e\r\n\u003c/ul\u003e\r\n\u003c/section\u003e\r\n"}},{"title":"Input","value":{"format":"HTML","content":"\r\n\u003csection\u003e\r\n\u003cp\u003eThe input is given from Standard Input in the following format:\u003c/p\u003e\r\n\u003cpre\u003e\u003cvar\u003e\\(N\\)\u003c/var\u003e\r\n\u003cvar\u003e\\(A_1\\)\u003c/var\u003e \u003cvar\u003e\\(B_1\\)\u003c/var\u003e\r\n\u003cvar\u003e\\(A_2\\)\u003c/var\u003e \u003cvar\u003e\\(B_2\\)\u003c/var\u003e\r\n\u003cvar\u003e\\(:\\)\u003c/var\u003e\r\n\u003cvar\u003e\\(A_{N-1}\\)\u003c/var\u003e \u003cvar\u003e\\(B_{N-1}\\)\u003c/var\u003e\r\n\u003cvar\u003e\\(K\\)\u003c/var\u003e\r\n\u003cvar\u003e\\(V_1\\)\u003c/var\u003e \u003cvar\u003e\\(P_1\\)\u003c/var\u003e\r\n\u003cvar\u003e\\(V_2\\)\u003c/var\u003e \u003cvar\u003e\\(P_2\\)\u003c/var\u003e\r\n\u003cvar\u003e\\(:\\)\u003c/var\u003e\r\n\u003cvar\u003e\\(V_K\\)\u003c/var\u003e \u003cvar\u003e\\(P_K\\)\u003c/var\u003e\r\n\u003c/pre\u003e\r\n\r\n\u003c/section\u003e\r\n"}},{"title":"Output","value":{"format":"HTML","content":"\r\n\u003csection\u003e\r\n\u003cp\u003eIf it is possible to write integers into all empty vertices so that the condition is satisfied, print \u003ccode\u003eYes\u003c/code\u003e. Otherwise, print \u003ccode\u003eNo\u003c/code\u003e.\u003c/p\u003e\r\n\u003cp\u003eIf it is possible to satisfy the condition, print \u003cvar\u003e\\(N\\)\u003c/var\u003e lines in addition. The \u003cvar\u003e\\(v\\)\u003c/var\u003e-th (\u003cvar\u003e\\(1 ≦ v ≦ N\\)\u003c/var\u003e) of these \u003cvar\u003e\\(N\\)\u003c/var\u003e lines should contain the integer that should be written into vertex \u003cvar\u003e\\(v\\)\u003c/var\u003e. If there are multiple ways to satisfy the condition, any of those is accepted.\u003c/p\u003e\r\n\u003c/section\u003e\r\n"}},{"title":"Sample 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\u003e5\r\n1 2\r\n3 1\r\n4 3\r\n3 5\r\n2\r\n2 6\r\n5 7\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eYes\r\n5\r\n6\r\n6\r\n5\r\n7\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\r\n\u003csection\u003e\r\n\r\n\r\n\u003c/section\u003e\r\n\r\n\u003csection\u003e\r\n\r\n\r\n\u003cp\u003eThe figure below shows the tree when Takahashi fell asleep. For each vertex, the integer written beside it represents the index of the vertex, and the integer written into the vertex is the integer written by Takahashi.\u003c/p\u003e\r\n\u003cdiv style\u003d\"text-align: center;\"\u003e\r\n\u003cimg alt\u003d\"6da26f89839711a520acdf5c3e1cc309.png\" src\u003d\"CDN_BASE_URL/07900bbff1a76bc94001eef14302b8eb?v\u003d1714806856\"\u003e\r\n\u003c/div\u003e\r\n\r\n\u003cp\u003eAoki can, for example, satisfy the condition by writing integers into the remaining vertices as follows:\u003c/p\u003e\r\n\u003cdiv style\u003d\"text-align: center;\"\u003e\r\n\u003cimg alt\u003d\"1858d5af5a2c0e51aca39a39d765debb.png\" src\u003d\"CDN_BASE_URL/066dfc8c38453e28aa2af5178f845797?v\u003d1714806856\"\u003e\r\n\u003c/div\u003e\r\n\r\n\u003cp\u003eThis corresponds to Sample Output 1. Note that other outputs that satisfy the condition will also be accepted, such as:\u003c/p\u003e\r\n\u003cpre\u003eYes\r\n7\r\n6\r\n8\r\n7\r\n7\r\n\u003c/pre\u003e\r\n\r\n\u003c/section\u003e\r\n"}},{"title":"Sample 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\u003e5\r\n1 2\r\n3 1\r\n4 3\r\n3 5\r\n3\r\n2 6\r\n4 3\r\n5 7\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eNo\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\r\n\u003csection\u003e\r\n\r\n\r\n\u003c/section\u003e\r\n\r\n\u003csection\u003e\r\n\r\n\r\n\u003c/section\u003e\r\n"}},{"title":"Sample 3","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\r\n1 2\r\n2 3\r\n3 4\r\n1\r\n1 0\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eYes\r\n0\r\n-1\r\n-2\r\n-3\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\r\n\u003csection\u003e\r\n\r\n\r\n\u003c/section\u003e\r\n\r\n\u003csection\u003e\r\n\r\n\r\n\u003cp\u003eThe integers written by Aoki may be negative or exceed \u003cvar\u003e\\(10^6\\)\u003c/var\u003e.\u003c/p\u003e\u003c/section\u003e\r\n"}}]}