创建于 2026/07/18 · 更新于 2026/07/18
You are given a rooted tree with vertices. The root is vertex .
You are also given paths. The -th path is described by two vertices and and an integer ; it consists of all edges on the simple path between and . It is guaranteed that is an ancestor of , or is an ancestor of .
You may place markers on the edges of the tree. Each edge can hold any number of markers. For each , at least of the placed markers must lie on the edges of the -th path.
Find the minimum total number of markers you need to place.
The first line contains and .
Each of the next lines contains and (, ) — an edge of the tree.
Each of the next lines contains , , (, , ); it is guaranteed that is an ancestor of , or is an ancestor of .
, .
Print a single integer — the minimum total number of markers.
2 1
1 2
1 2 6
6
5 3
3 1
4 3
5 2
4 5
2 4 2
2 3 3
5 3 2
3