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

#DSU0000005. Thi công đường (Road Construction)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Thi công đường (Road Construction)

Road Construction

Source: CSES

Version: Phuoc Hung OJ Extended

Problem Statement

There are nn cities and initially no roads. Over mm days, one bidirectional road is built each day. After each day, determine the number of connected components and the size of the largest connected component.

Input

The first line contains two integers n,mn,m. Each of the next mm lines contains two integers a,ba,b, specifying the road built on that day. Cities are numbered from 11 to nn.

Output

After each day, print two integers: the number of connected components and the size of the largest one.

Subtasks

  • Subtask 1 (20 points): 1≤n≤1501\le n\le 150; 1≤m≤1701\le m\le 170; 1≤a,b≤n1\le a,b\le n; a≠ba\ne b.
  • Subtask 2 (30 points): 1≤n≤100001\le n\le 10000; 1≤m≤60001\le m\le 6000; 1≤a,b≤n1\le a,b\le n; a≠ba\ne b.
  • Subtask 3 (50 points): 1≤n≤1000001\le n\le 100000; 1≤m≤2000001\le m\le 200000; 1≤a,b≤n1\le a,b\le n; a≠ba\ne b.

Examples

Input

5 3
1 2
1 3
4 5

Output

4 2
3 3
2 3

Explanation

After 1–2 there are four components, largest size 2; after 1–3, three components and size 3; after 4–5, two components and size 3.