Sereja has got an array, consisting of n integers, a_1, a_2, ..., a_{n}. Sereja is an active boy, so he is now going to complete m operations. Each operation will have one of the three forms:  Make v_{i}-th array element equal to x_{i}. In other words, perform the assignment a_{v}_{i} = x_{i}.  Increase each array element by y_{i}. In other words, perform n assignments a_{i} = a_{i} + y_{i} (1 ≤ i ≤ n).  Take a piece of paper and write out the q_{i}-th array element. That is, the element a_{q}_{i}. 

Help Sereja, complete all his operations.


-----Input-----

The first line contains integers n, m (1 ≤ n, m ≤ 10^5). The second line contains n space-separated integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 10^9) — the original array.

Next m lines describe operations, the i-th line describes the i-th operation. The first number in the i-th line is integer t_{i} (1 ≤ t_{i} ≤ 3) that represents the operation type. If t_{i} = 1, then it is followed by two integers v_{i} and x_{i}, (1 ≤ v_{i} ≤ n, 1 ≤ x_{i} ≤ 10^9). If t_{i} = 2, then it is followed by integer y_{i} (1 ≤ y_{i} ≤ 10^4). And if t_{i} = 3, then it is followed by integer q_{i} (1 ≤ q_{i} ≤ n).


-----Output-----

For each third type operation print value a_{q}_{i}. Print the values in the order, in which the corresponding queries follow in the input.


-----Examples-----
Input
10 11
1 2 3 4 5 6 7 8 9 10
3 2
3 9
2 10
3 1
3 10
1 1 10
2 10
2 10
3 1
3 10
3 9

Output
2
9
11
20
30
40
39

Difficulty: EASY

Solutions:
import sys
(length, ops) = map(int, sys.stdin.readline().split())
arr = list(map(int, sys.stdin.readline().split()))
cnt = 0
for z in range(ops):
	things = list(map(int, sys.stdin.readline().split()))
	if things[0] == 1:
		arr[things[1] - 1] = things[2] - cnt
	elif things[0] == 2:
		cnt += things[1]
	else:
		sys.stdout.write(str(arr[things[1] - 1] + cnt) + '\n')


(n, m) = [int(x) for x in input().split()]
lista = [int(x) for x in input().split()]
soma = 0
dic = {}
for i in range(m):
	entrada = input().split()
	a = entrada[0]
	b = int(entrada[1])
	if a == '1':
		lista[b - 1] = int(entrada[2])
		dic[b] = soma
	elif a == '2':
		soma += b
	elif a == '3':
		if b in dic:
			total = soma - dic[b]
			print(lista[b - 1] + total)
		else:
			print(lista[b - 1] + soma)


import sys
(n, m) = map(int, sys.stdin.readline().split())
L = list(map(int, sys.stdin.readline().split()))
c = 0
Ans = ''
for i in range(m):
	x = list(map(int, sys.stdin.readline().split()))
	if x[0] == 1:
		L[x[1] - 1] = x[2] - c
	elif x[0] == 2:
		c += x[1]
	else:
		Ans += str(L[x[1] - 1] + c) + '\n'
sys.stdout.write(Ans)


(n, q) = map(int, input().split())
a = list(map(int, input().split()))
b = 0
s = ''
for i in range(q):
	l = list(map(int, input().split()))
	if l[0] == 3:
		s += str(a[l[1] - 1] + b) + '\n'
	elif l[0] == 2:
		b += l[1]
	elif l[0] == 1:
		a[l[1] - 1] = l[2] - b
print(s)


from sys import stdin
(n, m) = list(map(int, stdin.readline().split()))
a = [0] + list(map(int, stdin.readline().split()))
s = 0
for x in range(m):
	op = list(map(int, stdin.readline().split()))
	if op[0] == 1:
		a[op[1]] = op[2] - s
	elif op[0] == 2:
		s += op[1]
	else:
		print(a[op[1]] + s)


(x, k) = input().split()
x = int(x)
k = int(k)
a = list(map(int, input().split()))
b = []
aumento = 0
for i in range(k):
	y = list(map(int, input().split()))
	if y[0] == 1:
		a[y[1] - 1] = y[2] - aumento
	elif y[0] == 2:
		aumento += y[1]
	else:
		b.append(str(a[y[1] - 1] + aumento))
print('\n'.join(b))


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
acc = 0
for i in range(m):
	query = list(map(int, input().split()))
	if query[0] == 1:
		a[query[1] - 1] = query[2] - acc
	elif query[0] == 2:
		acc += query[1]
	elif query[0] == 3:
		print(a[query[1] - 1] + acc)


(n, m) = map(int, input().split())
A = [0] + [int(x) for x in input().split()]
Q = 0
Answer = []
for i in range(m):
	temp = [int(x) for x in input().split()]
	if temp[0] == 1:
		v = temp[1]
		x = temp[2]
		A[v] = x - Q
	elif temp[0] == 2:
		y = temp[1]
		Q += y
	elif temp[0] == 3:
		q = temp[1]
		Answer.append(str(Q + A[q]))
print('\n'.join(Answer))


def main():
	(n, m) = list(map(int, input().split()))
	aa = list(map(int, input().split()))
	(delta, res) = (0, [])
	for _ in range(m):
		l = list(map(int, input().split()))
		if l[0] == 1:
			aa[l[1] - 1] = (l[2], delta)
		elif l[0] == 2:
			delta += l[1]
		else:
			x = aa[l[1] - 1]
			res.append(str((x[0] - x[1] if type(x) is tuple else x) + delta))
	print('\n'.join(res))

def __starting_point():
	main()
__starting_point()


(N, M) = tuple((int(i) for i in input().split()))
A = list((int(i) for i in input().split()))
AOE = 0
out = ''
for m in range(M):
	val = tuple((int(i) for i in input().split()))
	if val[0] == 1:
		ind = val[1]
		x = val[2]
		A[ind - 1] = x - AOE
	elif val[0] == 2:
		AOE += val[1]
	elif val[0] == 3:
		out += str(A[val[1] - 1] + AOE) + '\n'
print(out, end='')


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
(tmp, s) = (0, '')
for i in range(m):
	op = list(map(int, input().split()))
	if op[0] == 1:
		l[op[1] - 1] = op[-1] - tmp
	elif op[0] == 2:
		tmp += op[-1]
	else:
		s += f'{l[op[-1] - 1] + tmp}\n'
print(s)


def take_input(s):
	if s == 1:
		return int(input())
	return map(int, input().split())

def op_1(a, v, x, count):
	a[v - 1] = x - count
	return a

def op_3(a, q, count):
	print(a[q - 1] + count)
(n, m) = take_input(2)
if n > 1:
	a = list(take_input(n))
else:
	a = [take_input(1)]
count = 0
for i in range(m):
	s = input()
	if s[0] == '1':
		(t, v, x) = map(int, s.split())
		a = op_1(a, v, x, count)
	elif s[0] == '2':
		(t, y) = map(int, s.split())
		count += y
	else:
		(t, q) = map(int, s.split())
		op_3(a, q, count)


(n, m) = map(int, input().split())
a = [0] + [*map(int, input().split())]
s = ''
for i in range(m):
	x = list(map(int, input().split()))
	if x[0] == 1:
		a[x[1]] = x[2] - a[0]
	elif x[0] == 2:
		a[0] += x[1]
	elif x[0] == 3:
		s += str(a[x[1]] + a[0]) + '\n'
print(s)


firstLine = list(map(int, input().split()))
array = list(map(int, input().split()))
arraySize = firstLine[0]
numOperations = firstLine[1]
totalSum = 0
s = ''
for i in range(numOperations):
	command = list(map(int, input().split()))
	op = command[0]
	param1 = command[1]
	if op == 1:
		array[param1 - 1] = command[2] - totalSum
	elif op == 2:
		totalSum += param1
	else:
		s += str(array[param1 - 1] + totalSum) + '\n'
print(s)


import sys, threading, os.path
import collections, heapq, math, bisect
import string
from platform import python_version
import itertools
sys.setrecursionlimit(10 ** 6)
threading.stack_size(2 ** 27)

def main():
	if os.path.exists('input.txt'):
		input = open('input.txt', 'r')
	else:
		input = sys.stdin
	(n, m) = list(map(int, input.readline().split()))
	lis = list(map(int, input.readline().split()))
	sumall = 0
	sol = []
	for i in range(m):
		temlis = list(map(int, input.readline().split()))
		if temlis[0] == 1:
			lis[temlis[1] - 1] = temlis[2] - sumall
		elif temlis[0] == 2:
			sumall += temlis[1]
		elif temlis[0] == 3:
			sol.append(lis[temlis[1] - 1] + sumall)
	output = '\n'.join(map(str, sol))
	if os.path.exists('output.txt'):
		open('output.txt', 'w').writelines(str(output))
	else:
		sys.stdout.write(str(output))
main()


import os
import sys
from io import BytesIO, IOBase
input = sys.stdin.readline

def inp():
	return int(input())

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

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

def main():
	try:
		(n, m) = invr()
		a = inlt()
		s = 0
		for _ in range(m):
			t = inlt()
			if t[0] == 1:
				a[t[1] - 1] = t[2] - s
			elif t[0] == 2:
				s += t[1]
			else:
				print(a[t[1] - 1] + s)
	except Exception as e:
		print(e)
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')
main()


entrada = input().split()
size = int(entrada[0])
operations = int(entrada[1])
array = [int(valor) for valor in input().split()]
aux = 0
for i in range(operations):
	to_do = [int(valor) for valor in input().split()]
	if to_do[0] == 3:
		print(array[to_do[1] - 1] + aux)
	elif to_do[0] == 2:
		aux += to_do[1]
	elif to_do[0] == 1:
		array[to_do[1] - 1] = to_do[2] - aux


(n, m) = map(int, input().split())
a = [int(i) for i in input().split()]
add = [0] * n
b = 0
results = []
for i in range(m):
	op = [int(j) for j in input().split()]
	if op[0] == 1:
		add[op[1] - 1] = op[2] - b - a[op[1] - 1]
	elif op[0] == 2:
		b += op[1]
	else:
		results.append(a[op[1] - 1] + add[op[1] - 1] + b)
for result in results:
	print(result)


from sys import stdin
(N, M) = list(map(int, input().split()))
A = [int(a) for a in stdin.readline().split()]
globalIncreaser = 0
for i in range(M):
	op = [int(a) for a in stdin.readline().split()]
	opcode = op[0]
	if opcode == 1:
		(opcode, v, x) = op
		A[v - 1] = x - globalIncreaser
	elif opcode == 2:
		(opcode, y) = op
		globalIncreaser += y
	elif opcode == 3:
		(opcode, q) = op
		print(A[q - 1] + globalIncreaser)


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

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 map(int, input().split())

def array():
	return [int(i) for i in input().split()]
(n, m) = value()
a = array()
inc = 0
for _ in range(m):
	t = array()
	if t[0] == 1:
		a[t[1] - 1] = t[2] - inc
	elif t[0] == 2:
		inc += t[1]
	else:
		print(a[t[1] - 1] + inc)


from sys import stdin, stdout
(n, m) = map(int, input().split())
s = list(map(int, stdin.readline().split()))
p = 0
for _ in range(m):
	a = list(map(int, stdin.readline().split()))
	if a[0] == 1:
		s[a[1] - 1] = a[2] - p
	elif a[0] == 2:
		p += a[1]
	else:
		print(s[a[1] - 1] + p)


from sys import stdin, stdout
(n, m) = map(int, stdin.readline().split())
arr = [int(i) for i in stdin.readline().split()]
res = 0
for i in range(m):
	b = [int(x) for x in stdin.readline().split()]
	if b[0] == 1:
		arr[b[1] - 1] = b[2] - res
	elif b[0] == 2:
		res += b[1]
	else:
		stdout.write(str(arr[b[1] - 1] + res) + '\n')


(n, m) = list(map(int, input().split()))
arr = [int(i) for i in input().split()]
(res, s) = (0, '')
for i in range(m):
	b = [int(x) for x in input().split()]
	if b[0] == 1:
		arr[b[1] - 1] = b[2] - res
	elif b[0] == 2:
		res += b[1]
	else:
		s += str(arr[b[1] - 1] + res) + '\n'
print(s)


import os
import sys
from io import BytesIO, IOBase

def main():
	(n, m) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	op = [0 for x in range(n)]
	cur = 0
	for x in range(m):
		temp = list(map(int, input().split(' ')))
		if temp[0] == 1:
			a[temp[1] - 1] = temp[2]
			op[temp[1] - 1] = -cur
		elif temp[0] == 2:
			cur += temp[1]
		else:
			print(a[temp[1] - 1] + op[temp[1] - 1] + cur)
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')
main()


(n, m) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
soma = 0
for mm in range(m):
	entrada = [int(x) for x in input().split()]
	if entrada[0] == 1:
		a[entrada[1] - 1] = entrada[2] - soma
	elif entrada[0] == 2:
		soma += entrada[1]
	else:
		print(a[entrada[1] - 1] + soma)


from sys import *
input = stdin.readline
(n, m) = map(int, input().split())
l = list(map(int, input().split()))
c = 0
for i in range(m):
	d = list(map(int, input().split()))
	if d[0] == 1:
		l[d[1] - 1] = d[2] - c
	elif d[0] == 2:
		c = c + d[1]
	else:
		print(l[d[1] - 1] + c)


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
t = 1
for _ in range(t):
	(n, q) = map(int, input().split())
	arr = list(map(int, input().split()))
	sums = [0]
	lastAssign = [[x, 1] for x in arr]
	while q:
		ops = list(map(int, input().split()))
		if ops[0] == 1:
			ind = ops[1] - 1
			val = ops[2]
			lastAssign[ind] = [val, len(sums)]
		elif ops[0] == 2:
			sums.append(sums[-1] + ops[1])
		else:
			ind = ops[1] - 1
			till = lastAssign[ind][1]
			init = lastAssign[ind][0]
			print(init + sums[-1] - sums[till - 1])
		q -= 1


(n, m) = input().split()
a = input().split()
soma = 0
dic = {}
total = 0
for x in range(int(m)):
	b = input().split()
	v = int(b[1])
	if b[0] == '1':
		b[2] = int(b[2])
		a[v - 1] = b[2]
		dic[v] = soma
	elif b[0] == '2':
		soma = soma + v
	elif b[0] == '3':
		if v in dic:
			total = soma - dic[v]
			print(int(a[v - 1]) + total)
		else:
			print(int(a[v - 1]) + soma)


from sys import stdin, stdout
(n, m) = [int(i) for i in stdin.readline().split()]
a = [int(i) for i in stdin.readline().split()]
add = 0
for it in range(m):
	b = [int(i) for i in stdin.readline().split()]
	if b[0] == 1:
		a[b[1] - 1] = b[2] - add
	elif b[0] == 2:
		add += b[1]
	else:
		stdout.write(str(a[b[1] - 1] + add) + '\n')


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
b = 0
s = ''
for _ in range(m):
	l = list(map(int, input().split()))
	if l[0] == 3:
		s += str(a[l[1] - 1] + b) + '\n'
	elif l[0] == 2:
		b += l[1]
	elif l[0] == 1:
		a[l[1] - 1] = l[2] - b
print(s)


(n, m) = list(map(int, input().split()))
a = list(map(int, input().split()))
res = []
total_sum = 0
for i in range(m):
	data = list(map(int, input().split()))
	if data[0] == 1:
		a[data[1] - 1] = data[2] - total_sum
	elif data[0] == 2:
		total_sum += data[1]
	else:
		res.append(str(a[data[1] - 1] + total_sum))
print('\n'.join(res))


(n, m) = [int(x) for x in input().split(' ')]
a = [int(x) for x in input().split(' ')]
s = []
for i in range(m):
	s.append([int(x) for x in input().split(' ')])
add = 0
for l in s:
	if l[0] == 1:
		(v, x) = (int(l[1]), int(l[2]))
		a[v - 1] = x - add
	elif l[0] == 2:
		y = int(l[1])
		add += y
	elif l[0] == 3:
		print(a[int(l[1]) - 1] + add)


(n, m) = map(int, input().split())
arr = [int(i) for i in input().split()]
add = 0
for i in range(m):
	temp = [int(i) for i in input().split()]
	if temp[0] == 1:
		arr[temp[1] - 1] = temp[2] - add
	if temp[0] == 2:
		add += temp[1]
	if temp[0] == 3:
		print(add + arr[temp[1] - 1])


(n, m) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
l = 0
for _ in range(m):
	inp = [int(i) for i in input().split()]
	if inp[0] == 1:
		a[inp[1] - 1] = inp[2] - l
	elif inp[0] == 2:
		l += inp[1]
	else:
		print(a[inp[1] - 1] + l)


import sys
(n, m) = [int(x) for x in sys.stdin.readline().strip().split()]
arr = [int(x) for x in sys.stdin.readline().strip().split()]
incd = 0
for i in range(m):
	opp = [int(x) for x in sys.stdin.readline().strip().split()]
	if opp[0] == 1:
		arr[opp[1] - 1] = opp[2] - incd
	elif opp[0] == 2:
		incd += opp[1]
	elif opp[0] == 3:
		print(arr[opp[1] - 1] + incd)


from sys import stdin, stdout
(n, m) = map(int, stdin.readline().split())
a = list(map(int, stdin.readline().split()))
s = 0
for _ in range(m):
	t = list(map(int, stdin.readline().split()))
	if t[0] == 1:
		(v, x) = (t[1], t[2])
		a[v - 1] = x - s
	elif t[0] == 2:
		v = t[1]
		s += v
	else:
		v = t[1]
		print(a[v - 1] + s)


values = [*map(int, input().split())]
(n, m) = values
array = [*map(int, input().split())]
ad = 0
result = []
for i in range(m):
	op = [*map(int, input().split())]
	if op[0] == 1:
		index = op[1] - 1
		array[index] = op[2] - ad
	if op[0] == 2:
		ad += op[1]
	if op[0] == 3:
		index = op[1] - 1
		result.append(str(array[index] + ad))
print('\n'.join(result))


from sys import stdin, stdout
m = int(input().split()[1])
a = [int(x) for x in stdin.readline().split()]
(s, o) = (0, '')
for i in range(m):
	x = [int(x) for x in stdin.readline().split()]
	if x[0] == 1:
		a[x[1] - 1] = x[2] - s
	elif x[0] == 2:
		s += x[1]
	else:
		o += str(a[x[1] - 1] + s) + '\n'
stdout.write(o)


import sys
import itertools
import collections

def rs(x=''):
	return sys.stdin.readline().strip() if len(x) == 0 else input(x).strip()

def ri(x=''):
	return int(rs(x))

def rm(x=''):
	return map(str, rs(x).split())

def rl(x=''):
	return rs(x).split()

def rmi(x=''):
	return map(int, rs(x).split())

def rli(x=''):
	return [int(x) for x in rs(x).split()]

def println(val):
	sys.stdout.write(str(val) + '\n')

def solve(testCase):
	(n, m) = rmi()
	a = rli()
	queries = [tuple(rmi()) for _ in range(m)]
	add = 0
	mark = [0] * n
	inc = 0
	for (t, *operation) in queries:
		if t == 1:
			(vi, x) = operation
			vi -= 1
			a[vi] = x
			mark[vi] = -add
		elif t == 2:
			y = operation[0]
			add += y
			inc += 1
		elif t == 3:
			idx = operation[0]
			idx -= 1
			print(add + a[idx] + mark[idx])
for _ in range(ri() if 0 else 1):
	solve(_ + 1)


(n, m) = map(int, input().split())
l = [int(x) for x in input().split()]
curr = 0
for _ in range(m):
	temp = input().split()
	if temp[0] == '1':
		x = int(temp[1])
		y = int(temp[2])
		l[x - 1] = y
		l[x - 1] = l[x - 1] - curr
	elif temp[0] == '2':
		curr += int(temp[1])
	else:
		x = int(temp[1])
		print(l[x - 1] + curr)


(n, m) = map(int, input().split())
numbers = list(map(int, input().split()))
copy = [0] * n
results = []
accumulator = 0
for i in range(m):
	inputs = input().split()
	if inputs[0] == '3':
		results.append(numbers[int(inputs[1]) - 1] + accumulator + copy[int(inputs[1]) - 1])
	elif inputs[0] == '2':
		accumulator += int(inputs[1])
	else:
		copy[int(inputs[1]) - 1] = -accumulator
		numbers[int(inputs[1]) - 1] = int(inputs[2])
print(*results, sep='\n')


def go():
	(n, m) = (int(i) for i in input().split(' '))
	a = [int(i) for i in input().split(' ')]
	keep = 0
	o = ''
	for i in range(m):
		data = tuple((int(i) for i in input().split(' ')))
		if data[0] == 1:
			a[data[1] - 1] = data[2] - keep
		elif data[0] == 2:
			keep += data[1]
		elif data[0] == 3:
			o += '{}\n'.format(a[data[1] - 1] + keep)
	return o
print(go())


(n, m) = [int(x) for x in input().split()]
arr = [int(x) for x in input().split()]
query = []
for _ in range(m):
	query.append([int(x) for x in input().split()])
add = [0 for i in range(n)]
netadd = 0
for q in query:
	t = q[0]
	v = q[1]
	x = 0
	if len(q) == 3:
		x = q[2]
	if t == 3:
		print(arr[v - 1] + netadd - add[v - 1])
	elif t == 2:
		netadd += v
	else:
		arr[v - 1] = x
		add[v - 1] = netadd


(n, m) = [int(x) for x in input().split(' ')]
array = [int(x) for x in input().split(' ')]
add = 0
for i in range(m):
	op = [int(w) for w in input().split(' ')]
	op_type = op[0]
	if op_type == 3:
		print(array[op[1] - 1] + add)
	elif op_type == 2:
		add += op[1]
	else:
		v = op[1]
		x = op[2]
		array[v - 1] = x - add


(n, m) = map(int, input().split())
a = list(map(int, input().split()))
tot = 0
rs = []
for i in range(m):
	t = list(map(int, input().split()))
	if t[0] == 1:
		v = t[1]
		x = t[2]
		a[v - 1] = x - tot
	if t[0] == 2:
		y = t[1]
		tot += y
	if t[0] == 3:
		q = t[1]
		rs.append(str(a[q - 1] + tot))
print('\n'.join(rs))


(n, m) = map(int, input().split())
arr = list(map(int, input().split()))
increment = 0
for i in range(m):
	temp = list(map(int, input().split()))
	if temp[0] == 1:
		arr[temp[1] - 1] = temp[2] - increment
	elif temp[0] == 3:
		print(arr[temp[1] - 1] + increment)
	else:
		increment += temp[1]


from sys import stdin, stdout
m = int(input().split()[1])
a = [int(x) for x in stdin.readline().split()]
s = 0
for i in range(m):
	x = [int(x) for x in stdin.readline().split()]
	if x[0] == 1:
		a[x[1] - 1] = x[2] - s
	elif x[0] == 2:
		s += x[1]
	else:
		print(a[x[1] - 1] + s)


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
sum = 0
s = ''
for i in range(m):
	cur = list(map(int, input().split()))
	if cur[0] == 1:
		l[cur[1] - 1] = cur[2] - sum
	if cur[0] == 2:
		sum = sum + cur[1]
	if cur[0] == 3:
		s += str(l[cur[1] - 1] + sum) + '\n'
print(s)


import sys
(n, m) = sys.stdin.readline().split()
n = int(n)
m = int(m)
while True:
	num_arr = [int(i) for i in sys.stdin.readline().split(' ')]
	operation_arr = []
	last_sum = 0
	change_map = {}
	for i in range(0, m):
		operation = sys.stdin.readline().split(' ')
		id = int(operation[0])
		if id == 1:
			(idx, value) = (int(operation[1]), int(operation[2]))
		else:
			value = int(operation[1])
		if id == 1:
			operation_arr.append(last_sum)
			change_map[idx - 1] = i
			num_arr[idx - 1] = value
		elif id == 2:
			operation_arr.append(value + last_sum)
			last_sum += value
		elif id == 3:
			value -= 1
			operation_arr.append(last_sum)
			if value in change_map:
				print(num_arr[value] + last_sum - operation_arr[change_map[value]])
			else:
				print(num_arr[value] + last_sum)
	nm = sys.stdin.readline().split()
	if not nm:
		break
	else:
		(n, m) = nm
		n = int(n)
		m = int(m)


(n, m) = map(int, input().split())
l = list(map(int, input().split()))
l = [0] + l
l1 = []
for i in range(m):
	l1 += [list(map(int, input().split()))]
k = 0
for i in l1:
	if i[0] == 1:
		l[i[1]] = i[2]
		l[i[1]] -= k
	elif i[0] == 2:
		k += i[1]
	else:
		print(l[i[1]] + k)


import sys
(n, m) = [int(x) for x in sys.stdin.readline().split()]
a = [int(x) for x in sys.stdin.readline().split()]
increase = 0
for i in range(m):
	op = [int(x) for x in sys.stdin.readline().split()]
	t = op[0]
	if t == 1:
		v = op[1]
		x = op[2]
		a[v - 1] = x - increase
	elif t == 2:
		y = op[1]
		increase += y
	elif t == 3:
		q = op[1]
		print(a[q - 1] + increase)


import os, sys
from io import BytesIO, IOBase
from types import GeneratorType
from bisect import *
from collections import defaultdict, deque, Counter
import math, string
from heapq import *
from operator import add
from itertools import accumulate
BUFSIZE = 8192
sys.setrecursionlimit(10 ** 5)

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		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 = self.os.read(self._fd, max(self.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 = self.os.read(self._fd, max(self.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:
			self.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')
inf = float('inf')
en = lambda x: list(enumerate(x))
ceil_ = lambda a, b: (a + b - 1) // b
ii = lambda : int(input())
r = lambda : map(int, input().split())
rr = lambda : list(r())
(n, k) = r()
arr = rr()
ok = defaultdict(lambda : 0)
brr = [0]
for i in range(k):
	(a, *b) = rr()
	adder = 0
	if a == 1:
		(x, y) = b
		x -= 1
		arr[x] = y
		ok[x] = i
	elif a == 2:
		adder = b[0]
	else:
		x = b[0] - 1
		extra = brr[i] - brr[ok[x]]
		print(arr[x] + extra)
	brr += (brr[-1] + adder,)


import sys, math
from collections import deque, defaultdict
import operator as op
from functools import reduce
from itertools import permutations
import heapq
I = sys.stdin.readline
alpha = 'abcdefghijklmnopqrstuvwxyz'
mod = 10 ** 9 + 7

def ii():
	return int(I().strip())

def li():
	return list(map(int, I().strip().split()))

def mi():
	return map(int, I().strip().split())

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom

def ispali(s):
	i = 0
	j = len(s) - 1
	while i < j:
		if s[i] != s[j]:
			return False
		i += 1
		j -= 1
	return True

def isPrime(n):
	if n <= 1:
		return False
	elif n <= 2:
		return True
	else:
		for i in range(2, int(n ** 0.5) + 1):
			if n % i == 0:
				return False
		return True

def main():
	(n, m) = mi()
	arr = li()
	ans = ''
	cnt = 0
	for i in range(m):
		op = li()
		if op[0] == 1:
			arr[op[1] - 1] = op[2] - cnt
		elif op[0] == 2:
			cnt += op[1]
		else:
			ans += str(arr[op[1] - 1] + cnt) + '\n'
	print(ans)
main()


import os
import sys
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))
input = lambda : sys.stdin.readline().rstrip('\r\n')
readint = lambda : int(sys.stdin.readline().rstrip('\r\n'))
readints = lambda : map(int, sys.stdin.readline().rstrip('\r\n').split())
readstr = lambda : sys.stdin.readline().rstrip('\r\n')
readstrs = lambda : map(str, sys.stdin.readline().rstrip('\r\n').split())
readarri = lambda : [int(_) for _ in sys.stdin.readline().rstrip('\r\n').split()]
readarrs = lambda : [str(_) for _ in sys.stdin.readline().rstrip('\r\n').split()]

def getSum(BITree: list, index: int) -> int:
	summ = 0
	index = index + 1
	while index > 0:
		summ += BITree[index]
		index -= index & -index
	return summ

def updateBit(BITTree: list, n: int, index: int, val: int) -> None:
	index = index + 1
	while index <= n:
		BITTree[index] += val
		index += index & -index

def summation(x: int, BITTree1: list, BITTree2: list) -> int:
	return getSum(BITTree1, x) * x - getSum(BITTree2, x)

def updateRange(BITTree1: list, BITTree2: list, n: int, val: int, l: int, r: int) -> None:
	updateBit(BITTree1, n, l, val)
	updateBit(BITTree1, n, r + 1, -val)
	updateBit(BITTree2, n, l, val * (l - 1))
	updateBit(BITTree2, n, r + 1, -val * r)

def rangeSum(l: int, r: int, BITTree1: list, BITTree2: list) -> int:
	return summation(r, BITTree1, BITTree2) - summation(l - 1, BITTree1, BITTree2)

def solve():
	(n, q) = readints()
	arr = readarri()
	(f1, f2) = ([0] * (n + 1), [0] * (n + 1))
	for i in range(n):
		updateRange(f1, f2, n, arr[i], i, i)
	for _ in range(q):
		a = readarri()
		if a[0] == 1:
			curr = rangeSum(a[1] - 1, a[1] - 1, f1, f2)
			updateRange(f1, f2, n, -curr, a[1] - 1, a[1] - 1)
			updateRange(f1, f2, n, a[2], a[1] - 1, a[1] - 1)
		elif a[0] == 2:
			updateRange(f1, f2, n, a[1], 0, n - 1)
		else:
			print(rangeSum(a[1] - 1, a[1] - 1, f1, f2))

def main():
	t = 1
	for _ in range(t):
		solve()
main()


from sys import stdin
(n, c) = map(int, input().split())
l = list(map(int, stdin.readline().split()))
x = 0
for _ in range(c):
	m = list(map(int, stdin.readline().split()))
	if m[0] == 3:
		print(l[m[1] - 1] + x)
	elif m[0] == 1:
		l[m[1] - 1] = m[2] - x
	else:
		x += m[1]


(n, m) = map(int, input().split(' '))
arr = list(map(int, input().split(' ')))
buff = 0
ans = []
for i in range(m):
	inp = list(map(int, input().split(' ')))
	if inp[0] == 1:
		arr[inp[1] - 1] = inp[2] - buff
	elif inp[0] == 2:
		buff += inp[1]
	elif inp[0] == 3:
		ans.append(arr[inp[1] - 1] + buff)
print(*ans, sep='\n')


I = lambda : map(int, input().split())
(_, m) = I()
A = list(I())
s = ''
d = 0
for _ in range(m):
	(t, *X) = I()
	if t == 1:
		A[X[0] - 1] = X[1] - d
	elif t == 2:
		d += X[0]
	else:
		s += str(A[X[0] - 1] + d) + '\n'
print(s)