This page is still under construction.

Parts of this page are still being built. What you see may change.

두~~부 두부 두부

Time limit1sMemory limit1024 MB

Summary
Given N players in a circle, caller M, and called mo count K, output the number of the player whose mo count is K, who takes the next turn.
Level

Easy2 of 10

Topics
Math, Implementation
Solved
No attempts yet

Problem

Junseo, who has just finished his exams, is drinking with his friends.

두~~부 두부 두부 으쌰 으쌰 으쌰 두~~부 두부 두부 으쌰 으쌰 으쌰

A lively song starts playing from somewhere, and it makes everyone's shoulders move. The friends get up, dance, and begin to sing along.

Including Junseo, NN people are playing the game while singing. Since they can no longer say long names, they tell each other apart by numbers 11~NN. The friends sit in a circle, with the numbers increasing counterclockwise.
The person numbered MM, who was singing, calls out KK doo-bu.
Junseo, who sees a drinking game he does not know, quietly asks his neighbor Junwoo hyung about the rules.

  • The person whose turn it is calls out one integer KK.
  • The caller becomes the reference point with 33 mo.
  • The neighbor counterclockwise gets 1 more mo, and the neighbor clockwise gets 1 less.
  • The person whose mo count is KK takes the next turn, and the game repeats.
  • Anyone who calls out KK when it is not their turn, or does not call out KK on their own turn, must drink.

Junseo has heard the explanation, but he is too drunk to follow it and cannot tell who goes next. Tell him the number of the next person so he does not get caught by this drinking game!

Input

The first line contains three integers: NN (1≤N≤100 0001 \le N \le 100\,000), the number of people playing, MM (1≤M≤N1 \le M \le N), the number of the person whose turn it is, and KK (−100 000≤K≤100 000-100\,000 \le K \le 100\,000), the mo count called.

Output

Print the number of the person whose turn is next.

Hint

The figure below shows how the players in the doo-bu game work out their mo counts when N=5N=5 and M=2M=2.

Examples2

  1. Example 1

    Input
    7 2 4
    
    Expected output
    3
    
  2. Example 2

    Input
    6 1 -1
    
    Expected output
    3