4 5 0 2 3 2 1 4 1 2 2 3 3 4
2 If we paint the $1$\-st and $3$\-rd edges red and the $2$\-nd edge blue, the piece will traverse the following numbers of red and blue edges: * $0$ red edges and $1$ blue edge when moving from Vertex $2$ to $3$, * $0$ red edges and $1$ blue edge when moving from Vertex $3$ to $2$, * $1$ red edge and $0$ blue edges when moving from Vertex $2$ to $1$, * $2$ red edges and $1$ blue edge when moving from Vertex $1$ to $4$, for a total of $3$ red edges and $3$ blue edges, satisfying the condition.  Another way to satisfy the condition is to paint the $1$\-st and $3$\-rd edges blue and the $2$\-nd edge red. There is no other way to satisfy it, so the answer is $2$.
3 10 10000 1 2 1 2 1 2 2 1 1 2 1 2 1 3
0 There may be no way to paint the tree to satisfy the condition.
10 2 -1 1 10 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10
126
5 8 -1 1 4 1 4 2 1 3 5 1 2 4 1 3 1 1 5
2
{
"problem": {
"name": "Red and Blue Tree",
"description": {
"content": "Given are a tree with $N$ vertices, a sequence of $M$ numbers $A=(A_1,\\ldots,A_M)$, and an integer $K$. The vertices are numbered $1$ through $N$, and the $i$\\-th edge connects Vertices $U_i$ and $V",
"description_type": "Markdown"
},
"platform": "AtCoder",
"limit": {
"time_limit": 2000,
"memory_limit": 262144
},
"difficulty": "None",
"is_remote": true,
"is_sync": true,
"sync_url": null,
"sign": "abc222_e"
},
"statements": [
{
"statement_type": "Markdown",
"content": "Given are a tree with $N$ vertices, a sequence of $M$ numbers $A=(A_1,\\ldots,A_M)$, and an integer $K$. \nThe vertices are numbered $1$ through $N$, and the $i$\\-th edge connects Vertices $U_i$ and $V...",
"is_translate": false,
"language": "English"
}
]
}