Vasya lives in a round building, whose entrances are numbered sequentially by integers from 1 to n. Entrance n and entrance 1 are adjacent.

Today Vasya got bored and decided to take a walk in the yard. Vasya lives in entrance a and he decided that during his walk he will move around the house b entrances in the direction of increasing numbers (in this order entrance n should be followed by entrance 1). The negative value of b corresponds to moving |b| entrances in the order of decreasing numbers (in this order entrance 1 is followed by entrance n). If b = 0, then Vasya prefers to walk beside his entrance. [Image] Illustration for n = 6, a = 2, b =  - 5. 

Help Vasya to determine the number of the entrance, near which he will be at the end of his walk.


-----Input-----

The single line of the input contains three space-separated integers n, a and b (1 ≤ n ≤ 100, 1 ≤ a ≤ n,  - 100 ≤ b ≤ 100) — the number of entrances at Vasya's place, the number of his entrance and the length of his walk, respectively.


-----Output-----

Print a single integer k (1 ≤ k ≤ n) — the number of the entrance where Vasya will be at the end of his walk.


-----Examples-----
Input
6 2 -5

Output
3

Input
5 1 3

Output
4

Input
3 2 7

Output
3



-----Note-----

The first example is illustrated by the picture in the statements.

Difficulty: EASY

Solutions:
(n, a, b) = [int(x) for x in input().split()]
if b < 0:
	if abs(b) > n:
		b = -(abs(b) % n)
	b = n + b
if (a + b) % n == 0:
	print(n)
else:
	print((a + b) % n)


(n, a, b) = (int(x) for x in input().split())
a = a + b
while a < 1:
	a += n
while a > n:
	a -= n
print(a)


L = [int(s) for s in input().split()]
n = L[0]
a = L[1]
b = L[2]
if b > 0:
	if (a + b) % n == 0:
		print(n)
	else:
		print((a + b) % n)
else:
	r = a + b
	while r < 0:
		r += n
	if r == 0:
		print(n)
	else:
		print(r)


(n, a, b) = map(int, input().split())
if (a + b) % n == 0:
	print(n)
else:
	print((a + b) % n)


import sys
(n, a, b) = [int(i) for i in input().split(' ')]
print((a + b - 1) % n + 1)


(n, a, b) = input().split(' ')
print((int(a) + int(b) - 1) % int(n) + 1)


(n, a, b) = map(int, input().split())
ans = a + b
while ans < 0:
	ans += n
ans %= n
if ans == 0:
	print(n)
else:
	print(ans)


(n, a, b) = map(int, input().split())
if b == 0:
	print(a)
elif b > 0:
	a += b
	a %= n
	if a == 0:
		print(n)
	else:
		print(a)
elif b < 0:
	b = b * -1 % n
	nn = n
	nn -= b
	a = a + nn
	a %= n
	if a == 0:
		print(n)
	else:
		print(a)


(n, a, b) = map(int, input().split())
if b == 0:
	print(a)
elif b > 0:
	b = b % n
	if b == 0:
		print(a)
	else:
		x = (a + b) % n
		if x == 0:
			x = a + b
		print(x)
else:
	b = -1 * (abs(b) % n)
	if b == 0:
		print(a)
	else:
		b = abs(b) - a
		if n - b > n:
			print((n - b) % n)
		else:
			print(n - b)


(a, b, c) = map(int, input().split())
sum = b + c
count = 2 * a
x = sum % count
d = x % a
if d == 0:
	print(a)
else:
	print(d)


nab = list(map(int, input().split()))
ans = (nab[1] + nab[2]) % nab[0]
if ans == 0:
	print(nab[0])
else:
	print((nab[1] + nab[2]) % nab[0])


m = input().split(' ')
n = int(m[0])
a = int(m[1])
b = int(m[2])
k = (a + b) % n
if k == 0:
	k = n
print(k)


(n, a, b) = tuple((int(x) for x in input().split()))
b %= n
m = a + b
if m >= 0:
	m = 1 + (m - 1) % n
else:
	m = n - m
print(m)


(n, a, b) = map(int, input().split())
res = (a - 1 + b + 1000 * n) % n + 1
print(res)


(n, a, b) = map(int, input().split())
if b < 0:
	if not (a + n + b) % n:
		print(n)
	else:
		print((a + n + b) % n)
elif not (a + b) % n:
	print(n)
else:
	print((a + b) % n)


__author__ = 'artyom'

def main():
	(n, a, b) = read(3)
	r = (a + b) % n
	if r < 0:
		r += n
	elif r == 0:
		r = n
	return r

def read(mode=1, size=None):
	if mode == 0:
		return input().strip()
	if mode == 1:
		return int(input().strip())
	if mode == 2:
		return input().strip().split()
	if mode == 3:
		return list(map(int, input().strip().split()))
	a = []
	for _ in range(size):
		a.append(read(3))
	return a

def write(s='\n'):
	if s is None:
		s = ''
	if isinstance(s, tuple) or isinstance(s, list):
		s = ' '.join(map(str, s))
	s = str(s)
	print(s, end='\n')
write(main())


import math

def get_primes(prime_supr):
	is_prime = [0] * 2 + [1] * prime_supr
	for i in range(2, int(math.sqrt(prime_supr)) + 1):
		if is_prime[i]:
			for j in range(i * i, prime_supr + 1, i):
				is_prime[j] = 0
	return is_prime
get_int = lambda : map(int, input().split())
(n, a, b) = get_int()
ans = [n] + [i for i in range(1, n)]
print(ans[(a + b) % n])


(n, a, b) = map(int, input().split())
c = b % n
print((a + c - 1) % n + 1)


(n, a, b) = map(int, input().split())
ans = (a + b - 1) % n + 1
print(ans)


(n, a, b) = map(int, input().split())
s = (a + b) % n
if s == 0:
	s = n
print(s)


def main():
	(n, a, b) = (int(x) for x in input().split())
	print(solver(n, a, b))

def solver(n, a, b):
	house = (a + b) % n
	if house == 0:
		return n
	else:
		return house
main()


(n, a, b) = map(int, input().split())
steps = abs(b) % n
if b == 0:
	print(a)
elif b > 0:
	if steps + a > n:
		print(steps + a - n)
	else:
		print(steps + a)
elif b < 0:
	if a - steps < 0:
		print(n - abs(a - steps))
	elif a - steps == 0:
		print(n)
	else:
		print(a - steps)


(n, a, b) = map(int, input().split())
r = abs(b) % n
if b > 0:
	m = n - a
	if r <= m:
		h = a + r
	else:
		r -= m
		h = n
		if r != 0:
			h = 1
			r -= 1
		while r:
			h += 1
			r -= 1
	print(h)
elif b < 0:
	m = a - 1
	if r <= m:
		h = a - r
	else:
		r -= m
		h = 1
		if r != 0:
			h = n
			r -= 1
		while r:
			h -= 1
			r -= 1
	print(h)
else:
	print(a)


(n, a, b) = map(int, input().split())

def plus(i):
	if i == n:
		return 1
	else:
		return i + 1

def menos(i):
	if i == 1:
		return n
	else:
		return i - 1
if b == 0:
	print(a)
elif b > 0:
	for i in range(b):
		a = plus(a)
	print(a)
else:
	for i in range(abs(b)):
		a = menos(a)
	print(a)


(n, a, b) = [int(x) for x in input().split()]
if b > 0:
	i = 1
else:
	i = -1
b = abs(b)
while b != 0:
	a += i
	if a > n:
		a -= n
	if a < 1:
		a += n
	b -= 1
print(a)


from collections import deque as de
import math
from collections import Counter as cnt
from functools import reduce
from typing import MutableMapping
from itertools import groupby as gb
from fractions import Fraction as fr

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

class My_stack:

	def __init__(self):
		self.data = []

	def my_push(self, x):
		return self.data.append(x)

	def my_pop(self):
		return self.data.pop()

	def my_peak(self):
		return self.data[-1]

	def my_contains(self, x):
		return self.data.count(x)

	def my_show_all(self):
		return self.data

	def isEmpty(self):
		return len(self.data) == 0
arrStack = My_stack()

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def get_prime_factors(number):
	prime_factors = []
	while number % 2 == 0:
		prime_factors.append(2)
		number = number / 2
	for i in range(3, int(math.sqrt(number)) + 1, 2):
		while number % i == 0:
			prime_factors.append(int(i))
			number = number / i
	if number > 2:
		prime_factors.append(int(number))
	return prime_factors

def get_frequency(list):
	dic = {}
	for ele in list:
		if ele in dic:
			dic[ele] += 1
		else:
			dic[ele] = 1
	return dic

def Log2(x):
	return math.log10(x) / math.log10(2)

def isPowerOfTwo(n):
	return math.ceil(Log2(n)) == math.floor(Log2(n))

def ceildiv(x, y):
	return (x + y - 1) // y
(n, a, b) = map(int, input().split())
if b > 0:
	while b:
		b -= 1
		a += 1
		if a > n:
			a = 1
else:
	temp = abs(b)
	while temp:
		temp -= 1
		a -= 1
		if a < 1:
			a = n
print(a)


(n, a, b) = map(int, input().split())
x = (a + b) % n
if x == 0:
	x = n
print(x)


nab = input().split()
(n, a, b) = (int(nab[0]), int(nab[1]), int(nab[2]))
if (a + b) % n == 0:
	print(n)
else:
	print((a + b) % n)


(n, a, b) = list(map(int, input().split()))
c = [i for i in range(1, n + 1)]
x = c.index(a)
print(c[(x + b) % n])


(n, a, b) = map(int, input().split())
ret = (a + b) % n
if ret == 0:
	ret = n
print(ret)


(n, m, k) = list(map(int, input().split()))
if (m + k) % n == 0:
	print(n)
else:
	print((m + k) % n)


X = list(map(int, input().split()))
Now = X[1]
while X[2] != 0:
	Now += -1 if X[2] < 0 else 1
	Now = X[0] if Now == 0 else 1 if Now == X[0] + 1 else Now
	X[2] += -1 if X[2] > 0 else 1
print(Now)


(n, a, b) = map(int, input().split())
r = (a + b + n * 100) % n
print(r + (not r) * n)


(n, a, b) = list(map(int, list(input().split())))
m = (a + b + n) % n
if m == 0:
	print(n)
else:
	print(m)


temp = input().split(' ')
(entrances, currentPosition, walk) = [int(x) for x in temp]
result = (walk + currentPosition - 1) % entrances
print(1 + result)


(n, a, b) = map(int, input().split(' '))
k = a + b
l = k % n
if l == 0:
	print(n)
else:
	print(l)


string = input()
numbers = string.split(' ')
n = int(numbers[0])
a = int(numbers[1])
b = int(numbers[2])
x = abs(a + b % n)
if x % n == 0:
	print(n)
else:
	print(x % n)


input_list = input().split()
print(((int(input_list[1]) + int(input_list[2])) % int(input_list[0]) + int(input_list[0]) - 1) % int(input_list[0]) + 1)


s = input().split()
a = int(s[1])
b = int(s[2])
n = int(s[0])
b = b % n
a = (a + b) % n
if a == 0:
	a = n
print(a)


(n, a, k) = map(int, input().split())
if (a + k) % n == 0:
	print(n)
else:
	print((a + k) % n)


import os
import sys
from math import *
from collections import *
from bisect import *
from io import BytesIO, IOBase
from fractions import *

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
(n, a, b) = value()
b %= n
ans = (a + b) % n
if ans == 0:
	ans = n
print(ans)


s = input()
(n, a, b) = map(int, s.split(' '))
print((a + b - 1) % n + 1)


(n, a, b) = input().split()
(n, a, b) = (int(n), int(a), int(b))
if b > 0:
	Sum = a + b % n
	if Sum > n:
		Sum = Sum - n
	print(Sum)
elif b < 0:
	Sum = a - abs(b) % n
	if Sum <= 0:
		Sum = Sum + n
	print(Sum)
elif b == 0:
	print(a)


string = input().split()
n = int(string[0])
a = int(string[1])
b = int(string[2])
if b == 0:
	print(a)
elif b > 0:
	res = (a + b % n) % n
	if res == 0:
		res = n
	print(res)
else:
	res = a - abs(b) % n
	if res == 0:
		res = n
	if res < 0:
		res = n + res
	print(res)


(n, a, b) = map(int, input().split())
for i in range(abs(b)):
	if n == 1:
		break
	elif b >= 0:
		if n == a:
			a = 0
		a += 1
		if a == n and i != abs(b) - 1:
			a = 0
	elif b < 0:
		if a == 1:
			a = n + 1
		a -= 1
		if a == 1 and i != abs(b) - 1:
			a = n + 1
for i in range(100):
	if abs(a) > n:
		a = a - n
	else:
		break
print(abs(a))


import sys
input = sys.stdin.readline

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def factorial(x, m):
	val = 1
	while x > 0:
		val = val * x % m
		x -= 1
	return val

def fact(x):
	val = 1
	while x > 0:
		val *= x
		x -= 1
	return val

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def nCr(n, k):
	if k > n:
		return 0
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def upper_bound(a, x, lo=0, hi=None):
	if hi == None:
		hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	(prime[0], prime[1]) = (False, False)
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
spf = [0 for i in range(MAXN)]

def factoriazation(x):
	res = []
	for i in range(2, int(x ** 0.5) + 1):
		while x % i == 0:
			res.append(i)
			x //= i
	if x != 1:
		res.append(x)
	return res

def int_array():
	return list(map(int, input().strip().split()))

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
from itertools import permutations
import math
from bisect import bisect_left

def solve():
	(n, a, b) = map(int, input().split())
	ans = (a + b + n) % n
	if ans == 0:
		print(n)
		return
	print(ans)
for _ in range(1):
	solve()


raw = str(input()).split()
n = int(raw[0])
a = int(raw[1]) - 1
b = int(raw[2])
print((a + b) % n + 1)


s = input().split()
a = int(s[0])
b = int(s[1])
n = int(s[2])
if n == 0:
	print(b)
elif b > 0:
	if (n + b) % a == 0:
		print(a)
	else:
		print((n + b) % a)
elif b < 0:
	print(abs(a - b) % n)


t = input().split()
n = int(t[0])
a = int(t[1]) - 1
b = int(t[2])
print((a + b) % n + 1)


(n, a, b) = map(int, input().split())
if b == 0:
	print(a)
elif b < 0:
	k = abs(b)
	while k != 0:
		a -= 1
		if a == 0:
			a = n
		k -= 1
	print(a)
else:
	k = b
	while k != 0:
		a += 1
		if a > n:
			a = 1
		k -= 1
	print(a)


(n, a, b) = map(int, input().split(' '))
result = a + b % n
if result > n:
	result = result % n
print(result)


(n, a, b) = map(int, input().split())
print(range(n)[(a + b - 1) % n] + 1)


(n, a, b) = map(int, input().split())
b %= n
a += b
if a > n:
	a -= n
elif a < 1:
	a += n
print(a)


l = list(map(int, input().split()))
ans = (l[1] + l[2]) % l[0]
if ans == 0:
	ans = l[0]
print(ans)


from sys import stdin, stdout
(n, a, b) = map(int, stdin.readline().rstrip().split())
stdout.write(str((a + b) % n or n) + '\n')


(n, a, b) = [int(i) for i in input().split()]
print((a + b - 1) % n + 1)


(n, a, b) = list(map(int, input().split()))
print(((a - 1 + b) % n + n) % n + 1)


(n, a, k) = map(int, input().split())
if k < 0:
	k = abs(k)
	if k <= a - 1:
		print(a - k)
	else:
		k -= a - 1
		k = k % n
		print([n - k + 1, 1][k == 0])
else:
	k = abs(k)
	if k <= n - a:
		print(a + k)
	else:
		k -= n - a
		k = k % n
		print([k, n][k == 0])


(n, a, b) = [int(x) for x in input().split()]
b = b % n
ans = a + b
if b > 0:
	if ans > n:
		ans = ans - n
elif ans < 1:
	ans = ans + n
print(ans)


(n, a, b) = list(map(int, input().split()))
c = (n * 100 + a + b) % n
print([c, n][c == 0])


(n, a, b) = map(int, input().split())
if b > 0:
	pos = (a + b) % n
	if pos == 0:
		pos = n
elif b == 0:
	pos = a
else:
	remain = abs(b) % n
	b = n - remain
	pos = (a + b) % n
	if pos == 0:
		pos = n
print(pos)


a1 = input().split()
a = [int(a1[i]) for i in range(len(a1))]
n = a[2] % a[0] + a[1]
print(n % a[0]) if n % a[0] != 0 else print(a[0])


import sys

class walk:

	def __init__(self, house, start, distance):
		self.h = house
		self.s = start
		self.d = distance

	def calEnd(self):
		rem = (self.s + self.d) % self.h
		if rem == 0:
			return self.h
		return abs(rem)

def main():
	(hou, start, dis) = [int(x) for x in sys.stdin.readline().split()]
	w = walk(hou, start, dis)
	print(w.calEnd())
main()


e = input().split()
p = int(e[0])
a = int(e[1])
b = int(e[2])
negativo = b < 0
b = abs(b)
i = a
if negativo:
	while b > 0:
		if i == 0:
			i = p
		i -= 1
		b -= 1
else:
	while b > 0:
		if i == p:
			i = 0
		i += 1
		b -= 1
if i != 0:
	print(i)
else:
	print(p)


import math
import collections
import bisect
import heapq
import time
import random
import itertools
import sys
(n, a, b) = map(int, input().split())
ans = (a + b - 1 + n * abs(b)) % n + 1
print(ans)


(n, a, b) = map(int, input().split())
for i in range(abs(b)):
	if b < 0:
		a -= 1
		if a == 0:
			a = n
	if b >= 0:
		a += 1
		if a == n + 1:
			a = 1
print(a)


(n, a, b) = [int(j) for j in input().split()]
k = (a % n + b % n) % n
if k == 0:
	k = n
print(k)


(house, pos, steps) = map(int, input().split(' '))
houses = list(range(1, house + 1))
houses = houses * (abs(steps) // house + 2)
print(houses[pos - 1 + steps])


def read_file():
	with open('input.txt', 'r') as f:
		return f.readlines()

def write_file(data):
	with open('output.txt', 'w') as f:
		f.write(data)
(n, a, b) = map(int, input().split())
d = (a + b % n) % n
print(d if d != 0 else n)


(n, a, w) = map(int, input().split())
w1 = abs(w)
w1 = w1 % n
if w1 == 0:
	print(a)
elif w > 0:
	if a + w1 <= n:
		print(a + w1)
	else:
		print(a + w1 - n)
elif w < 0:
	w1 = n - w1
	if a + w1 <= n:
		print(a + w1)
	else:
		print(a + w1 - n)


(n, m, b) = map(int, input().split())
b = b % n
if b + m >= 0:
	e = abs(m + b) % n
else:
	e = abs(n + b + m) % n
if e == 0:
	print(n)
else:
	print(e)


(n, a, b) = map(int, input().split())
d = a + b
if d > n:
	for i in range(10000):
		d -= n
		if d <= n:
			print(d)
			break
elif d < 1:
	for i in range(10000):
		d += n
		if d >= 1:
			print(d)
			break
else:
	print(d)


(n, a, b) = map(int, input().split())
loc = (a + b) % n
if loc == 0:
	loc = n
print(loc)


(n, a, b) = (int(z) for z in input().split())
if b >= 0:
	for i in range(b):
		a += 1
	a %= n
if b < 0:
	for i in range(-b):
		a -= 1
	a %= n
if a == 0:
	a = n
print(a)


(rs, ri, rai) = (input, lambda : int(input()), lambda : list(map(int, input().split())))
(n, a, b) = rai()
(a, b) = (a - 1, b)
print((a + b) % n + 1)


(n, a, b) = map(int, input().split())
for f in range(abs(b)):
	if b > 0:
		a += 1
		if a == n + 1:
			a = 1
	else:
		a -= 1
		if a == 0:
			a = n
print(a)


(n, a, b) = list(map(int, input().split(' ')))
x = (a + 100 * n + b) % n
if x == 0:
	print(n)
else:
	print(x)


(n, a, b) = [int(x) for x in input().split()]
c = 1
if b < 0:
	c = -1
for i in range(abs(b)):
	a += c
	if a == 0:
		a = n
	if a > n:
		a = 1
print(a)


(a, b, c) = list(map(int, input().split(' ')))
print(((b - 1 + c) % a + a) % a + 1)


(n, a, b) = map(int, input().split())
if b > 0:
	for i in range(b):
		a += 1
		if a == n + 1:
			a = 1
	print(a)
elif b == 0:
	print(a)
else:
	b *= -1
	for i in range(b):
		a -= 1
		if a == 0:
			a = n
	print(a)


(n, h, p) = map(int, input().split())
res = (h + p) % n if p > 0 else (n + h + p) % n
print(n if res == 0 else res)


(n, a, b) = map(int, input().split())
ans = (a + b % n) % n
print([n, ans][bool(ans)])


(n, a, b) = map(int, input().split())
array = [i for i in range(1, n + 1)]
print(array[(a - 1 + b) % n])


def go_to(starts, ends, numbers):
	return (starts % numbers + ends % numbers) % numbers
n = input().split()
k = go_to(int(n[1]), int(n[2]), int(n[0]))
if k == 0:
	print(int(n[0]))
else:
	print(k)


row = input().split()
n = int(row[0])
a = int(row[1])
b = int(row[2])
if b == 0:
	print(a)
elif b < 0:
	rem = abs(b) % n
	if a - rem == 0:
		print(n)
	elif a - rem > 0:
		print(a - rem)
	else:
		print(n - (rem - a))
else:
	rem = b % n
	if rem + a > n:
		print((rem + a) % n)
	else:
		print(rem + a)


(n, a, b) = map(int, input().split())
if b < 0:
	num = b + a
	if num == 0:
		print(n)
	elif num > 0:
		print(num)
	else:
		k = abs(num) % n
		k = n - k
		print(k)
elif b == 0:
	print(a)
else:
	num = b + a
	if num > n:
		k = num % n
		if k == 0:
			print(n)
		else:
			print(k)
	else:
		print(num)


(n, a, b) = map(int, input().split())
result = (a + b - 1) % n + 1
print(result)


read_ints = lambda : list(map(int, input().split()))

def solve(n, a, b):
	return (a - 1 + b) % n + 1
(n, a, b) = read_ints()
print(solve(n, a, b))


import math, fractions
(n, a, b) = [int(x) for x in input().split()]
tn = b % n
ans = (a + tn) % n
if ans == 0:
	ans = n
print(ans)


from collections import deque
li = deque([])
(n, a, k) = input().split()
n = int(n)
a = int(a)
if k[0] == '-':
	f = k[0]
	k = int(k[1:])
else:
	f = '+'
	k = int(k)
for i in range(int(a), int(n + 1)):
	li.append(i)
for i in range(1, a):
	li.append(i)
if f == '-':
	for i in range(k):
		j = li.pop()
		li.appendleft(j)
else:
	for i in range(k):
		j = li.popleft()
		li.append(j)
print(li[0])


(n, a, b) = map(int, input().split())
if b == 0:
	print(a)
	quit()
m = abs(b)
d = m // b
while m > 0:
	m -= 1
	if a + d > n:
		a = 1
	elif a + d < 1:
		a = n
	else:
		a += d
print(a)


(n, a, b) = map(int, input().split())
d = 1
if b < 0:
	d = -1
	b = abs(b)
while b > 0:
	a += d
	if a == n + 1:
		a = 1
	if a == 0:
		a = n
	b -= 1
print(a)


s = list(map(int, input().split()))
print((s[1] + s[2] - 1) % s[0] + 1)


import math
(n, a, b) = [int(x) for x in input().split()]
if b < 0:
	m = math.ceil(abs(b) / n)
	incre = n * m - abs(b)
else:
	incre = b % n
res = incre + a
if res > n:
	res = res % n
print(res)


(n, a, b) = map(int, input().split())
l = []
for i in range(1, n + 1):
	l.append(i)
if b < 0:
	t = a - 1
	y = b + t
	p = y % n
	print(l[p])
else:
	t = n - a
	y = b - t
	p = y % n - 1
	print(l[p])


(n, a, b) = map(int, input().split())
if b == 0:
	print(a)
	exit()
if b < 0:
	b = abs(b) % n
	a -= b
	if a < 1:
		a += n
else:
	b %= n
	a += b
	if a > n:
		a -= n
print(a)


(n, a, b) = map(int, input().split())
if b < 0:
	b += 200 * n
ans = (a + b) % n
if ans == 0:
	ans = n
print(ans)


(n, a, b) = map(int, input().split())
print((a - 1 + b + 100 * n) % n + 1)


(n, a, b) = list(input().split(' '))
n = int(n)
a = int(a)
b = int(b)
result = ((a + b) % n + n) % n
if result == 0:
	print(n)
else:
	print(result)


(n, a, b) = list(map(int, input().split()))
c = [0]
for i in range(1, n + 1):
	c += [i]
for i in range(1, n + 1):
	c += [i]
for i in range(1, n + 1):
	c += [i]
print(c[a + n + b % n])


(n, a, b) = tuple(map(int, input().split()))
r = (a + b) % n
if r == 0:
	print(n)
else:
	print(r)


xs = input().split(' ')
n = int(xs[0])
a = int(xs[1])
b = int(xs[2])
a -= 1
a += b
while a < 0:
	a += n
print(a % n + 1)


(n, a, b) = map(int, input().split())
c = 0
if b < 0:
	while b != 0:
		a = a - 1
		if a <= 0:
			a = n
		b = b + 1
	c = 1
if b > 0:
	while b != 0:
		a = a + 1
		if a > n:
			a = 1
		b = b - 1
	c = 1
print(a)


a = [int(i) for i in input().split()]
if a[2] >= 0:
	temp = a[2] % a[0]
	temp1 = (a[1] + temp) % a[0]
else:
	temp = -a[2] % a[0]
	temp1 = (a[1] + (a[0] - temp)) % a[0]
if temp1 == 0:
	print(a[0])
else:
	print(temp1)


(n, a, b) = map(int, input().split())
a = a - 1
a = (a + b) % n
if a < 0:
	a = a + n
print(a + 1)


(n, a, b) = map(int, input().split())
print((a + b - 1 + n * 99) % n + 1)


from sys import *
inp = lambda : stdin.readline()

def main():
	(n, a, b) = [int(i) for i in inp().split()]
	a = a + b
	while a <= 0:
		a += n
	while a > n:
		a -= n
	print(a)
main()


(n, a, b) = [int(s) for s in input().split()]
r = (a - 1 + b) % n
if r < 0:
	r += n
print(r + 1)


import math
import os
import random
import re
import sys
a = list(map(int, input().rstrip().split()))
(n, c, b) = (a[0], a[1], a[2])
x = []
for i in range(1, n + 1):
	x.append(i)
if b < 0:
	b = -b
	x = x[::-1]
j = x.index(c)
for i in range(0, b):
	j = j + 1
	if j == len(x):
		j = 0
		continue
print(x[j])


3

class StdIO:

	def read_int(self):
		return int(self.read_string())

	def read_ints(self, sep=None):
		return [int(i) for i in self.read_strings(sep)]

	def read_float(self):
		return float(self.read_string())

	def read_floats(self, sep=None):
		return [float(i) for i in self.read_strings(sep)]

	def read_string(self):
		return input()

	def read_strings(self, sep=None):
		return self.read_string().split(sep)
io = StdIO()

def main():
	(n, a, b) = io.read_ints()
	print((a + b - 1) % n + 1)

def __starting_point():
	main()
__starting_point()


(num, al, bl) = map(int, input().split())
if bl < 0:
	if not (al + num + bl) % num:
		print(num)
	else:
		print((al + num + bl) % num)
elif not (al + bl) % num:
	print(num)
else:
	print((al + bl) % num)


__author__ = 'Esfandiar'
(n, a, b) = map(int, input().split())
if b >= 0:
	if (a + b) % n == 0:
		print(n)
	else:
		print((a + b) % n)
else:
	b *= -1
	yy = a - b
	if yy <= 0:
		b -= a
		print(n - b % n)
	else:
		print(yy)


import math, sys
from collections import Counter, defaultdict, deque
from sys import stdin, stdout
input = stdin.readline
lili = lambda : list(map(int, sys.stdin.readlines()))
li = lambda : list(map(int, input().split()))
I = lambda : int(input())
S = lambda : input()
(n, a, b) = li()
k = a
if b <= 0:
	b = abs(b)
	for i in range(0, b):
		k = k - 1
		if k == 0:
			k = n
else:
	for i in range(0, b):
		k += 1
		if k == n + 1:
			k = 1
print(k)


import time
(n, a, b) = (int(i) for i in input().split())
start = time.time()
ans = (a + b) % n
if ans == 0:
	ans = n
print(ans)
finish = time.time()


import sys

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)
fast_reader = sys.stdin.readline
fast_writer = sys.stdout.write

def input():
	return fast_reader().strip()

def print(*argv):
	fast_writer(' '.join((str(i) for i in argv)))
	fast_writer('\n')
(n, a, b) = map(int, input().split())
print((a + b - 1) % n + 1)


(n, a, b) = [int(i) for i in input().split()]
if b > 0:
	print(a + b % n if a + b % n <= n else (a + b % n) % n)
elif a > abs(b):
	print(a + b)
else:
	print(n - abs(a + b) % n)


import sys
(n, a, b) = map(int, input().split())
if b == 0:
	res = a
elif b < 0:
	b = abs(b)
	if a < b:
		b -= a - 1
		while b > 0:
			for i in range(n, 0, -1):
				b -= 1
				if b == 0:
					res = i
					break
	elif a == b:
		res = n
	else:
		res = a - b
elif b > 0:
	if n - a < b:
		b -= n - a
		while b > 0:
			for i in range(1, n + 1):
				b -= 1
				if b == 0:
					res = i
					break
	else:
		res = a + b
print(res)


(n, a, b) = map(int, input().split())
val = abs(a + b % n) % n if abs(a + b % n) % n > 0 else n
print(val)


(n, a, b) = map(int, input().split())
arr = list(range(1, n + 1)) * 2
if b < 0:
	print()
	b = n - b % n
	arr = arr[::-1]
	ind = arr.index(a)
	ans = arr[arr.index(a) + b]
else:
	b = b % n
	ind = arr.index(a)
	ans = arr[arr.index(a) + b]
print(ans)


(n, a, b) = map(int, input().split())
x = [i for i in range(1, n + 1)]
y = x[::-1]
if n == 1:
	print(1)
elif b < 0:
	z = y.index(a)
	ans = y[z:]
	if len(ans) > abs(b):
		print(ans[abs(b)])
	else:
		p = abs(b) % n
		q = p - len(ans)
		ans = ans + y[:q + 1]
		print(ans[-1])
else:
	ans = x + x
	b = b % n
	z = ans.index(a)
	ans = ans[z:z + b + 1]
	print(ans[-1])


y = input()
y = y.split()
n = int(y[0])
a = int(y[1])
b = int(y[2])
result = (a + b) % n
result = result + n
result = result % n
if result == 0:
	result = n
print(result)


(n, s, d) = map(int, input().split())
if d >= 0:
	d = d
	for i in range(d):
		s += 1
		if s > n:
			s = 1
else:
	d = 0 - d
	for j in range(d):
		s -= 1
		if s == 0:
			s = n
print(s)


(n, a, b) = map(int, input().split(' '))
y = a + b
while 1:
	if b == 0:
		print(a)
		break
	elif y <= 0:
		y += n
	elif y > n:
		y -= n
	else:
		print(y)
		break


import math
(n, a, b) = map(int, input().split())
b = b % n
result = 0
if b < 0:
	b = math.fabs(b)
	if b >= a:
		result = n - b - a
	else:
		result = a - b
elif b > n - a:
	result = b - (n - a)
else:
	result = a + b
print(result)


(n, a, b) = list(map(int, input().split()))
c = abs(b)
while c > 0:
	if b < 0:
		a -= 1
		if a == 0:
			a = n
	else:
		a += 1
		if a == n + 1:
			a = 1
	c -= 1
print(a)


try:
	while True:
		(n, a, b) = list(map(int, input().split()))
		x = (a + b) % n
		print(n if x == 0 else x)
except EOFError:
	pass


class A(object):

	def __init__(self):
		self.m_DP = []
		self.AC()

	def AC(self):
		(n, a, b) = map(int, input().split())
		s = abs(b)
		s %= n
		if b > 0:
			a += s
			a %= n
		else:
			a -= s
			a += n
			a %= n
		if a == 0:
			a = n
		print(a)
A()


(n, x, y) = map(int, input().split(' '))
if (x + y) % n == 0:
	print(n)
else:
	print((x + y) % n)


(n, a, b) = list(map(int, input().split()))
if b == 0:
	print(a)
	exit()
dx = b // abs(b)
for i in range(abs(b)):
	a += dx
	if a == 0:
		a = n
	elif a == n + 1:
		a = 1
print(a)


def main():
	(n, a, b) = map(int, input().strip().split())
	p = (a + b) % n
	print(p if p != 0 else n)
main()


from sys import stdin

def mod(a, b):
	return (a % b + b) % b
for line in stdin:
	(n, a, b) = (int(i) for i in line.split(' '))
	a -= 1
	res = mod(a + b, n)
	print(res + 1)


(n, a, b) = map(int, input().split())
z = [i for i in range(1, n + 1)]
y = z.index(a)
if b < 0 and abs(b) > n:
	x = -(abs(b) % n)
else:
	x = b % n
print(z[(y + x) % n])


(n, a, b) = (int(i) for i in input().split())
c = abs(b) % n
if b < 0:
	r = a - c
	if r < 1:
		r += n
else:
	r = a + c
	if r > n:
		r -= n
print(r)


ch = input()
d = ch.split()
n = int(d[0])
a = int(d[1])
b = int(d[2])
if b < 0:
	b = b % n
	if a + b > n:
		print(a + b - n)
	elif a + b > 0:
		print(a + b)
	else:
		print(a + b + n)
elif b > 0:
	b = b % n
	if a + b <= n:
		print(a + b)
	else:
		print(a + b - n)
else:
	print(a)


from sys import stdin as Si
(n, a, b) = map(int, Si.readline().split())
if b == 0:
	print(a)
else:
	x = (a + b) % n
	if x == 0:
		print(n)
	else:
		print(x)


__author__ = 'User'
(n, a, b) = map(int, input().split())
a -= 1
a = (a + b) % n
a += 1
print(a)


(n, m, p) = map(int, input().split())
r = (m + p % n) % n
if r == 0:
	r = n
print(r)


(n, a, b) = map(int, input().rstrip().split(' '))
if b < 0:
	if abs(b) < a:
		print(a + b)
	else:
		b = abs(b + a)
		l = b % n
		print(n - l)
elif b > 0:
	b = b + a
	f = b % n
	if f:
		print(b % n)
	else:
		print(n)
else:
	print(a)


(n, a, b) = map(int, input().split())
if b < 0:
	(bp, ans) = (abs(b), a - abs(b) % n)
	if ans == 0:
		print(n)
	elif ans < 0:
		print(n + ans)
	else:
		print(ans)
elif (b + a) % n != 0:
	print((b + a) % n)
else:
	print(n)


def solve():
	(N, A, B) = map(int, input().split())
	A -= 1
	A += N * 100
	A += B
	A %= N
	A += 1
	print(A)
solve()


(n, a, b) = map(int, input().split())
b %= n
arr = [i for i in range(1, n + 1)]
index = (a + b) % n - 1
print(arr[index])


gi = lambda : list(map(int, input().strip().split()))
(n, a, b) = gi()
print((a - 1 + b + n) % n + 1)


x = input()
arr = x.split()
n = int(arr[0])
a = int(arr[1])
b = int(arr[2])
k = a
while b != 0:
	if b > 0:
		k = k + 1
		if k > n:
			k = 1
		b = b - 1
	if b < 0:
		k = k - 1
		if k == 0:
			k = n
		b = b + 1
print(k)


(n, a, b) = map(int, input().split())
aa = abs(b) % n
if b < 0 and aa > a:
	ans = n - aa + a
elif b < 0:
	ans = a - aa
elif aa > n - a:
	ans = aa - n + a
else:
	ans = aa + a
print([ans, n][ans == 0])


(n, a, b) = map(int, input().split())
if b < 0:
	i = abs(b) % n
	j = a
	while i > 0:
		if j == 0:
			j = n
		j -= 1
		i -= 1
	if j == 0:
		j = n
	print(j)
else:
	i = b % n
	j = a
	while i > 0:
		if j == n + 1:
			j = 1
		j += 1
		i -= 1
	if j == n + 1:
		j = 1
	print(j)


(n, a, b) = (int(i) for i in input().split())
s = 0
if b > 0:
	while s != b:
		s += 1
		a += 1
		if a > n:
			a = 1
elif b < 0:
	while s != b:
		s -= 1
		a -= 1
		if a == 0:
			a = n
print(a)


(n, a, b) = map(int, input().split())
Answer = (a + b % n + n) % n
if Answer == 0:
	Answer = n
print(Answer)


(n, a, b) = input().split()
(n, a, b) = (int(n), int(a), int(b))
if b >= 0:
	b = b % n
	a = (a + b) % n
	if a:
		print(a)
	else:
		print(n)
else:
	b = abs(b)
	b = b % n
	b = n - b
	a = (a + b) % n
	if a:
		print(a)
	else:
		print(n)


(n, a, r) = list(map(int, input().split()))
if r > 0:
	for x in range(5555555):
		if r != 0:
			if a != n:
				a += 1
				r -= 1
			else:
				a = 1
				r -= 1
		else:
			break
	print(a)
else:
	for x in range(5555555):
		if r != 0:
			if a != 1:
				a -= 1
				r += 1
			else:
				a = n
				r += 1
		else:
			break
	print(a)


con = 0
for i in input().strip().split(' '):
	if con == 0:
		n = int(i)
	elif con == 1:
		a = int(i)
	else:
		b = int(i)
	con = con + 1
p = abs(b)
while p > 0:
	if b < 0:
		a = a - 1
		if a == 0:
			a = n
	if b > 0:
		a = a + 1
		if a == n + 1:
			a = 1
	p = p - 1
print(a)


def ii():
	return int(input())

def fi():
	return float(input())

def si():
	return input()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
import math
(n, a, b) = mi()
ans = a + b
if ans < 0:
	ans *= -1
	ans %= n
	ans = ans - n
	if ans < 0:
		ans *= -1
else:
	ans %= n
	if ans == 0:
		ans = n
print(ans)


(n, a, b) = (int(i) for i in input().split())
start = a - 1
if b >= 0:
	finish = (start + b) % n
	print(finish + 1)
else:
	b = -b
	posb = n - b % n
	finish = (start + posb) % n
	print(finish + 1)


(n, a, b) = [int(i) for i in input().split()]
k = (a + b) % n
if k == 0:
	print(n)
else:
	print(k)


(n, cp, ns) = map(int, input().split())
if ns > 0:
	ns = ns % n
	ans = cp + ns
	if ans > n:
		ans = ans % n
else:
	ns = ns * -1
	ns = ns % n
	if cp - ns > 0:
		ans = cp - ns
	else:
		ans = n - (ns - cp)
print(ans)


def main():
	f = [int(i) for i in input().split()]
	f[1] -= 1
	f[1] += f[-1]
	f[1] %= f[0]
	if f[1] < 0:
		f[1] = (f[1] + f[0]) % f[0]
	f[1] += 1
	print(f[1])
main()


h = input().split(' ')
n = int(h[0])
m = int(h[1])
k = int(h[2])
print((m + k + 2000 * n - 1) % n + 1)


x = list(map(int, input().split()))
import math
n = x[0]
a = x[1]
b = x[2]
if abs(b) % n == 0:
	print(a)
else:
	if b > 0:
		p = math.floor(abs(b) / n)
		q = p * n
		q1 = b - q
		r = a + q1
		if r > n:
			r = r - n
	else:
		p = math.floor(abs(b) / n)
		q = p * n
		q1 = abs(b) - q
		r1 = n - q1
		r = a + r1
		if r > n:
			r = r - n
	print(r)


(n, a, b) = input().split()
(n, a, b) = (int(n), int(a), int(b))
if b == 0:
	print(a)
else:
	t = (n + (a + b % n)) % n
	if t == 0:
		print(n)
	else:
		print(t)


(n, a, b) = input().split()
n = int(n)
a = int(a)
b = int(b)
if b == 0:
	a = a
elif b < 0:
	i = 0
	h = 1
	while i < abs(b) - abs(b) // n * n:
		a -= h
		if a == 0:
			a = n
		i += 1
elif b > 0:
	i = 0
	h = 1
	while i < abs(b) - abs(b) // n * n:
		if a == n:
			a = 0
		a += h
		i += 1
print(a)


(a, b, c) = map(int, input().split())
c = c % a
if c < 0:
	c = a + c
t = b + c
t = t % a
if t == 0:
	t = a
print(t)


(n, a, b) = map(int, input().strip().split())
print((a + b - 1) % n + 1)


(n, a, b) = map(int, input().split())
d = (a - 1 + b) % n + n
x = d % n + 1
print(x)


from math import ceil

def compute_last_entrance(n, a, b):
	if b == 0 or n == 1 or n == b:
		return a
	x = a + b
	if x > n:
		y = ceil(x / n)
		x -= y * n
		if x <= 0:
			x += n
		return x
	else:
		if x > 0:
			return x
		if x == 0:
			return n
		y = ceil(abs(x) / n)
		x += n * y
		if x == 0:
			x += n
		return x
inputs = input().split(' ')
for i in range(len(inputs)):
	inputs[i] = int(inputs[i])
print(compute_last_entrance(inputs[0], inputs[1], inputs[2]))


a = [int(x) for x in input().split()]
print((a[1] + a[2] - 1) % a[0] + 1)


x = [int(i) for i in input().split()]
n = x[0]
a = x[1]
b = x[2]
if n == 0 or n == 1:
	print(n)
elif b == 0:
	print(a)
elif b > 0:
	for i in range(b):
		if a == n:
			a = 0
			a += 1
		else:
			a += 1
	print(a)
else:
	b = -b
	for i in range(b):
		if a == 1:
			a = n + 1
			a -= 1
		else:
			a -= 1
	print(a)


(n, a, b) = map(int, input().split())
r = a + b - 1
f = r % n + 1
print(f)


(n, a, b) = map(int, input().split(' '))
flag = 0
direction = 0
if b < 0:
	b = -b
	direction = 1
for i in range(b):
	if direction == 0:
		a += 1
		if a > n:
			a = 1
	if direction == 1:
		a -= 1
		if a < 1:
			a = n
print(a)


(n, a, b) = tuple(map(int, input().split()))
a -= 1
print((a + b) % n + 1)


data = list(map(int, input().split()))
n = data[0]
a = data[1]
b = data[2]
add = b % n
a = a - 1
res = (a + add) % n + 1
print(res)


st = [int(i) for i in input().split(' ')]
n = st[0]
a = st[1]
b = st[2]
print(((a - 1 + b) % n + n) % n + 1)


inp = input().split(' ')
n = int(inp[0])
s = int(inp[1])
d = int(inp[2])
res = (s + d) % n
if res == 0:
	res = n
print(res)


import math
(a, b, c) = map(int, input().split())
d = c % a
if a == 1:
	print(1)
elif c == 0:
	print(b)
elif c > 0:
	if (b + c) % a == 0:
		print(a)
	else:
		print((d + b) % a)
else:
	d = int(math.fabs(c)) % a
	d = b - d
	if d > 0:
		print(d)
	elif d == 0:
		print(a)
	else:
		print(a + d)


import math
(n, src, steps) = map(int, input().split())
if n == 1:
	print(1)
elif steps > 0:
	dest = (src + steps) % n
	if dest == 0:
		print(n)
	else:
		print(dest)
elif steps == 0:
	print(src)
else:
	steps *= -1
	steps = steps % n
	dest = src - steps
	if dest > 0:
		print(dest)
	elif dest == 0:
		print(n)
	else:
		print(dest + n)


(n, m, b) = map(int, input().split())
while b != 0:
	m += 1 if b > 0 else -1
	m = 1 if m > n else m
	m = n if m < 1 else m
	b += 1 if b < 0 else -1
print(m)


(n, a, b) = [int(num) for num in input().split()]
r = abs((a + b) % n)
res = r if r != 0 else n
print(res)


import sys
inf = float('inf')
from math import ceil, floor, log, log2, sqrt, factorial, pow, pi, gcd

def powerMod(x, y):
	res = 1
	while y > 0:
		if y & 1:
			res = res * x
		y = y >> 1
		x = x * x
	return res
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
(mod, MOD) = (1000000007, 998244353)
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
(n, a, b) = get_ints()
if b >= 0:
	ans = (a + b % n) % n
	if ans == 0:
		print(n)
	else:
		print(ans)
else:
	ans = (a + n - abs(b) % n) % n
	if ans == 0:
		print(n)
	else:
		print(ans)


(n, a, b) = [int(i) for i in input().split()]
c = a + b
if c > n:
	k = c % n
elif c < 1:
	if abs(c) <= n:
		k = n + c
	else:
		k = n - abs(c) % n
else:
	k = c
if k == 0:
	k = n
print(k)


(n, a, b) = list(map(int, input().split()))
a -= 1
if b == 0:
	print(a + 1)
elif b > 0:
	print((a + b) % n + 1)
else:
	print((n * 110 + b + a) % n + 1)


(n, a, b) = (int(x) for x in input().split())
if b >= 0:
	ans = (a - 1 + b) % n + 1
else:
	b *= -1
	steps = b % n
	back = a - 1
	if steps <= back:
		ans = a - steps
	else:
		rem = steps - back
		ans = n + 1 - rem
print(ans)


from sys import stdin

def main():
	(n, a, b) = [int(x) for x in next(stdin).split()]
	k = (a + b) % n
	print(k if k > 0 else n)
main()


a = []
for i in input().split():
	a.append(int(i))
ans = (a[1] + a[2] + a[0]) % a[0]
if ans == 0:
	ans = a[0]
print(str(ans))


(x, y, z) = map(int, input().split())
print((y + z - 1) % x + 1)


(a, b, c) = map(int, input().split())
if c == 0:
	print(b)
if c < 0:
	c = -c % a
	c = -c
	if b + c <= 0:
		print(a + c + b)
	else:
		print(b + c)
if c > 0:
	c = c % a
	if b + c > a:
		print(c - a + b)
	else:
		print(b + c)


class CodeforcesTask659ASolution:

	def __init__(self):
		self.result = ''
		self.n_a_b = []

	def read_input(self):
		self.n_a_b = [int(x) for x in input().split(' ')]

	def process_task(self):
		k = sum(self.n_a_b[1:]) % self.n_a_b[0]
		if not k:
			k = self.n_a_b[0]
		self.result = str(k)

	def get_result(self):
		return self.result
Solution = CodeforcesTask659ASolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


(q, w, e) = map(int, input().split())
a = (w + e) % q
if a == 0:
	a = q
print(a)


import sys
for line in sys.stdin:
	if line == None or line == '\n':
		break
	(total, start, walk_nums) = line.split(' ')
	total = int(total)
	start = int(start)
	walk_nums = int(walk_nums)
	walk_nums = walk_nums % total
	if walk_nums < 0:
		print('%s' % (total + walk_nums + start))
	answer = (start + walk_nums) % total
	if answer == 0:
		print('%s' % total)
	else:
		print('%s' % answer)


def main():
	(number_of_entrances, his_entrance, length_of_walk) = [int(x) for x in input().split()]
	ans = (his_entrance + length_of_walk % number_of_entrances) % number_of_entrances
	if ans == 0:
		ans = number_of_entrances
	print(ans)
main()


(n, a, p) = map(int, input().split())
if (p % n + a) % n == 0:
	print(n)
else:
	print((p % n + a) % n)


lst = [eval(i) for i in input('').split()]
a = lst[1] + lst[2]
res = a % lst[0]
if res < 0:
	print(lst[0] + res)
elif res == 0:
	print(lst[0])
else:
	print(res)


(n, a, b) = map(int, input().split())
q = (a + b + n) % n
print(q if q else n)


(n, a, b) = map(int, input().split())
print([(a + b % n) % n, a + b % n][(a + b % n) % n == 0])


import math
(n, a, b) = [int(i) for i in input().split()]
l = list(range(1, n + 1))
l = l * 2000
if b >= 0:
	d = l.index(a)
	d = d + b
	print(l[d])
else:
	l = l[::-1]
	d = l.index(a)
	d = d + abs(b)
	print(l[d])


(n, a, b) = list(map(int, input().split()))
b1 = b
b = abs(b) % n
if b1 < 0:
	b = n - b
x = a + b
if x > n:
	print(x - n)
else:
	print(x)


(a, b, c) = [int(i) for i in input().split()]
if c < 0:
	c = -c
	c = c % a
	c = -c
	c = c + b
	c = abs(c + a) % a
	if c == 0:
		c = a
	print(c)
else:
	b = b + c
	b = b % a
	if b == 0:
		b = a
	print(b)


x = list(map(int, input().split()))
n = x[0]
a = x[1]
b = x[2]
print(((a - 1 + b) % n + n) % n + 1)


from collections import deque
v = []
p = []
(n, a, b) = map(int, input().split())
if b > 0:
	for i in range(a, n + 1):
		v.append(i)
	for i in range(1, a):
		v.append(i)
	for i in range(b):
		t = v.pop(0)
		v.append(t)
	print(v[0])
elif b < 0:
	for i in range(a, n + 1):
		p.append(i)
	for j in range(1, a):
		p.append(j)
	r = deque(p)
	for i in range(abs(b)):
		k = r.pop()
		r.appendleft(k)
	print(r[0])
else:
	print(a)


(n_house, a, b) = map(int, input().split())
print((a + b % n_house - 1) % n_house + 1)


(n, a, b) = map(int, input().split())
a1 = a + b - 1
a2 = a1 % n + 1
print(a2)


import collections
(n, a, b) = map(int, input().split())
d = collections.deque([i for i in range(1, n + 1)])
if b < 0:
	d.rotate(abs(b))
else:
	d.rotate(-1 * b)
print(d[a - 1])


def f(l, start, step):
	n = start + step
	if n >= l:
		n = n % l
	while n < 0:
		n = l + n
	return n + 1
(a, b, c) = map(int, input().split())
print(f(a, b - 1, c))


(entrances, beginning, steps) = map(int, input().split())
if steps == 0:
	print(beginning)
elif steps < 0:
	endpointneg = beginning - abs(steps) % entrances
	if endpointneg <= 0:
		print(entrances + endpointneg)
	else:
		print(endpointneg)
else:
	endpoint = beginning + steps
	if endpoint <= entrances:
		print(endpoint)
	else:
		result = endpoint % entrances if endpoint % entrances else endpoint // entrances
		print(result if entrances > 1 else 1)


(a, b, c) = map(int, input().split())
output = (b + c) % a
if output == 0:
	output = a
print(output)


(gates, home_gate, walk_distance) = input().split(' ')
walk_distance = int(walk_distance)
home_gate = int(home_gate)
gates = int(gates)
if walk_distance < 0:
	if home_gate + walk_distance > 0:
		print(home_gate + walk_distance)
	elif abs(walk_distance) % gates >= home_gate:
		print(home_gate - abs(walk_distance) % gates + gates)
	else:
		print(home_gate - abs(walk_distance) % gates)
elif walk_distance > 0:
	if abs(home_gate + walk_distance) > gates:
		if home_gate + walk_distance % gates > gates:
			print((home_gate + walk_distance % gates) % gates)
		else:
			print(home_gate + walk_distance % gates)
	else:
		print(home_gate + walk_distance)
else:
	print(home_gate)


inp = input().split()
n = int(inp[0])
a = int(inp[1])
b = int(inp[2])
if a + b >= 0:
	if (a + b) % n:
		print((a + b) % n)
	else:
		print(n)
elif n - -(a + b) % n:
	print(n - -(a + b) % n)
else:
	print(n)


def solved(n, a, b):
	return (a + b - 1) % n + 1
(n, a, b) = map(int, input().split())
print(solved(n, a, b))


numbers = list(map(int, input().split()))
n = numbers[0]
a = numbers[1]
b = numbers[2]
if b == 0:
	print(a)
else:
	print(((a - 1 + b) % n + n) % n + 1)


z = list(map(int, input().split()))
z[2] %= z[0]
print(['%d' % (z[2] + z[1]), '%d' % ((z[2] + z[1]) % z[0])][z[2] + z[1] > z[0]])


testCase = input()
testCase = testCase.split(' ')
n = int(testCase[0])
a = int(testCase[1])
b = int(testCase[2])
entrance = (b % n + a) % n
if entrance == 0:
	entrance = n
print(entrance)


(n, a, b) = map(int, input().split())
print((a + b) % n or n)


import math
(n, a, b) = map(int, input().split())
if b >= 0:
	if a + b % n > n:
		print((a + b % n) % n)
	else:
		print(a + b % n)
elif abs(b) < a:
	print(a - -1 * b)
else:
	b = abs(b) - a
	print(n - b % n)


l1 = [int(x) for x in input().split()]
(n, a, b) = (l1[0], l1[1], l1[2])
final = (a + b) % n
if final == 0:
	print(n)
else:
	print(final)


def dom(n, a, b):
	if b >= 0:
		if (a + b) % n == 0:
			return n
		else:
			return (a + b) % n
	else:
		b = -b
		if a > b:
			return a - b
		elif (b - a) % n == 0:
			return n
		else:
			return n - (b - a) % n
(N, A, B) = [int(i) for i in input().split()]
print(dom(N, A, B))


from sys import stdin
max_val = int(10000000000000.0)
min_val = int(-10000000000000.0)

def read_int():
	return int(stdin.readline())

def read_ints():
	return [int(x) for x in stdin.readline().split()]

def read_str():
	return input()

def read_strs():
	return [x for x in stdin.readline().split()]
(n, a, b) = read_ints()
print((a + b - 1) % n + 1)


(n, a, b) = [int(x) for x in input().split(' ')]
tmp = (a + b) % n
if tmp < 0:
	tmp = n + tmp
elif tmp == 0:
	tmp = n
print(tmp)


(n, a, b) = map(int, input().split())
d = (a + b % n) % n
if d == 0:
	d = n
print(d)


s = input().split()
n = int(s[0])
a = int(s[1])
b = int(s[2])
if b == 0:
	print(a)
elif b > 0:
	mas = []
	for i in range(n):
		mas.append(i + 1)
	mas = mas[a - 1:n] + mas[:a - 1]
	print(mas[b % n])
else:
	mas = []
	for i in range(n):
		mas.append(i + 1)
	mas1 = mas[:a]
	mas2 = mas[a:n]
	mas = mas1[::-1] + mas2[::-1]
	print(mas[abs(b) % n])


I = lambda : int(input())
M = lambda : map(int, input().split())
LI = lambda : list(map(int, input().split()))
(n, a, b) = M()
if n == 1:
	print(1)
elif b >= 0:
	b = b % n
	if b > n - a:
		print(abs(n - a - b))
	else:
		print(a + b)
else:
	b = n - b % n
	if b < a:
		print(a - b)
	else:
		print(n - abs(a - b))


(n, a, b) = map(int, input().split())
ent = []
ent.append(n)
for i in range(n - 1):
	ent.append(i + 1)
print(ent[(a + b) % n])


(n, a, b) = map(int, input().strip().split())
res = (a + b) % n
if res == 0:
	print(n)
else:
	print(res)


(n, k, m) = map(int, input().split())
while m < 0:
	m += n
k += m
if k % n == 0:
	print(n)
else:
	print(k % n)


for i in range(1):
	(n, m, k) = map(int, input().split())
	s = (m + k) % n
	if s == 0:
		print(n)
	else:
		print(s)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def main():
	(n, m, k) = LI()
	return (m + k - 1) % n + 1
print(main())


(n, a, b) = input().split()
enterances = list(range(1, int(n) + 1))

def upper_bound(nums, target):
	(l, r) = (0, len(nums) - 1)
	while l <= r:
		mid = l + (r - l) // 2
		if nums[mid] >= target:
			r = mid - 1
		else:
			l = mid + 1
	return l
print(enterances[(upper_bound(enterances, int(a)) + int(b)) % int(n)])


data = [int(info) for info in input().split(' ')]
result = data[1] + data[2]
if data[1] < 0:
	result += data[0]
if result == 0:
	print(data[0])
else:
	result = result % data[0]
	if result == 0:
		print(data[0])
	else:
		print(result)


(n, i, j) = map(int, input().split())
count = 1
if j > 0:
	while count <= j:
		if i >= n:
			i = 1
		else:
			i += 1
		count += 1
	print(i)
else:
	while count <= abs(j):
		if i <= 1:
			i = n
		else:
			i -= 1
		count += 1
	print(i)


inputstring = input().split()
i = 0

def nextint():
	global i
	n = int(inputstring[i])
	i = i + 1
	return n
n = nextint()
a = nextint()
b = nextint()
a = a - 1
print((a + b + 100 * n * n) % n + 1)


nn = list(map(int, input().rstrip().split()))
n = nn[0]
a = nn[1]
b = nn[2]
numm = (a + b) % n
if numm == 0:
	print(n)
else:
	print(numm)


from sys import stdin, stdout
(a, b, c) = map(int, stdin.readline().strip().split())
b -= 1
c = (b + c) % a
print(c + 1)


import math

def solve(n, a, b):
	if b < 0:
		res = n - -1 * b % n + a
	else:
		res = b % n + a
	return res if res <= n else res - n

def main():
	arr = list(map(int, input().split(' ')))
	print(solve(*arr))
main()


(n, m, d) = map(int, input().split())
if d < 0:
	print((m - 1 + (n + d)) % n + 1)
else:
	print((m - 1 + d) % n + 1)


(n, a, d) = map(int, input().split())
s = a + d % n
if s % n == 0:
	print(n)
else:
	print(s % n)


s = input().split()
print((int(s[1]) + int(s[2]) - 1) % int(s[0]) + 1)


(n, a, b) = map(int, input().split())
if b >= 0:
	y = (a + b) % n
	if y == 0:
		y = n
	print(y)
else:
	v = -1 * b % n
	x = a - v
	if x <= 0:
		x += n
	print(x)


def main():
	(n, a, b) = map(int, input().split())
	b %= n
	k = (a + b) % n
	print(k if k != 0 else n)
main()


def neg_s(a, n):
	if a - 1 == 0:
		return n
	else:
		return a - 1

def pos_step(a, n):
	if a + 1 == n:
		return n
	elif a == n:
		return 1
	else:
		return a + 1
[n, a, b] = [int(x) for x in input().split(' ')]
if b == 0:
	print(a)
	exit()
else:
	if b > 0:
		f = lambda a, n: pos_step(a, n)
	else:
		f = lambda a, b: neg_s(a, n)
	for i in range(abs(b)):
		a = f(a, n)
	print(a)