Dance Mooves
시간 제한2초메모리 제한512 MB
K개의 교환으로 이루어진 주기를 M분 동안 반복할 때 각 소가 서로 다른 몇 개의 위치를 거치는지 센다.
문제
Farmer John’s cows are showing off their new dance mooves!
At first, all cows () stand in a line with cow in the th position in line. The sequence of dance mooves is given by () pairs of positions . In each minute of the dance, the cows in positions and in line swap. The same swaps happen again in minutes , again in minutes , and so on, continuing in a cyclic fashion for a total of minutes (). In other words,
- In minute , the cows at positions and swap.
- In minute , the cows at positions and swap.
- ...
- In minute , the cows in positions and swap.
- In minute , the cows in positions and swap.
- In minute , the cows in positions and swap.
- and so on ...
For each cow, please determine the number of unique positions in the line she will ever occupy.
입력
The first line contains integers , , and . Each of the next lines contains ().
출력
Print lines of output, where the th line contains the number of unique positions that cow reaches.
예제
이 문제는 공개된 예제가 없습니다.