Dance Mooves#11203

Dance Mooves

1 secondo
128 megabyte
Molto difficile

Farmer John's cows are showing off their new dance moves!

At first, all cows stand in a line, with cow in the -th position. The sequence of dance moves consists of pairs of positions (a_1, b_1), (a_2, b_2), \ldots, (a_k, b_k). During minute , for i = 1, \ldots, k, the cows currently standing in positions a_i and b_i swap places.

The same sequence of swaps is then repeated during minutes k+1, \ldots, 2k, then again during minutes 2k + 1, \ldots, 3k, and so on, continuing cyclically for a total of minutes. In other words:

For each cow, determine the number of distinct positions in the line that she will ever occupy during the minutes.

Input

The first line contains three integers , and m~(2 \le n \le 10^5, 1 \le k \le 2 \cdot 10^5, 1 \le m \le 10^{18}).

Each of the next lines contains two integers a_i and b_i~(1 \le a_i < b_i \le n), describing the positions involved in the -th swap.

Output

Print lines. The -th line should contain the number of distinct positions that cow occupies during the minutes.

Esempi

Esempio 1

Loading
Loading

Nota

After minutes, the cows, in increasing order of position, are [3, 4, 5, 2, 1, 6].

  • Cow reaches positions {1, 2, 3, 4, 5}.

  • Cow reaches positions {1, 2, 3, 4}.

  • Cow reaches positions {1, 2, 3}.

  • Cow reaches positions {2, 3, 4}.

  • Cow reaches positions {3, 4, 5}.

  • Cow never moves, so she remains in position throughout.