PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#LCA0000085. Lưu lượng lớn nhất (Max Flow)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

2 lộ trình

Lưu lượng lớn nhất (Max Flow)

Max Flow

Source: USACO

Version: Phuoc Hung OJ Extended

Problem Statement

There are nn stalls connected by n−1n-1 pipes forming a tree. For each of kk pumping sessions, one unit of milk flows along the unique path from stall aa to stall bb, including both endpoints. Determine the maximum number of sessions passing through any single stall.

Input

First line: n,kn,k. Then n−1n-1 edges u,vu,v and kk source-destination pairs a,ba,b.

Output

Print one integer: the maximum flow through any stall.

Subtasks

  • Subtask 1 (20 points): 2≤n≤352\le n\le 35; 1≤k≤351\le k\le 35; 1≤u,v,a,b≤n1\le u,v,a,b\le n; edges form a tree vô hướng.

  • Subtask 2 (30 points): 2≤n≤12002\le n\le 1200; 1≤k≤12001\le k\le 1200; 1≤u,v,a,b≤n1\le u,v,a,b\le n; edges form a tree vô hướng.

  • Subtask 3 (50 points): 2≤n≤500002\le n\le 50000; 1≤k≤1000001\le k\le 100000; 1≤u,v,a,b≤n1\le u,v,a,b\le n; edges form a tree vô hướng.

Examples

Input

5 3
1 2
1 3
3 4
3 5
1 4
2 5
4 5

Output

3

Explanation

All three paths pass through stall 33, so its flow is 33, the maximum.