Олимпиадный тренинг

Задача 32980. Dance


Задача

Темы:
To perform a big dance, N dancers lined up in a circle (N is even). Let's number the dancers by numbers from 1 to N starting from the podium clockwise. At each step of the dance, the dancers are divided into pairs (the pair is formed by two dancers adjacent in a circle), and the dancers in the pair change places, and on the first and all subsequent odd steps, the dancer standing at the beginning of the circle forms a pair with the dancer standing next to him on hour hand. Also, two dancers form a pair, following them clockwise, and so on. In the second step and all even-numbered steps, the dancer standing at the beginning
circle, forms a pair with the dancer standing next to him counterclockwise. The two dancers following them counterclockwise also form a couple, and so on. 
 
The figure shows the initial arrangement for N = 6 dancers and the next two steps of the dance. The location of the podium is marked with a dot.
Determine who will stand next to dancer number P after K steps.

The program receives as input three integers N, P, K, written on separate lines. The first number N – the number of dancers in the circle, N is even. Second number P – dancer number, 1 ≤ P≤ N. Third number K – number of steps taken after the start of the dance, 1 ≤ K. The maximum values ​​for N and K are given in the Grading System section. 
 
The program should output two integers in ascending order – numbers of dancers who will stand next to dancer number P after the K steps of the dance.



Enter Output Note
6
5
2
24 The picture above matches this example.