n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the first child is considered the leader. The game is played in k steps. In the i-th step the leader counts out a_{i} people in clockwise order, starting from the next person. The last one to be pointed at by the leader is eliminated, and the next player after him becomes the new leader.

For example, if there are children with numbers [8, 10, 13, 14, 16] currently in the circle, the leader is child 13 and a_{i} = 12, then counting-out rhyme ends on child 16, who is eliminated. Child 8 becomes the leader.

You have to write a program which prints the number of the child to be eliminated on every step.


-----Input-----

The first line contains two integer numbers n and k (2 ≤ n ≤ 100, 1 ≤ k ≤ n - 1).

The next line contains k integer numbers a_1, a_2, ..., a_{k} (1 ≤ a_{i} ≤ 10^9).


-----Output-----

Print k numbers, the i-th one corresponds to the number of child to be eliminated at the i-th step.


-----Examples-----
Input
7 5
10 4 11 4 1

Output
4 2 5 6 1 

Input
3 2
2 5

Output
3 2 



-----Note-----

Let's consider first example:   In the first step child 4 is eliminated, child 5 becomes the leader.  In the second step child 2 is eliminated, child 3 becomes the leader.  In the third step child 5 is eliminated, child 6 becomes the leader.  In the fourth step child 6 is eliminated, child 7 becomes the leader.  In the final step child 1 is eliminated, child 3 becomes the leader.

Source: codeforces | Difficulty: EASY
Tags: Implementation


Solutions:
(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
nums = list(range(1, n + 1))
leader = 0
elims = []
for i in range(k):
	elim = (leader + arr[i]) % n
	elims.append(nums.pop(elim))
	n -= 1
	leader = elim
print(*elims)


l = input().split()
n = int(l[0])
k = int(l[1])
done = [0 for i in range(n)]
count = 0
posn = 0
l = input().split()
li = [int(i) for i in l]
l = []
for i in range(n):
	l.append(i)
for i in range(k):
	posn += 1
	posn %= len(l)
	li[i] -= 1
	posn = posn + li[i] % len(l)
	posn %= len(l)
	done[l[posn]] = 1
	print(l[posn] + 1, end=' ')
	if posn == len(l) - 1:
		posn = 0
		l.pop(-1)
	else:
		l.pop(posn)


import sys
import math
import random
sys.setrecursionlimit(100000)
(n, k) = map(int, input().split())
ar = [i + 1 for i in range(n)]
for m in map(int, input().split()):
	m %= len(ar)
	print(ar[m], end=' ')
	ar = ar[m + 1:] + ar[:m]


(n, k) = list(map(int, input().split()))
(*a,) = list(map(int, input().split()))
ans = []
peo = list(range(1, n + 1))
cur = 0
for i in range(k):
	dind = (cur + a[i]) % len(peo)
	cur = dind
	ans.append(peo.pop(dind))
	cur %= len(peo)
	dind %= len(peo)
print(*ans)


(n, y) = input().split()
n = int(n)
y = int(y)
liste = list(range(1, n + 1))
x = 0
z = 0
liste2 = list(map(int, input().split()))
liste3 = []
while x < y:
	z = (z + liste2[x]) % len(liste)
	liste3.append(liste[z])
	liste.pop(z)
	x += 1
for i in liste3:
	print(i)


ip = input().split(' ')
n = ip[0]
k = ip[1]
ip2 = input().split(' ')
a = list(map(int, ip2))
children = []
for x in range(int(n)):
	children.append(x + 1)
temp = 0
for y in a:
	print(children[(temp + y) % len(children)])
	temp = children.index(children[(temp + y) % len(children)])
	del children[temp]


import sys
(n, k) = map(int, sys.stdin.readline().strip().split(' '))
counts = list(map(int, sys.stdin.readline().strip().split(' ')))
children = list(range(n + 1))
children.pop(0)
pos = 0
for a in counts:
	subarray = children[pos + 1:]
	dif = a - len(subarray)
	if dif <= 0:
		pos += a
		print(children[pos], end=' ')
		children.pop(pos)
	else:
		pos = dif % len(children) - 1
		print(children[pos], end=' ')
		children.pop(pos)
	if pos == -1:
		pos += 1
	pos = pos % len(children)


def find_eliminatee(l, offset):
	c = l
	for _ in range(offset):
		c = next(c)
	return c

def next(c):
	t = bound(c + 1)
	while es[t]:
		t = bound(t + 1)
	return t

def bound(v):
	return v % len(es)
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
l = 0
es = [False] * n
for i in range(k):
	e = find_eliminatee(l, a[i] % n)
	es[e] = True
	n -= 1
	l = next(e)
	print(e + 1, end=' ')


(n, k) = map(int, input().split())
a = [i for i in range(1, n + 1)]
move = [int(i) for i in input().split()]
for m in move:
	m %= len(a)
	print(a[m], end=' ')
	a = a[m + 1:] + a[:m]


(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
l = [x for x in range(1, n + 1)]
cl = 0
for i in range(k):
	x = arr[i]
	if x <= len(l) - cl - 1:
		if cl + x != len(l) - 1:
			print(l[cl + x], end=' ')
			del l[cl + x]
			cl = cl + x
		else:
			print(l[cl + x], end=' ')
			del l[cl + x]
			cl = 0
	else:
		x -= len(l) - cl - 1
		x %= len(l)
		if x == 0:
			print(l[len(l) - 1], end=' ')
			del l[len(l) - 1]
			cl = 0
		else:
			cl = x - 1
			print(l[x - 1], end=' ')
			del l[x - 1]


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
ele = [j + 1 for j in range(n)]
j = 0
e = []
for i in range(k):
	j = (j + a[i]) % len(ele)
	m = ele.pop(j)
	e.append(m)
for j in range(len(e)):
	print(e[j], end=' ')
print('')


def counting_out_rhyme():
	(n, k) = input().split()
	(n, k) = (int(n), int(k))
	a = [int(x) for x in input().split()]
	nl = [i + 1 for i in range(n)]
	answer = []
	for i in range(k):
		count = a[i]
		while True:
			if count >= len(nl):
				z = int(count / len(nl))
				count = count - len(nl) * z
			else:
				answer.append(nl.pop(count))
				nl = nl[count:] + nl[:count]
				break
	for i in answer:
		print(i)
counting_out_rhyme()


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


(n, k) = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
ms = [int(i) for i in range(1, n + 1)]
cur = 0
for i in a:
	ind = (i - n + cur) % n
	n -= 1
	cur = ind
	print(ms.pop(ind), end=' ')


(n, k) = map(int, input().split())
ai = list(map(int, input().split()))
ai2 = list(range(1, n + 1))
num = 0
for i in range(k):
	num = num + ai[i]
	num %= n
	print(ai2[num], end=' ')
	n -= 1
	ai2.remove(ai2[num])


from __future__ import division, print_function
import itertools, os, sys, threading
from collections import deque, Counter, OrderedDict, defaultdict
import heapq
from math import ceil, floor, log, sqrt, factorial, pow, pi

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

def si():
	return str(input())

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

def li():
	return list(mi())
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 = 1000000007
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def getKey(item):
	return item[0]

def sort2(l):
	return sorted(l, key=getKey)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

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

def ntl(n):
	return [int(i) for i in str(n)]

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

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
graph = defaultdict(list)
visited = [0] * 1000000
col = [-1] * 1000000

def dfs(v, c):
	if visited[v]:
		if col[v] != c:
			print('-1')
			exit()
		return
	col[v] = c
	visited[v] = 1
	for i in graph[v]:
		dfs(i, c ^ 1)

def bfs(d, v):
	q = []
	q.append(v)
	visited[v] = 1
	while len(q) != 0:
		x = q[0]
		q.pop(0)
		for i in d[x]:
			if visited[i] != 1:
				visited[i] = 1
				q.append(i)
		print(x)
	print(l)

def make_graph(e):
	d = {}
	for i in range(e):
		(x, y) = mi()
		if x not in d.keys():
			d[x] = [y]
		else:
			d[x].append(y)
		if y not in d.keys():
			d[y] = [x]
		else:
			d[y].append(x)
	return d

def gr2(n):
	d = {}
	for i in range(n):
		(x, y) = mi()
		if x not in d.keys():
			d[x] = [y]
		else:
			d[x].append(y)
	return d

def connected_components(graph):
	seen = set()

	def dfs(v):
		vs = set([v])
		component = []
		while vs:
			v = vs.pop()
			seen.add(v)
			vs |= set(graph[v]) - seen
			component.append(v)
		return component
	ans = []
	for v in graph:
		if v not in seen:
			d = dfs(v)
			ans.append(d)
	return ans
(n, k) = mi()
l = li()
a = []
for i in range(1, n + 1):
	a.append(i)
ld = 1
ans = []
for i in range(k):
	x = a.index(ld) + 1
	y = len(a) - x
	z = (l[i] - y) % len(a)
	ans.append(a[z - 1])
	ld = a[z]
	a.pop(z - 1)
print(' '.join(map(str, ans)))


(n, _) = map(int, input().split())
a = [i + 1 for i in range(n)]
for m in map(int, input().split()):
	m %= len(a)
	print(a[m], end=' ')
	a = a[m + 1:] + a[:m]


(n, k) = [int(s) for s in input().split()]
a = [int(s) for s in input().split()]
b = [i for i in range(1, n + 1)]
v = 0
rez = []
for i in range(k):
	t = a[i] % len(b)
	v += t
	v %= len(b)
	rez.append(b[v])
	del b[v]
print(' '.join([str(elem) for elem in rez]))


(n, k) = map(int, input().split())
lst = list(map(int, input().split()))
children = [i for i in range(1, n + 1)]
output = []
front = 0
for (i, a) in enumerate(lst):
	elim = (a + front) % (n - i)
	child = children[elim]
	front = children.index(child)
	children.remove(child)
	print(child, end=' ')
print()


(n, k) = map(int, input().split())
a = map(int, input().split())
cs = list(range(1, n + 1))
l = 0
res = ''
len = n
for x in a:
	pos = (l + x) % len
	res += str(cs[pos]) + ' '
	del cs[pos]
	len -= 1
	l = pos
print(res)


import sys
(n, k) = map(int, sys.stdin.readline().split())
a = [int(x) for x in sys.stdin.readline().split()]
l = [i for i in range(1, n + 1)]
p = 0
ret = []
for d in a:
	p += d
	p %= len(l)
	ret.append(l[p])
	del l[p]
print(' '.join((str(x) for x in ret)))


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
lst = list(range(1, n + 1))
leader = 0
for step in range(k):
	index = (leader + a[step] % n) % n
	ans = lst[index]
	print(ans, end=' ')
	lst.remove(ans)
	n -= 1
	leader = index


(x, y) = map(int, input().split())
arr1 = []
arr3 = []
arr = list(map(int, input().split()))
l = 1
arr1 = [0] * x
for i in range(0, x):
	arr1[i] = i + 1
for i in range(0, len(arr)):
	x1 = (arr[i] + l) % x
	if x1 == 0:
		x1 = x
	arr3.append(arr1[x1 - 1])
	del arr1[x1 - 1]
	x -= 1
	l = x1
for i in range(0, len(arr3)):
	print(arr3[i], end=' ')


from collections import deque
(N, K) = map(int, input().split())
A = list(map(int, input().split()))
q = deque(range(1, N + 1))
ret = []
for k in range(K):
	for a in range(A[k] % len(q)):
		q.append(q.popleft())
	ret.append(q.popleft())
print(' '.join([str(r) for r in ret]))


(n, k) = map(int, input().split(' '))
arr = list(map(int, input().split(' ')))
le = [i for i in range(-1, n - 1)]
le[0] = n - 1
ri = [i for i in range(1, n + 1)]
ri[n - 1] = 0
a = 0
ans = []
for i in arr:
	i = i % n
	for j in range(0, i):
		a = ri[a]
	ans.append(a + 1)
	le[ri[a]] = le[a]
	ri[le[a]] = ri[a]
	a = ri[a]
	n = n - 1
for a in ans:
	print(a, end=' ')
print('')


(N, K) = map(int, input().split())
As = map(int, input().split())
cs = [c for c in range(1, N + 1)]
ans = []
for a in As:
	i = a % len(cs)
	ans.append(cs[i])
	cs = cs[i + 1:] + cs[:i]
print(' '.join(map(str, ans)))


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
lead = 0
people = [i + 1 for i in range(n)]
for d in a:
	nex = (lead + d) % n
	print(people[nex])
	del people[nex]
	n -= 1
	nex %= n
	lead = nex


(n, k) = list(map(int, input().split()))
l = list(map(int, input().split()))
ans = list(range(1, n + 1))
base = 0
for i in range(k):
	base = (l[i] + base) % len(ans)
	print(ans.pop(base))


import math
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
l1 = [x for x in range(1, n + 1)]
j = 0
for i in a:
	k -= 1
	j = (j + i) % n
	if k != 0:
		print(l1[j], end=' ')
	else:
		print(l1[j], end='')
	n -= 1
	l1.pop(j)


s = input().split()
n = int(s[0])
k = int(s[1])
s = input().split()
v = []
for w in s:
	v.append(int(w))
kids = []
for i in range(1, n + 1):
	kids.append(i)
actual = 0
for i in range(k):
	actual = (actual + v[i]) % n
	print(kids.pop(actual))
	n -= 1
	actual = actual % n


e = 1
(n, k) = map(int, input().split())
n1 = list(range(n + 1)[1:n + 1])
a = list(map(int, input().split()))
for i in range(k):
	j = (e + a[i]) % n - 1
	if (e + a[i]) % n == 0:
		j = n - 1
		e = 1
	else:
		e = j + 1
	print(n1.pop(j))
	n -= 1


(n, k) = input().split(' ')
(n, k) = (int(n), int(k))
a = list(range(1, n + 1))
l = 0
for i in input().split(' '):
	e = (l + int(i)) % len(a)
	print(a[e], end=' ')
	a.pop(e)
	l = e


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
an = [i + 1 for i in range(n)]
result = []
j = 0
for i in range(k):
	j += a[i] % len(an)
	if j >= len(an):
		j -= len(an)
	result.append(an[j])
	an.pop(j)
print(' '.join(map(str, result)))


(n, k) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
c = list(range(1, n + 1))
ved = 0
for i in a:
	n = i % len(c)
	ved = ved + n
	if ved >= len(c):
		ved -= len(c)
	print(c[ved], end=' ')
	c.pop(ved)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
deleted = []
for i in range(n):
	deleted.append(i)
host = 0
for i in range(k):
	j = (host + a[i]) % n
	print(deleted.pop(j) + 1, end=' ')
	if j == n - 1:
		host = 0
	else:
		host = j
	n -= 1


(n, k) = map(int, input().split())
a = [int(i) for i in input().split()]
v = [int(i) for i in range(n)]
i = 0
cont = 0
tam = n
eli = []
while cont < k:
	i = (i + a[cont]) % tam
	eli.append(v[i] + 1)
	v.pop(i)
	cont += 1
	tam -= 1
for i in range(k):
	if i != k - 1:
		print(eli[i], end=' ')
	else:
		print(eli[i], end='')
print()


def solve():
	(n, k) = [int(x) for x in input().split(' ')]
	a = [int(x) for x in input().split(' ')]
	curr = [i for i in range(n)]
	i = 0
	j = 0
	ans = []
	for c in range(k):
		i = (i + a[j]) % n
		ans.append(curr[i] + 1)
		del curr[i]
		n -= 1
		i = i % n
		j += 1
	return ans
print(*solve())


(n, k) = [int(x) for x in input().split(' ')]
steps = [int(x) for x in input().split(' ')]
steps.reverse()
circle = list(range(n))

def next_index(i, step, circle):
	length = len(circle)
	return (i + step) % length
index = 0
for i in range(len(steps)):
	index = next_index(index, steps.pop(), circle)
	print(circle[index] + 1, end=' ')
	del circle[index]


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
cur = 0
children = [i + 1 for i in range(n)]
for i in range(k):
	cur = (cur + a[i]) % len(children)
	print(children[cur], end=' ')
	children = children[:cur] + children[cur + 1:]
	cur %= len(children)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
array = [0] * n
for i in range(n):
	array[i] = i + 1
now = 0
for i in range(k):
	dp = (now + a[i] % len(array)) % len(array)
	print(array[dp], end=' ')
	array.pop(dp)
	now = dp


from copy import deepcopy as dcopy

def main():
	(n, k) = map(int, input().split())
	ks = list(map(int, input().split()))
	children = list(range(n))
	leader_i = 0
	res = []
	for k in ks:
		elim_i = (leader_i + k) % len(children)
		elim_num = dcopy(children[elim_i])
		nextl_i = (leader_i + k + 1) % len(children)
		nextl_num = dcopy(children[nextl_i])
		res.append(children.pop(elim_i) + 1)
		leader_i = children.index(nextl_num)
	print(' '.join(map(str, res)))
main()


(n, k) = map(int, input().split())
B = list(map(int, input().split()))
A = [i for i in range(1, n + 1)]
x = 0
for i in range(k):
	x = (x + B[i]) % len(A)
	print(A.pop(x), end=' ')


from collections import deque

def rhymes(n, a):
	children = deque(range(1, n + 1))
	result = []
	for step in a:
		children.rotate(-step)
		result.append(children.popleft())
	return result

def main():
	(n, k) = map(int, input().strip().split())
	a = tuple(map(int, input().strip().split()))
	result = rhymes(n, a)
	print(*result)
main()


x = input().split(' ')
y = input().split(' ')
x = list(map(int, x))
y = list(map(int, y))
n = x[0]
child = []
for i in range(n):
	child.append(i + 1)
z = []
lead = 1
for i in range(len(y)):
	lead = child.index(lead)
	if lead == n:
		out = 1
	else:
		out = lead + 1
	t = y[i] % n
	while t > 0:
		if out == n:
			out = 1
		else:
			out += 1
		t -= 1
	if out < n:
		lead = child[out]
	else:
		lead = child[0]
	n -= 1
	a = child.pop(out - 1)
	z.append(a)
for i in range(len(z)):
	print(z[i], end=' ')


(n, k) = map(int, input().split())
lst = []
for i in range(n):
	lst.append(i + 1)
klst = list(map(int, input().split()))
index = 0
for i in range(k):
	index = (index + klst[i]) % len(lst)
	print(lst.pop(index), end=' ')


(n, k) = map(int, input().split())
a = [x + 1 for x in range(n)]
for m in map(int, input().split()):
	m %= len(a)
	print(a[m], end=' ')
	a = a[m + 1:] + a[:m]
print()


__author__ = 'Alexander'
s = input()
(n, k) = tuple(map(int, s.split()))
s = input()
a = list(map(int, s.split()))
r = list(range(1, n + 1))
j = 0
for i in range(k):
	j = (j + a[i]) % n
	n -= 1
	print(r[j], end=' ')
	del r[j]


import sys, math, queue
sys.setrecursionlimit(1000000)
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
c = [i for i in range(n)]
indx = 0
for i in range(k):
	indx = (indx + a[i]) % (n - i)
	print(c.pop(indx) + 1, end=' ')


(n, k) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
c = 1
ans = []
b = [i for i in range(1, n + 1)]
for i in range(k):
	c = (c + a[i] - 1) % n
	ans.append(b[c])
	b.pop(c)
	n = n - 1
	if n == 0:
		break
	c = (c + 1) % n
for i in ans:
	print(i, end=' ')


temp = input()
(n, k) = temp.split(' ')
n = int(n)
k = int(k)
temp = input()
tab = temp.split(' ')
tab = [int(x) for x in tab]
i = 0
players = []
while i < n:
	players.append(i + 1)
	i += 1
idx = 0
i = 0
while i < k:
	idx += tab[i]
	idx %= len(players)
	print(players[idx], end=' ')
	idx %= len(players)
	del players[idx]
	i += 1


(n, k) = map(int, input().split())
k = list(map(int, input().split()))
(l, ans) = ([], [])
for i in range(n):
	l.append(i)
leader = 0
for i in k:
	ans.append(l[(leader + i) % len(l)] + 1)
	leader = (leader + i) % len(l)
	l.remove(ans[-1] - 1)
	leader = leader % len(l)
print(*ans, sep=' ')


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
pos = 0
d = []
m = n
R = list(range(0, n))
for i in range(k):
	s = a[i] % (n - i)
	pos = pos + s
	if pos >= n - i:
		pos -= n - i
	d.append(R[pos] + 1)
	R.remove(R[pos])
	if pos >= n - i:
		pos -= n - i
print(*d)


[n, k] = map(int, input().strip().split())
ais = list(map(int, input().strip().split()))
cur = 0
ch = list(range(1, n + 1))
l = []
for a in ais:
	cur += a
	cur %= len(ch)
	l.append(ch[cur])
	del ch[cur]
print(' '.join(map(str, l)))


(n, a, b, l) = (input().split(), input().split(), [0], 1)
(n[0], n[1]) = (int(n[0]), int(n[1]))
for i in range(1, n[0] + 1):
	b.append(i)
for i in range(n[1]):
	l = (l + int(a[i])) % n[0]
	if l == 0:
		l = n[0]
	n[0] -= 1
	print(b[l], end=' ')
	b.pop(l)


(n, k) = map(int, input().split())
t = list(range(n))
i = 0
for ai in map(int, input().split()):
	i = (i + ai) % len(t)
	print(t[i] + 1, end=' ')
	t = t[:i] + t[i + 1:]
	i = i % len(t)


(n, k) = map(int, input().split())
a = [int(x) for x in input().split()]
v = [i for i in range(1, n + 1)]
val = 0
ans = ''
for i in a:
	i %= len(v)
	val += i
	if val >= len(v):
		val -= len(v)
	ans += str(v[val]) + ' '
	del v[val]
print(ans)


import sys
import bisect as bi
import math as mt
import collections as cc
import heapq as hp
I = lambda : list(map(int, input().split()))
(n, k) = I()
l = I()
ar = list(range(1, n + 1))
now = 0
for i in range(k):
	cur = (now + l[i]) % n
	print(ar[cur], end=' ')
	ar.pop(cur)
	n = len(ar)
	now = cur % n


(n, k) = map(int, input().split())
childs = list(range(1, n + 1))
a = list(map(int, input().split()))
res = []
main = 0
for i in a:
	idx = main
	idx = (idx + i) % len(childs)
	res.append(childs[idx])
	del childs[idx]
	main = idx
print(' '.join(map(str, res)))


f = lambda : map(int, input().split())
(n, k) = f()
s = 0
b = list(range(n))
for a in f():
	s = (s + a) % len(b)
	print(1 + b.pop(s))


import sys
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
ans = [0] * k
p = list(range(1, n + 1))
i = 0
for j in range(k):
	i = (i + a[j]) % len(p)
	ans[j] = p[i]
	p.pop(i)
	i %= len(p)
print(*ans)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
l = list(range(1, n + 1))
ans = []
leader = 0
for i in range(k):
	nu = a[i] % len(l)
	pos = (leader + nu) % len(l)
	if pos == len(l) - 1:
		leader = 0
	else:
		leader = pos
	ans.append(l.pop(pos))
print(*ans)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
children = list(range(1, n + 1))
(lea, idx) = (0, 0)
for ai in a:
	idx = (lea + ai) % len(children)
	print(children.pop(idx))
	lea = idx


(n, k) = (int(x) for x in input().split())
a = [i + 1 for i in range(n)]
k = [int(x) for x in input().split()]
cur = 0
for x in k:
	cur += x
	cur %= n
	print(a[cur], end=' ')
	del a[cur]
	n -= 1
	cur %= n
print()


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
used = [0] * n
ans = ''
cnt = 1
tmp = n
for i in range(k):
	cur = a[i] % n
	while cur > 0:
		if used[cnt] == 0:
			cur -= 1
		cnt += 1
		cnt = cnt % tmp
	if cnt != 0:
		ans += str(cnt) + ' '
	else:
		ans += str(tmp) + ' '
	used[cnt - 1] = 1
	while used[cnt] == 1:
		cnt += 1
		cnt %= tmp
	cnt += 1
	cnt %= tmp
	n -= 1
print(ans)


s = input()
(n, k) = s.split(' ')
n = int(n)
k = int(k)
str = input()
a_s = str.split(' ')
a = []
for i in range(k):
	a.append(int(a_s[i]))
c = []
for i in range(n):
	c.append(i + 1)
am = n
lead = 0
for t in range(k):
	p = (lead + a[t]) % am
	print(c[p], end=' ')
	am -= 1
	lead = p % am
	del c[p]


(n, k) = map(int, input().split())
(s, a, v, c) = (list(range(1, n + 1)), list(map(int, input().split())), [], 0)
for i in range(k):
	c = (c + a[i]) % len(s)
	v.append(str(s.pop(c)))
print(' '.join(v))


(n, k) = map(int, input().split())
a = map(int, input().split())
kids = list(range(n))
leader = 0
out = []
for ai in a:
	ai += leader
	ai %= n
	kid = kids[ai]
	kids = kids[:ai] + kids[ai + 1:]
	n -= 1
	leader = ai % n
	out.append(kid + 1)
print(' '.join(map(str, out)))


(n, k) = map(int, input().split())
ks = list(map(int, input().split()))
c = [i + 1 for i in range(n)]
ind = 0
for i in range(k):
	d = (ind + ks[i]) % len(c)
	ind = d
	print(c[d], end=' ')
	del c[d]
print()


def findout(A, x):
	ans = A[x % len(A)]
	new_A = A[x % len(A) + 1:] + A[:x % len(A)]
	return (new_A, ans)
Ans = []
(n, k) = list(map(int, input().strip().split(' ')))
change = list(map(int, input().strip().split(' ')))
A = [i + 1 for i in range(n)]
for x in change:
	(A, ans) = findout(A, x)
	Ans += [ans]
Ans = [str(x) for x in Ans]
print(' '.join(Ans))


(n, k) = [int(i) for i in input().split()]
ass = [int(i) for i in input().split()]
chi = [i + 1 for i in range(n)]
s = 0
for a in ass:
	print(chi[(a + s) % n], end=' ')
	chi.pop((a + s) % n)
	s = (a + s) % n
	n -= 1


(n, k) = [int(x) for x in input().split(' ')]
steps = [int(x) for x in input().split(' ')]
steps.reverse()
circle = list(range(n))
index = 0
for i in range(len(steps)):
	index = (index + steps.pop()) % len(circle)
	print(circle[index] + 1, end=' ')
	del circle[index]


(n, k) = list(map(int, input().split()))
a = list(map(int, input().split()))
leaderidx = 0
children = [i for i in range(1, n + 1)]
ans = []
for i in range(k):
	mov = a[i] % len(children)
	leaderidx = (leaderidx + mov) % len(children)
	ans.append(str(children[leaderidx]))
	del children[leaderidx]
print(' '.join(ans))


(n, k) = [int(a) for a in input().rstrip().split()]
array = [int(a) for a in input().split()]
narray = [i for i in range(1, n + 1)]
popArray = []
popIndex = 0
for i in range(0, k):
	popIndex = (array[i] + popIndex) % len(narray)
	print(narray[popIndex], end=' ')
	narray.remove(narray[popIndex])


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
children = [x for x in range(1, n + 1)]
l_index = 0
i = 0
out = []
while i < k:
	pos = a[i] % len(children) + l_index
	elim = children[pos % len(children)]
	out.append(str(elim))
	i += 1
	l_index = pos % len(children)
	del children[pos % len(children)]
print(' '.join(out))


(n, k) = map(int, input().split())
aa = [int(x) for x in input().split()]
nxt = [(i + 1) % n for i in range(n)]
prv = [(i - 1 + n) % n for i in range(n)]
cur = 0
for z in range(k):
	a = aa[z]
	a %= n
	for i in range(a):
		cur = nxt[cur]
	nxt[prv[cur]] = nxt[cur]
	prv[nxt[cur]] = prv[cur]
	print(cur + 1, end=' ')
	cur = nxt[cur]
	n -= 1


(n, k) = map(int, input().split())
children = list(range(1, n + 1))
leader = 0
answer = list()
for a in map(int, input().split()):
	leader = (leader + a) % len(children)
	answer.append(children[leader])
	del children[leader]
print(*answer)


(n, y) = input().split()
n = int(n)
y = int(y)
liste = list(range(1, n + 1))
x = 0
z = 0
liste2 = list(map(int, input().split()))
while x < y:
	z = (z + liste2[x]) % len(liste)
	print(liste[z])
	liste.pop(z)
	x += 1


(n, k) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
children = list(range(1, n + 1))
pos = 0
for i in range(k):
	pos = (pos + a[i]) % len(children)
	print(children[pos], end=' ')
	del children[pos]
print()


from sys import stdin
(n, _) = map(int, stdin.readline().rstrip().split())
data = list(map(int, stdin.readline().rstrip().split()))
child = list(range(1, n + 1))
cur_pos = 0
rs = []
for (index, count) in enumerate(data):
	count %= n - index
	while count > 0:
		cur_pos += 1
		if child[cur_pos % n] != 0:
			count -= 1
	rs.append(child[cur_pos % n])
	child[cur_pos % n] = 0
	while child[cur_pos % n] == 0:
		cur_pos += 1
print(' '.join(map(str, rs)))


(child_num, step_max) = map(int, input().split())
count_num = input()
count = [int(n) for n in count_num.split()]
leader = 0
step = 0
num = 1
child = []
while num <= child_num:
	child.append(num)
	num += 1
eli_num = []
eli_child = []
while step < step_max:
	eli_num.append((count[step] % child_num + leader) % child_num)
	eli_child.append(child[eli_num[step]])
	del child[eli_num[step]]
	child_num -= 1
	leader = eli_num[step]
	step += 1
for eli in eli_child:
	print(eli, end=' ')


a = list(map(int, input().split()))
n = a[0]
k = a[1]
b = list(map(int, input().split()))
l = [0] * n
for i in range(n):
	l[i] = i + 1
ans = []
for i in range(k):
	c = b[i]
	g = len(l)
	j = c % g
	ans.append(l[j])
	l.pop(j)
	l = l[j:] + l[:j]
print(*ans)


(n, k) = list(map(int, input().split()))
arr = list(map(int, input().split()))
child = list(range(1, n + 1))
main = 0
for i in range(k):
	j = (main + arr[i]) % len(child)
	print(child[j])
	del child[j]
	main = j % len(child)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
L = [i for i in range(1, n + 1)]
ldr = 0
for x in a:
	ldr = (ldr + x) % len(L)
	print(L[ldr], end=' ')
	L.pop(ldr)


(n, k) = map(int, input().strip().split(' '))
arr = list(map(int, input().strip().split()))
children = list([i + 1 for i in range(n)])
answer = []
i = 0
for ai in arr:
	i = (i + ai) % n
	answer.append(str(children[i]))
	del children[i]
	n -= 1
print(' '.join(answer))


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
b = [i + 1 for i in range(n)]
l = n
ans = []
ind = 0
x = 0
for i in range(k):
	ind = ind + a[i] % l
	if ind >= l:
		ind -= l
	ans.append(b.pop(ind))
	l -= 1
print(*ans)


__author__ = 'Alexander'
(n, k) = map(int, input().split())
a = [int(x) for x in input().split()]
loose = []
first = 0
for i in range(k):
	loose.append((a[i] + first) % (n - i) + 1)
	first = (a[i] + first) % (n - i)
lst = list(range(1, n + 1))
res = ''
for i in range(k):
	res += str(lst[loose[i] - 1]) + ' '
	lst.remove(lst[loose[i] - 1])
print(res)


(n, k) = map(int, input().split())
(*a,) = map(int, input().split())
g = list(range(n + 1))[1:]
n -= 1
v = 0
for i in a:
	v += i
	v %= len(g)
	print(g.pop(v), end=' ')


(n_children, steps) = map(int, input().strip().split())
numbers = list(map(int, input().strip().split()))
children = list(range(0, n_children))
leader = 0
for step in range(0, steps):
	eliminated = (leader + numbers[step]) % len(children)
	print(children[eliminated] + 1, end=' ')
	del children[eliminated]
	leader = eliminated % len(children)


(n, k) = (int(n) for n in input().split())
A = [int(n) for n in input().split()]
V = [i + 1 for i in range(n)]
pos = 0
elim = []
for i in range(k):
	pos = (pos + A[i]) % len(V)
	elim.append(V.pop(pos))
	if pos == len(V):
		pos = 0
for x in elim:
	print(x, end=' ')


(kids_n, rounds_n) = [int(x) for x in input().split(' ')]
rounds = [int(x) for x in input().split(' ')]
kids = [x + 1 for x in range(kids_n)]
leader = 0
for i in range(rounds_n):
	eliminated_index = (leader + rounds[i]) % kids_n
	if eliminated_index == kids_n - 1:
		leader = 0
	else:
		leader = eliminated_index
	eliminated_kid = kids.pop(eliminated_index)
	kids_n -= 1
	if i == rounds_n - 1:
		print(eliminated_kid)
	else:
		print(eliminated_kid, end=' ')


from collections import deque
(n, k) = list(map(int, input().split()))
a = [int(i) for i in input().split()]
d = deque([i for i in range(1, n + 1)])
res = []
for i in range(k):
	d.rotate(-a[i])
	x = d.popleft()
	res.append(x)
print(*res)


(n, k) = map(int, input().split())
arr = [i for i in range(1, n + 1)]
arg_k = list(map(int, input().split()))
v = 0
for i in arg_k:
	l = len(arr)
	d = (i + v) % l
	print(arr.pop(d))
	v = d % len(arr)


(n, k) = list(map(int, input().split()))
input2 = list(map(int, input().split()))
outputlist = []
currentl = [i for i in range(1, n + 1)]
ved = 0
for i in range(len(input2)):
	number = input2[i] % len(currentl)
	while number > 0:
		ved += 1
		ved %= len(currentl)
		number -= 1
	outputlist.append(currentl[ved])
	del currentl[ved]
	ved %= len(currentl)
print(' '.join(map(str, outputlist)))


def solution(n, nums):
	lis = [x for x in range(n)]
	pivot = 0
	for a in nums:
		steps = a % len(lis)
		borr = (pivot + steps) % len(lis)
		print(lis[borr] + 1, end=' ')
		del lis[borr]
		pivot = borr

def main():
	(n, k) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	solution(n, a)
main()


def solution(n, nums):
	child = [x for x in range(1, n + 1)]
	lead = 0
	for a in nums:
		steps = a % len(child)
		borr = (lead + steps) % len(child)
		print(child[borr], end=' ')
		del child[borr]
		lead = borr

def main():
	(n1, n2) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	solution(n1, a)
main()


(n, k) = map(int, input().split())
a = list(map(int, input().split()))

def round(children, a, leader):
	lead_pos = children.index(leader)
	a = (lead_pos + a) % len(children)
	deleted = children[a]
	del children[a]
	return (children, a % len(children), deleted)
children = list(range(1, n + 1))
result = []
leader = 1
for i in range(k):
	(children, leader_pos, deleted) = round(children, a[i], leader)
	leader = children[leader_pos]
	result.append(deleted)
print(*result, sep=' ')


(n, k) = map(int, input().split())
A = [int(x) for x in input().split()]
tab = list(range(1, n + 1))
leader = 0
result = []
for x in A:
	leader = (leader + x) % len(tab)
	result += [tab[leader]]
	tab = tab[:leader] + tab[leader + 1:]
	leader = leader % len(tab)
print(' '.join(map(str, result)))


n = int(input().split()[0])
a = list(map(int, input().split()))
ch = list(range(1, n + 1))
leader = ch[0]
for ai in a:
	out = (ch.index(leader) + ai) % len(ch)
	leader = ch[(out + 1) % len(ch)]
	print('{} '.format(ch[out]), end='')
	del ch[out]
	if len(ch) == 0:
		break


import sys
I = sys.stdin.readline
(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
c = list(range(n))
ans = []
s = 0
for i in arr:
	s = (s + i) % len(c)
	ans.append(1 + c.pop(s))
print(*ans)


(n, k) = [int(i) for i in input().split()]
passos = [int(i) for i in input().split()]
cri = []
for i in range(n):
	cri.append(i + 1)
ini = 0
for p in passos:
	ini += p
	ini %= len(cri)
	print(cri[ini], end=' ')
	cri.pop(ini)
print()


def plus(a):
	global n
	a += 1
	a = a % n
	return a
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
p = [1] * n
qwer = n
index = 0
for i in range(k):
	res = 0
	while res != a[i] % qwer:
		index = plus(index)
		res += p[index]
	p[index] = 0
	qwer -= 1
	print(index + 1, end=' ')
	while p[index] != 1:
		index = plus(index)


(n, k) = map(int, input().split())
ks = list(map(int, input().split()))
a = []
for i in range(1, n + 1):
	a.append(i)
l = 0
for i in range(k):
	t = ks[i]
	l = (t + l) % n
	print(a.pop(l), end=' ')
	n -= 1


(n, k) = map(int, input().split())
players = list(range(1, n + 1))
leader = 0
for count in map(int, input().split()):
	e = (leader + count) % n
	print(players[e], end=' ')
	players.pop(e)
	leader = e
	n -= 1


(n, k) = [int(x) for x in str(input()).split(' ', 1)]
next_ = [i + 1 for i in range(n + 1)]
next_[n] = 1
a = [int(x) for x in str(input()).split(' ')]
remain = n
cur = 1
prev = None
eli = []
for a0 in a:
	a0 = a0 % remain
	for _ in range(a0):
		prev = cur
		cur = next_[cur]
	if prev is None:
		prev = cur
		while next_[prev] != cur:
			prev = next_[prev]
	eli.append(cur)
	next_[prev] = next_[cur]
	cur = next_[cur]
	remain -= 1
print(' '.join([str(e) for e in eli]))


(n, k) = map(int, input().strip().split(' '))
lst = list(map(int, input().strip().split(' ')))
l = []
for i in range(1, n + 1):
	l.append(i)
i2 = 1
for i in range(1, k + 1):
	k1 = (lst[i - 1] + i2) % (n - i + 1)
	print(l[k1 - 1], end=' ')
	ind = l.index(l[k1 - 1])
	if l[ind] == l[-1]:
		i2 = 1
	else:
		i2 = k1
	del l[ind]


(n, k) = map(int, input().split())
childs = [i for i in range(1, n + 1)]
data = list(map(int, input().split()))
last_start = 0
count = n
for el in data:
	a = el % count
	print(childs.pop((last_start + a) % count), end=' ')
	last_start = (last_start + a) % count
	count -= 1


from collections import deque
from sys import stdin
lines = deque((line.strip() for line in stdin.readlines()))

def nextline():
	return lines.popleft()

def types(cast):
	return list((int(x) for x in nextline().split()))

def ints():
	return types(int)

def strs():
	return nextline().split()

def main():
	(n, k) = ints()
	nums = ints()
	cur = 0
	kids = list(range(1, n + 1))
	elims = [0] * k
	for i in range(k):
		elim = (cur + nums[i]) % len(kids)
		elims[i] = kids[elim]
		del kids[elim]
		if kids:
			cur = elim % len(kids)
	print(' '.join(map(str, elims)))
main()


i = 0

def someFunc():
	global i
	i += 1
	return i

class Human:

	def __init__(self, value, kum):
		self.value = value
		self.kum = kum
(n, k) = map(int, input().split())
aa = list(map(int, input().split()))
a = list(range(1, n + 1))
for i in aa:
	y = i % len(a)
	print(a[y], end=' ')
	a = a[y + 1:] + a[0:y]


from math import *
(n, k) = map(int, input().split())
q = [int(i) for i in input().split()]
v = [i for i in range(n)]
x = 0
for i in range(k):
	x = (x + q[i]) % len(v)
	print(v[x] + 1, end=' ')
	v.pop(x)
print()


(siz, qu) = map(int, input().split())
(ar, ind) = ([x for x in range(1, siz + 1)], 0)
for k in map(int, input().split()):
	nx = (ind + k) % siz
	print(ar[nx])
	siz -= 1
	ar.pop(nx)
	ind = nx


(n, k) = map(int, input().split())
list_k = list(map(int, input().split()))
list_child = [None] * n
for i in range(n):
	list_child[i] = i
count_from = 1
for i in range(k):
	eliminate = (list_k[i] + count_from - 1) % len(list_child)
	print(list_child.pop(eliminate) + 1, end=' ')
	count_from = (eliminate + 2) % len(list_child)
	count_from -= 1


(n, k) = [int(i) for i in input().split(' ')]
a = [int(i) for i in input().split(' ')]
childs = [i for i in range(n)]
leader = 0
deads = []
for i in range(k):
	dead = (leader + a[i]) % n
	deads.append(str(childs[dead] + 1))
	childs.pop(dead)
	n -= 1
	leader = dead
print(' '.join(deads))


(n, k) = map(int, input().split())
A = list(map(int, input().split()))
kids = list(range(1, n + 1))
next = 0
res = []
for a in A:
	n = len(kids)
	lose = (next + a) % n
	next = lose % n
	res.append(kids.pop(lose))
print(*res)


[n, k] = list(map(int, input().split()))
a = list(map(int, input().split()))
p = [i + 1 for i in range(n)]
leader = 0
res = []
for i in range(k):
	leader = (leader + a[i]) % n
	res.append(p.pop(leader))
	n = len(p)
	if leader == n:
		leader = 0
print(' '.join(map(str, res)))


import sys

def solve():
	(n, k) = map(int, input().split())
	ch = [i + 1 for i in range(n)]
	a = [int(i) for i in input().split()]
	live = n
	leader = 0
	ans = []
	for v in a:
		v = v % live
		j = 0
		cnt = 0
		while cnt < v:
			if ch[(leader + j + 1) % n]:
				cnt += 1
			j += 1
		ans.append((leader + j) % n + 1)
		ch[(leader + j) % n] = 0
		live -= 1
		leader = (leader + j + 1) % n
		while ch[leader] == 0:
			leader = (leader + 1) % n
	print(*ans)

def debug(x, table):
	for (name, val) in table.items():
		if x is val:
			print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
			return None

def __starting_point():
	solve()
__starting_point()


def main():
	(n, k) = map(int, input().split())
	a = map(int, input().split())
	kids = list(range(1, n + 1))
	i = 0
	for ai in a:
		i += ai
		i %= len(kids)
		print(kids[i], end=' ')
		del kids[i]
main()


import sys
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
(n, k) = I()
x = I()
l = [i + 1 for i in range(n)]
an = []
cur = 0
for i in range(k):
	cr = (cur + x[i]) % n
	an.append(l[cr])
	del l[cr]
	n -= 1
	cur = cr
print(*an)


import sys
LI = lambda : list(map(int, sys.stdin.readline().split()))
MI = lambda : map(int, sys.stdin.readline().split())
SI = lambda : sys.stdin.readline().strip('\n')
II = lambda : int(sys.stdin.readline())
(n, k) = MI()
inp = [i for i in range(1, n + 1)]
l = 0
out = []
for a in LI():
	e = (l + a) % len(inp)
	out.append(inp[e])
	l = e
	inp.pop(e)
print(*out)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
j = 0
L = list(range(1, n + 1))
for i in l:
	k -= 1
	j = (j + i) % n
	if k != 0:
		print(L[j], end=' ')
	else:
		print(L[j], end='')
	n -= 1
	L.pop(j)


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
l = list(range(1, n + 1))
leader = 0
for x in a:
	lx = (leader + x) % n
	print(l[lx], end=' ')
	del l[lx]
	n -= 1
	leader = lx % n


import sys
import bisect
from bisect import bisect_left as lb
input_ = lambda : sys.stdin.readline().strip('\r\n')
from math import log
from math import gcd
from math import atan2, acos
from random import randint
sa = lambda : input_()
sb = lambda : int(input_())
sc = lambda : input_().split()
sd = lambda : list(map(int, input_().split()))
sflo = lambda : list(map(float, input_().split()))
se = lambda : float(input_())
sf = lambda : list(input_())
flsh = lambda : sys.stdout.flush()
mod = 10 ** 9 + 7
mod1 = 998244353
gp = []
cost = []
dp = []
mx = []
ans1 = []
ans2 = []
special = []
specnode = []
a = 0
kthpar = []

def dfs(root, par):
	if par != -1:
		dp[root] = dp[par] + 1
	for i in range(1, 20):
		if kthpar[root][i - 1] != -1:
			kthpar[root][i] = kthpar[kthpar[root][i - 1]][i - 1]
	for child in gp[root]:
		if child == par:
			continue
		kthpar[child][0] = root
		dfs(child, root)
ans = 0

def hnbhai(tc):
	(n, k) = sd()
	a = sd()
	temp = [i for i in range(1, n + 1)]
	lead = 0
	ans = []
	for i in range(k):
		tot = a[i]
		ind = (lead + tot) % len(temp)
		if ind == n - 1:
			ans.append(temp.pop())
			lead = 0
			continue
		ans.append(temp.pop(ind))
		lead = ind
	print(*ans)
for _ in range(1):
	hnbhai(_ + 1)


(n, k) = map(int, input().split())
l = list(map(int, input().split()))
temp = []
for i in range(n):
	temp.append(i + 1)
x = 0
i = 0
mlist = []
while k != 0:
	y = l[i] % n
	z = x + y
	if z > n - 1:
		w = z % n
	else:
		w = z
	mlist.append(temp[w])
	temp.pop(w)
	x = w
	i += 1
	n -= 1
	k -= 1
print(*mlist)


res = ''
ved = 0
ost = 0
(n, k) = map(int, input().split())
s = input().split()
al = [int(c) for c in s]
kl = [c for c in range(n)]
for i in range(k):
	ost = al[i] % len(kl)
	if ved + ost > len(kl) - 1:
		ved = ost - (len(kl) - ved)
	else:
		ved = ved + ost
	res = res + str(kl[ved] + 1) + ' '
	kl.remove(kl[ved])
	if ved == len(kl):
		ved = 0
print(res)


(n, k) = map(int, input().split())
a = [int(x) for x in input().split()]
ld = 0
ppl = list(range(1, n + 1))
for rd in range(k):
	ld = (ld + a[rd]) % len(ppl)
	print(ppl[ld], end=' ')
	ppl = ppl[:ld] + ppl[ld + 1:]
print()


(n, _) = [int(i) for i in input().strip().split(' ')]
ak = [int(i) for i in input().strip().split(' ')]
people = list(range(1, n + 1))
current = 0
leaved = []
for k in ak:
	pos = (current + k) % len(people)
	leave = people.pop(pos)
	leaved.append(leave)
	if pos >= len(people):
		current = 0
	else:
		current = pos
print(' '.join(map(str, leaved)))


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
x = [0] * n
y = ''
for i in range(n):
	x[i] = i + 1
c = 0
for j in range(len(a)):
	a[j] = (a[j] + c) % (n - j)
	y += str(x[a[j]]) + ' '
	del x[a[j]]
	c = a[j]
print(y)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
mod = 10 ** 9 + 7

def LI():
	return [int(x) 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 main():
	(n, k) = LI()
	ka = list(range(n))
	a = LI()
	r = []
	l = 0
	for _ in range(k):
		t = a[_]
		al = len(ka)
		b = (l + t) % al
		r.append(ka[b] + 1)
		ka = ka[:b] + ka[b + 1:]
		l = b
	return ' '.join(map(str, r))
print(main())


(n, k) = map(int, input().split())
l = [i for i in range(n)]
leader = 0
K = list(map(int, input().split()))
for i in K:
	leader += i
	leader %= n
	print(l[leader] + 1, end=' ')
	del l[leader]
	n -= 1
	leader %= n


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
b = [i + 1 for i in range(n)]
l = 1
for i in range(k):
	for j in range(len(b)):
		if b[j] == l:
			break
	r = len(b) - j - 1
	l = j + 1
	t = a[i] % (l + r)
	if t <= r and t != 0:
		t = j + t
	elif t > r:
		t = t - r - 1
	else:
		t = j
	if t == len(b) - 1:
		print(b[t], end=' ')
		del b[t]
		l = b[0]
	else:
		print(b[t], end=' ')
		del b[t]
		l = b[t]


(n, k) = map(int, input().split())
data = map(int, input().split())
arr = [i + 1 for i in range(n)]
for v in data:
	l = len(arr)
	i = v % l
	print(arr[i], end=' ')
	arr = [arr[(i + k) % l] for k in range(1, l)]
print()


(n, k) = map(int, input().split())
a = map(int, input().split())
b = list(range(1, n + 1))
p = 0
for i in range(k):
	d = next(a) % len(b)
	for j in range(d):
		p = (p + 1) % len(b)
	print(b[p], end=' ')
	b.pop(p)
	p %= len(b)


(n, k) = input().split()
n = int(n)
k = int(k)
a = list(map(int, input().split()))
b = []
for i in range(n):
	b.append(i + 1)
ptr = 1
for i in range(k):
	temp = (ptr + a[i]) % n
	print(b[temp - 1], end=' ')
	b.pop(temp - 1)
	ptr = temp
	if temp == 0:
		ptr = 1
	n -= 1


(n, x) = map(int, input().split())
a = []
for x in range(1, n + 1):
	a.append(x)
b = list(map(int, input().split()))
for z in b:
	z %= len(a)
	print(a[z], end=' ')
	a = a[z + 1:] + a[:z]


(n, k) = map(int, input().split())
lst = [int(x) for x in input().split()]
a = [int(x) for x in range(n)]
t = 0
for x in range(k):
	t += lst[x]
	t %= n - x
	print(a[t] + 1, end=' ')
	a = a[:t] + a[t + 1:]


(num_children, num_steps) = list(map(int, input().split(' ')))
counts_at_each_step = list(map(int, input().split(' ')))

def next_index_in_list(list_, index):
	if index == len(list_) - 1:
		return 0
	return index + 1

def prev_index_in_list(list_, index):
	if index == 0:
		return len(list_) - 1
	return index - 1

def update_current_leader_index(current_leader_index, eliminate_index, list_):
	if current_leader_index > eliminate_index:
		return prev_index_in_list(list_, current_leader_index)
	else:
		return current_leader_index
children = list(range(1, num_children + 1))
current_leader_index = 0
elimination_sequence = []
for count_at_step in counts_at_each_step:
	eliminate_index = (count_at_step + current_leader_index) % len(children)
	elimination_sequence.append(children[eliminate_index])
	current_leader_index = next_index_in_list(children, eliminate_index)
	del children[eliminate_index]
	current_leader_index = update_current_leader_index(current_leader_index, eliminate_index, children)
print(' '.join(map(str, elimination_sequence)))


(nn, k) = map(int, input().split())
n = nn
a = list(map(int, input().split()))
c = list(range(1, n + 1))
s = 0
ans = []
for j in a:
	x = j % n
	m = 0
	while m < x:
		s += 1
		s %= nn
		while c[s] == -1:
			s += 1
			s %= nn
		m += 1
	ans.append(str(c[s]))
	c[s] = -1
	n -= 1
	if n > 0:
		while c[s] == -1:
			s += 1
			s %= nn
print(' '.join(ans))


(n, k) = map(int, input().split())
l = input()
a = [int(i) for i in l.split()]
m = list(range(1, n + 1))
l = ''
b = 0
d = len(m)
for i in a:
	if m[(i + b) % d] == m[len(m) - 1]:
		l += '{} '.format(m[(i + b) % d])
		m.remove(m[(i + b) % d])
		b = 0
	else:
		l += '{} '.format(m[(i + b) % d])
		m.remove(m[(i + b) % d])
		b = m.index(m[(i + b) % d])
	d = len(m)
print(l)


import sys
foo = [int(x) for x in sys.stdin.readline().strip().split(' ')]
(n, k) = foo
inp = [int(x) for x in sys.stdin.readline().strip().split(' ')]
people = [x for x in range(0, n)]
leader = 0
for a in inp:
	removed_idx = (leader + a) % len(people)
	print(people[removed_idx] + 1)
	del people[removed_idx]
	leader = removed_idx


import sys
from bisect import bisect_right as rb
from collections import deque
from queue import PriorityQueue
from math import *
input_ = lambda : sys.stdin.readline().strip('\r\n')
ii = lambda : int(input_())
il = lambda : list(map(int, input_().split()))
ilf = lambda : list(map(float, input_().split()))
ip = lambda : input_()
fi = lambda : float(input_())
ap = lambda ab, bc, cd: ab[bc].append(cd)
li = lambda : list(input_())
pr = lambda x: print(x)
prinT = lambda x: print(x)
f = lambda : sys.stdout.flush()
inv = lambda x: pow(x, mod - 2, mod)
mod = 10 ** 9 + 7
(n, k) = il()
a = [i for i in range(1, n + 1)]
b = il()
l = 0
for i in b:
	ind = (l + i) % len(a)
	print(a[ind], end=' ')
	a.pop(ind)
	l = ind


(n, k) = map(int, input().split())
cs = [i + 1 for i in range(n)]
rem = 0
for v in map(int, input().split()):
	rem = (rem + v) % len(cs)
	print(cs[rem], end=' ')
	cs.remove(cs[rem])


import bisect
from itertools import accumulate
import os
import sys
import math
from decimal import *
from io import BytesIO, IOBase
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))

def input():
	return sys.stdin.readline().rstrip('\r\n')

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 SieveOfEratosthenes(n):
	prime = []
	primes = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if primes[p] == True:
			prime.append(p)
			for i in range(p * p, n + 1, p):
				primes[i] = False
		p += 1
	return prime

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

def factors(n):
	fac = set()
	fac.add(1)
	fac.add(n)
	for i in range(2, int(math.sqrt(n)) + 1):
		if n % i == 0:
			fac.add(i)
			fac.add(n // i)
	return list(fac)

def modInverse(a, m):
	m0 = m
	y = 0
	x = 1
	if m == 1:
		return 0
	while a > 1:
		q = a // m
		t = m
		m = a % m
		a = t
		t = y
		y = x - q * y
		x = t
	if x < 0:
		x = x + m0
	return x
(n, k) = map(int, input().split())
num = [i for i in range(1, n + 1)]
a = list(map(int, input().split()))
boss = 0
j = 0
while True:
	if num.count(-1) == n:
		exit()
	for i in range(0, len(a)):
		count = 0
		j = (j + 1) % len(num)
		while j < len(num):
			count += 1
			if (a[i] - count) % len(num) == 0:
				print(num[j], end=' ')
				num.pop(j)
				break
			j = (j + 1) % len(num)
	exit()


import sys
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
num = [i for i in range(1, n + 1)]
leader = 0
for i in range(k):
	if a[i] == n:
		pos = leader
	elif a[i] > n:
		a[i] = a[i] % n
		pos = leader + a[i]
	if leader + a[i] >= n:
		a[i] -= n - 1 - leader
		pos = a[i] - 1
	else:
		pos = leader + a[i]
	print(num[pos], '', end='')
	num.pop(pos)
	leader = pos
	n -= 1


inp1 = input().split()
n = int(inp1[0])
k = int(inp1[1])
koh_lanta = list(range(1, n + 1))
liste_elimination = input().split()
lead = 0
eliminated = []
for i in range(k):
	lead = (lead + int(liste_elimination[i])) % (n - i)
	eliminated.append(koh_lanta.pop(int(lead)))
print(*eliminated)


import math
import queue
(n, k) = map(int, input().split())
s = []
a = [int(cost) for cost in input().split()]
for i in range(1, n + 1):
	s.append(i)
for i in range(0, k):
	b = a[i] % n
	print(s[b], '', end='')
	temp_arr = []
	for i in range(b + 1, n):
		temp_arr.append(s[i])
	for i in range(0, b):
		temp_arr.append(s[i])
	s = temp_arr
	n -= 1


def circle(arr, start):
	if start == arr.__len__():
		start = 0
	while True:
		yield start
		start += 1
		if start == arr.__len__():
			start = 0

def get_ith_victim(a, i, count):
	z = count % a.__len__()
	it = circle(a, i)
	toPop = i
	while z >= 0:
		toPop = it.__next__()
		z -= 1
	res = a.pop(toPop)
	return (res, toPop)
(n, k) = tuple(map(int, input().split()))
nums = list(map(int, input().split()))
members = list(range(1, n + 1))
next_leader = 0
for c in nums:
	(victim, next_leader) = get_ith_victim(members, next_leader, c)
	print(victim, end=' ')


import math
import os
import random
import re
import sys

def mindist(n, k, list):
	player = [i for i in range(1, n + 1)]
	capo = 0
	rem = n
	result = ''
	for step in range(k):
		puntato = (capo + list[step]) % rem
		capo = puntato
		result += str(player[puntato]) + ' '
		player.remove(player[puntato])
		rem -= 1
	return result[:-1]
[n, k] = list(map(int, input().rstrip().split()))
list = list(map(int, input().rstrip().split()))
print(mindist(n, k, list))


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
cur = 0
x = []
for i in range(n):
	x.append(i + 1)
for i in range(k):
	v = cur
	f = a[i] % n
	for j in range(f):
		v += 1
		if v >= n:
			v = v - n
	print(x[v], end=' ')
	x.pop(v)
	n -= 1
	cur = v % n


(n, k) = [int(x) for x in input().split(' ')]
steps = [int(x) for x in input().split(' ')]
leader = 0
children = [x for x in range(1, n + 1)]
result = []
for s in steps:
	next_index = (leader + s) % len(children)
	result.append(children[next_index])
	del children[next_index]
	leader = next_index
print(' '.join(map(lambda x: str(x), result)))


(n, k) = map(int, input().strip().split())
a = list(map(int, input().strip().split()))
ch = list(range(1, n + 1))
curr = 0
out = []
for i in range(k):
	curr = (curr + a[i]) % len(ch)
	out.append(ch.pop(curr))
	if curr == len(ch):
		curr = 0
print(' '.join(map(str, out)))


import sys
(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
num = []
for i in range(n):
	num.append(i + 1)
cnt = pos = elliminate = 0
res = []
for j in range(k):
	cnt = arr[j] % n
	if elliminate + cnt < n:
		elliminate = elliminate + cnt
	else:
		elliminate = cnt - (n - 1 - elliminate) - 1
	res.append(num[elliminate])
	num.pop(elliminate)
	n -= 1
	if elliminate < n - 1:
		leader = num[elliminate]
	else:
		leader = num[0]
print(*res, sep=' ')


from sys import stdout

def solve():
	(n, k) = map(int, input().rstrip().split())
	ls = list(map(int, input().rstrip().split()))
	children = [i for i in range(1, n + 1)]
	index = 0
	for elt in ls:
		index = (index + elt) % len(children)
		stdout.write(str(children[index]) + ' ')
		children.pop(index)
	print()
solve()


import sys
(n, k) = map(int, input().split())
a = list(map(int, input().split()))
out = [False for i in range(n)]
i = 0
for j in range(k):
	num = a[j] % (n - j)
	while num > 0:
		i = (i + 1) % n
		if not out[i]:
			num -= 1
	out[i] = True
	print(i + 1, end=' ')
	i = (i + 1) % n
	while out[i]:
		i = (i + 1) % n


(n, k) = map(int, input().split())
lst = [i for i in range(1, n + 1)]
arr = [int(x) for x in input().split()]
lead = 0
for i in range(k):
	print(lst.pop((lead + arr[i]) % n), end=' ')
	lead = (lead + arr[i]) % n
	n -= 1


(n, k) = map(int, input().split())
a = list(map(int, input().split()))
lead = 0
lst = []
for i in range(1, n + 1):
	lst.append(i)
for i in range(k):
	ind = (lead + a[i]) % len(lst)
	print(lst[ind], end=' ')
	lead = ind
	lst[ind] = -1
	llst = []
	for j in range(len(lst)):
		if lst[j] != -1:
			llst.append(lst[j])
	lst = list(llst)


import math
(n, k) = map(int, input().split())
a = [int(i) for i in input().split()]
mass = []
printmass = ''
count = n
now = 0
for i in range(n):
	mass.insert(i, i + 1)
for i in range(k):
	a[i] = (a[i] + now) % count
	printmass += str(mass[a[i]]) + ' '
	del mass[a[i]]
	now = a[i]
	count -= 1
print(printmass)


def geti():
	return map(int, input().split())
(n, k) = geti()
a = list(geti())
xk = [i + 1 for i in range(n)]
t = 1
b = []
x = 0
for i in range(k):
	x = (x + a[i]) % len(xk)
	b.append(xk[x])
	xk.remove(xk[x])
for i in b:
	print(i, end=' ')