M번의 팔로우 이벤트가 일어난 직후마다 확장 과정을 적용해 더 이상 추가할 수 없을 때의 팔로우 관계 총합을 각각 구한다.
어려움9유니온 파인드그래프구현아직 제출이 없습니다시간 제한2초메모리 제한512 MBJoitter is a trending social media where you can share your memories with your friends.
In Joitter, you can follow other users. For example, when a user a follows another user b, user a can read user b’s posts on the timeline. In this case, it is possible that user b follows back user a or not. However, it is impossible that user a follows him/herself or user a follows a particular user b more than once.
N users, consisting of user 1, user 2, . . ., user N, have started using Joitter. At first, none of them follows any other users.
From now on, for M days, following events occur: user Ai follows user Bi on the i-th day (1 ≤ i ≤ M).
The official of Joitter is planning to hold a social exchange event on its service once during the M days. A social exchange event occurs as follows:
The official of Joitter still has not decided when to hold the social exchange event. So, they would like to know the maximum value of the total sum of the number of users each user follows after the social exchange event, if it happens right after the following event of the i-th day, for each i (1 ≤ i ≤ M). We assume that the social exchange event finishes before the following event on the next day.
Write a program that, given the number of users and following events during M days, calculates the maximum value of the total sum of the number of users each user follows after the social exchange event, if the social exchange event falls right after the following event of the i-th day, for each i (1 ≤ i ≤ M).
Read the following data from the standard input. All the values in the input are integers.
N M
A1 B1
.
.
.
AM BM
Write M lines to the standard output. In the i-th line (1 ≤ i ≤ M), output the maximum value of the total sum of the number of users each user follows after the social exchange event, if the social exchange event falls right after the following event of day i.