#K89097. Final Seat Position

    ID: 37454 Type: Default 1000ms 256MiB

Final Seat Position

Final Seat Position

John is sitting on a circular arrangement of ( n ) seats, numbered from 1 to ( n ). He starts at seat number ( s ) and performs ( t ) hops. A positive ( t ) indicates moving to the right (clockwise), while a negative ( t ) indicates moving to the left (counterclockwise). Since the seats are arranged in a circle, after seat ( n ) it wraps back to seat 1, and before seat 1 it wraps to seat ( n ).

The task is to determine the seat number where John will end up after performing the given hops. Use modular arithmetic with the formula: ( \text{result} = ((s + t - 1) \mod n) + 1 ).

inputFormat

The input consists of three space-separated integers: ( n ) (the total number of seats), ( s ) (the starting seat number), and ( t ) (the number of hops). It is guaranteed that ( n ) and ( s ) are positive and that ( s ) is between 1 and ( n ) (inclusive).

outputFormat

Output a single integer representing the final seat number where John will end up after performing the hops.## sample

8 3 5
8