2 4 1 2 1 3 1 4 BWWW 4 1 2 1 3 1 4 BBWW
WBBW
-1
For the first test case, suppose the color sequence before the operation was `WBBW`. In this case,
* for vertex $1$, the colors of the connected vertices $2, 3, 4$ are `B`, `B`, `W`, respectively, with $C_1 = {}$`B` occupying the majority;
* for vertex $2$, the color of the connected vertex $1$ is `W`, with $C_2 = {}$`W` occupying the majority;
* for vertex $3$, the color of the connected vertex $1$ is `W`, with $C_3 = {}$`W` occupying the majority;
* for vertex $4$, the color of the connected vertex $1$ is `W`, with $C_4 = {}$`W` occupying the majority.
Therefore, the color sequence after the operation is `BWWW`, satisfying the condition. Similarly, if the color sequence before the operation was `WBBB`, `WBWB`, or `WWBB`, the color sequence after the operation would be `BWWW`, and any of these are considered correct.
For the second test case, the color sequence `BBWW` cannot result from the operation on the given tree.{
"problem": {
"name": "Dyed by Majority (Odd Tree)",
"description": {
"content": "You are given a tree with $N$ vertices. The vertices are labeled from $1$ to $N$, and the $i$\\-th edge connects vertex $A_i$ and vertex $B_i$. Moreover, for every vertex, the **number of incident edge",
"description_type": "Markdown"
},
"platform": "AtCoder",
"limit": {
"time_limit": 2000,
"memory_limit": 262144
},
"difficulty": "None",
"is_remote": true,
"is_sync": true,
"sync_url": null,
"sign": "arc161_c"
},
"statements": [
{
"statement_type": "Markdown",
"content": "You are given a tree with $N$ vertices. The vertices are labeled from $1$ to $N$, and the $i$\\-th edge connects vertex $A_i$ and vertex $B_i$. Moreover, for every vertex, the **number of incident edge...",
"is_translate": false,
"language": "English"
}
]
}