#include <bits/stdc++.h>
using namespace std;

#define gc getchar
#define pc putchar

#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen ("output.txt","w",stdout)

#define eps             1e-8
#define inf             0x3f3f3f3f
#define INF             2e18
#define LL              long long
#define ULL             unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define rall(a)         a.rbegin(),a.rend()
#define SQR(a)          ((a)*(a))
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define Iterator(a)     __typeof__(a.begin())
#define rIterator(a)    __typeof__(a.rbegin())
#define FOR(a,it)       for(Iterator(a) it = a.begin();it != a.end(); it++)
#define rFOR(a,it)      for(rIterator(a) it = a.rbegin();it != a.rend(); it++)
#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define CasePrint       pc('C'); pc('a'); pc('s'); pc('e'); pc(' '); write(qq++,false); pc(':'); pc(' ')
#define vi              vector <int>
#define vL              vector <LL>
#define For(I,A,B)      for(int I = (A); I < (B); ++I)
#define rFor(I,A,B)     for(int I = (A); I >= (B); --I)
#define Rep(I,N)        For(I,0,N)

using namespace std;

const int MOD = 1e9 + 7;
int fx[] = { -1, +0, +1, +0, +1, +1, -1, -1, +0 };
int fy[] = { +0, -1, +0, +1, +1, -1, +1, -1, +0 };
template<typename T> inline T GCD(T a, T b) {
	a = abs(a);
	b = abs(b);
	if (a < b)
		swap(a, b);
	while (b) {
		a = a % b;
		swap(a, b);
	}
	return a;
}
template<typename T> inline T EGCD(T a, T b, T &x, T &y) {
	if (a == 0) {
		x = 0;
		y = 1;
		return b;
	}
	T x1, y1;
	T d = EGCD(b % a, a, x1, y1);
	x = y1 - (b / a) * x1;
	y = x1;
	return d;
}
template<typename T> inline T LCM(T x, T y) {
	T tp = GCD(x, y);
	if ((x / tp) * 1. * y > 9e18)
		return 9e18;
	return (x / tp) * y;
}
template<typename T> inline T BigMod(T A, T B, T M = MOD) {
	T ret = 1;
	while (B) {
		if (B & 1)
			ret = (ret * A) % M;
		A = (A * A) % M;
		B = B >> 1;
	}
	return ret;
}
template<typename T> inline T InvMod(T A, T M = MOD) {
	return BigMod(A, M - 2, M);
}
/*---------------------------fast I/O------------------------------------*/
#define scani2(a,b) scani(a) , scani(b)
#define scani3(a,b,c) scani(a), scani(b), scani(c)
#define scani4(a,b,c,d) scani(a), scani(b), scani(c), scani(d)
#define scani5(a,b,c,d,e) scani(a), scani(b), scani(c), scani(d) , scani(e)
template<typename T> T scani(T &n) {
	n = 0;
	bool negative = false;
	char c = gc();
	while (c < '0' || c > '9') {
		if (c == '-')
			negative = true;
		c = gc();
	}
	while (c >= '0' && c <= '9') {
		n = n * 10 + c - 48;
		c = gc();
	}
	if (negative)
		n = ~(n - 1);
	return n;
}
template<typename T> void write(T n, int type = true) {
	if (n < 0) {
		pc('-');
		n = -n;
	}
	if (!n) {
		pc('0');
		if (type == 32)
			pc(' ');
		else if (type)
			pc('\n');
		return;
	}
	char buff[22];
	int len = 0;
	while (n)
		buff[len++] = n % 10 + 48, n /= 10;
	for (int i = len - 1; i >= 0; i--)
		pc(buff[i]);
	if (type == 32)
		pc(' ');
	else if (type)
		pc('\n');
}
int scans(char *a) {
	int i = 0;
	char c = 0;
	while (c < 33)
		c = gc();
	while (c > 33) {
		a[i++] = c;
		c = gc();
	}
	a[i] = 0;
	return i;
}
/*********************************************** End of template *********************************************/
const int N = 3e6;
string str[N];
int cnt[N];

int main() {
	int n, in, pos, sz, l = -1;
	scani(n);
	memset(cnt, 0, N);

	string s;
	Rep(q,n)
	{
		cin >> s;
		sz = s.size();
		scani(in);
		Rep(i,in)
		{
			scani(pos);
			l = max(l, pos);
			if (cnt[pos - 1] < sz) {
				cnt[pos - 1] = sz;
				str[pos - 1] = s;
			}
		}
	}

	Rep(i,l)
	{
		if (!cnt[i])
			pc('a');
		else {
			int m = 0;
			for (int j = 0; j < cnt[i]; j++) {
				pc(str[i][j]);
				if (cnt[j + i + 1] > cnt[i] - j - 1) {
					m=j+1;
					break;
				}
			}
			i+=m?m-1:cnt[i]-1;
		}
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define gc getchar
#define pc putchar

#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen ("output.txt","w",stdout)

#define eps             1e-8
#define inf             0x3f3f3f3f
#define INF             2e18
#define LL              long long
#define ULL             unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define rall(a)         a.rbegin(),a.rend()
#define SQR(a)          ((a)*(a))
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define Iterator(a)     __typeof__(a.begin())
#define rIterator(a)    __typeof__(a.rbegin())
#define FOR(a,it)       for(Iterator(a) it = a.begin();it != a.end(); it++)
#define rFOR(a,it)      for(rIterator(a) it = a.rbegin();it != a.rend(); it++)
#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define CasePrint       pc('C'); pc('a'); pc('s'); pc('e'); pc(' '); write(qq++,false); pc(':'); pc(' ')
#define vi              vector <int>
#define vL              vector <LL>
#define For(I,A,B)      for(int I = (A); I < (B); ++I)
#define rFor(I,A,B)     for(int I = (A); I >= (B); --I)
#define Rep(I,N)        For(I,0,N)

using namespace std;

const int MOD = 1e9 + 7;
int fx[] = { -1, +0, +1, +0, +1, +1, -1, -1, +0 };
int fy[] = { +0, -1, +0, +1, +1, -1, +1, -1, +0 };
template<typename T> inline T GCD(T a, T b) {
	a = abs(a);
	b = abs(b);
	if (a < b)
		swap(a, b);
	while (b) {
		a = a % b;
		swap(a, b);
	}
	return a;
}
template<typename T> inline T EGCD(T a, T b, T &x, T &y) {
	if (a == 0) {
		x = 0;
		y = 1;
		return b;
	}
	T x1, y1;
	T d = EGCD(b % a, a, x1, y1);
	x = y1 - (b / a) * x1;
	y = x1;
	return d;
}
template<typename T> inline T LCM(T x, T y) {
	T tp = GCD(x, y);
	if ((x / tp) * 1. * y > 9e18)
		return 9e18;
	return (x / tp) * y;
}
template<typename T> inline T BigMod(T A, T B, T M = MOD) {
	T ret = 1;
	while (B) {
		if (B & 1)
			ret = (ret * A) % M;
		A = (A * A) % M;
		B = B >> 1;
	}
	return ret;
}
template<typename T> inline T InvMod(T A, T M = MOD) {
	return BigMod(A, M - 2, M);
}
/*---------------------------fast I/O------------------------------------*/
#define scani2(a,b) scani(a) , scani(b)
#define scani3(a,b,c) scani(a), scani(b), scani(c)
#define scani4(a,b,c,d) scani(a), scani(b), scani(c), scani(d)
#define scani5(a,b,c,d,e) scani(a), scani(b), scani(c), scani(d) , scani(e)
template<typename T> T scani(T &n) {
	n = 0;
	bool negative = false;
	char c = gc();
	while (c < '0' || c > '9') {
		if (c == '-')
			negative = true;
		c = gc();
	}
	while (c >= '0' && c <= '9') {
		n = n * 10 + c - 48;
		c = gc();
	}
	if (negative)
		n = ~(n - 1);
	return n;
}
template<typename T> void write(T n, int type = true) {
	if (n < 0) {
		pc('-');
		n = -n;
	}
	if (!n) {
		pc('0');
		if (type == 32)
			pc(' ');
		else if (type)
			pc('\n');
		return;
	}
	char buff[22];
	int len = 0;
	while (n)
		buff[len++] = n % 10 + 48, n /= 10;
	for (int i = len - 1; i >= 0; i--)
		pc(buff[i]);
	if (type == 32)
		pc(' ');
	else if (type)
		pc('\n');
}
int scans(char *a) {
	int i = 0;
	char c = 0;
	while (c < 33)
		c = gc();
	while (c > 33) {
		a[i++] = c;
		c = gc();
	}
	a[i] = 0;
	return i;
}
/*********************************************** End of template *********************************************/

const int N = 3e6;
string str[N];
int cnt[N];

int main() {
	int n, in, pos, sz, l = -1;
	scani(n);
	memset(cnt, 0, N);

	string s;
	Rep(q,n)
	{
		cin >> s;
		sz = s.size();
		scani(in);
		Rep(i,in)
		{
			scani(pos);
			l = max(l, pos);
			if (cnt[pos - 1] < sz) {
				cnt[pos - 1] = sz;
				str[pos - 1] = s;
			}
		}
	}

	Rep(i,l) if (!cnt[i]) pc('a');
		else {
			for(int j=i; i < cnt[j]+j && cnt[i]<=cnt[j]-i+j; i++)
				pc(str[j][i-j]);
			i--;
		}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define gc getchar
#define pc putchar

#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen ("output.txt","w",stdout)

#define eps             1e-8
#define inf             0x3f3f3f3f
#define INF             2e18
#define LL              long long
#define ULL             unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define rall(a)         a.rbegin(),a.rend()
#define SQR(a)          ((a)*(a))
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define Iterator(a)     __typeof__(a.begin())
#define rIterator(a)    __typeof__(a.rbegin())
#define FOR(a,it)       for(Iterator(a) it = a.begin();it != a.end(); it++)
#define rFOR(a,it)      for(rIterator(a) it = a.rbegin();it != a.rend(); it++)
#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define CasePrint       pc('C'); pc('a'); pc('s'); pc('e'); pc(' '); write(qq++,false); pc(':'); pc(' ')
#define vi              vector <int>
#define vL              vector <LL>
#define For(I,A,B)      for(int I = (A); I < (B); ++I)
#define rFor(I,A,B)     for(int I = (A); I >= (B); --I)
#define Rep(I,N)        For(I,0,N)

using namespace std;

const int MOD = 1e9 + 7;
int fx[] = { -1, +0, +1, +0, +1, +1, -1, -1, +0 };
int fy[] = { +0, -1, +0, +1, +1, -1, +1, -1, +0 };
template<typename T> inline T GCD(T a, T b) {
	a = abs(a);
	b = abs(b);
	if (a < b)
		swap(a, b);
	while (b) {
		a = a % b;
		swap(a, b);
	}
	return a;
}
template<typename T> inline T EGCD(T a, T b, T &x, T &y) {
	if (a == 0) {
		x = 0;
		y = 1;
		return b;
	}
	T x1, y1;
	T d = EGCD(b % a, a, x1, y1);
	x = y1 - (b / a) * x1;
	y = x1;
	return d;
}
template<typename T> inline T LCM(T x, T y) {
	T tp = GCD(x, y);
	if ((x / tp) * 1. * y > 9e18)
		return 9e18;
	return (x / tp) * y;
}
template<typename T> inline T BigMod(T A, T B, T M = MOD) {
	T ret = 1;
	while (B) {
		if (B & 1)
			ret = (ret * A) % M;
		A = (A * A) % M;
		B = B >> 1;
	}
	return ret;
}
template<typename T> inline T InvMod(T A, T M = MOD) {
	return BigMod(A, M - 2, M);
}
/*---------------------------fast I/O------------------------------------*/
#define scani2(a,b) scani(a) , scani(b)
#define scani3(a,b,c) scani(a), scani(b), scani(c)
#define scani4(a,b,c,d) scani(a), scani(b), scani(c), scani(d)
#define scani5(a,b,c,d,e) scani(a), scani(b), scani(c), scani(d) , scani(e)
template<typename T> T scani(T &n) {
	n = 0;
	bool negative = false;
	char c = gc();
	while (c < '0' || c > '9') {
		if (c == '-')
			negative = true;
		c = gc();
	}
	while (c >= '0' && c <= '9') {
		n = n * 10 + c - 48;
		c = gc();
	}
	if (negative)
		n = ~(n - 1);
	return n;
}
template<typename T> void write(T n, int type = true) {
	if (n < 0) {
		pc('-');
		n = -n;
	}
	if (!n) {
		pc('0');
		if (type == 32)
			pc(' ');
		else if (type)
			pc('\n');
		return;
	}
	char buff[22];
	int len = 0;
	while (n)
		buff[len++] = n % 10 + 48, n /= 10;
	for (int i = len - 1; i >= 0; i--)
		pc(buff[i]);
	if (type == 32)
		pc(' ');
	else if (type)
		pc('\n');
}
int scans(char *a) {
	int i = 0;
	char c = 0;
	while (c < 33)
		c = gc();
	while (c > 33) {
		a[i++] = c;
		c = gc();
	}
	a[i] = 0;
	return i;
}
/*********************************************** End of template *********************************************/
const int N = 3e6+7;
char s[N], ans[N];
int m[N];

int main() {
	int n,in,ind=0,szc,last=-1; scani(n);
	memset(m,0,sizeof m);

	Rep(i,n){ szc=scans(s); scani(in);
		Rep(j,in){ scani(ind); ind--;
			for(int i=0,sz=szc; m[ind]<=sz; sz--,ind++,i++){
				ans[ind]=s[i];
				m[ind]=sz;
			}
		}
		last=max(last,ind-1);
	}

	Rep(i,last)
		pc(m[i]?ans[i]:'a');

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define gc getchar
#define pc putchar

#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen ("output.txt","w",stdout)

#define eps             1e-8
#define inf             0x3f3f3f3f
#define INF             2e18
#define LL              long long
#define ULL             unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define rall(a)         a.rbegin(),a.rend()
#define SQR(a)          ((a)*(a))
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define Iterator(a)     __typeof__(a.begin())
#define rIterator(a)    __typeof__(a.rbegin())
#define FOR(a,it)       for(Iterator(a) it = a.begin();it != a.end(); it++)
#define rFOR(a,it)      for(rIterator(a) it = a.rbegin();it != a.rend(); it++)
#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define CasePrint       pc('C'); pc('a'); pc('s'); pc('e'); pc(' '); write(qq++,false); pc(':'); pc(' ')
#define vi              vector <int>
#define vL              vector <LL>
#define For(I,A,B)      for(int I = (A); I < (B); ++I)
#define rFor(I,A,B)     for(int I = (A); I >= (B); --I)
#define Rep(I,N)        For(I,0,N)

using namespace std;

const int MOD = 1e9 + 7;
int fx[] = { -1, +0, +1, +0, +1, +1, -1, -1, +0 };
int fy[] = { +0, -1, +0, +1, +1, -1, +1, -1, +0 };
template<typename T> inline T GCD(T a, T b) {
	a = abs(a);
	b = abs(b);
	if (a < b)
		swap(a, b);
	while (b) {
		a = a % b;
		swap(a, b);
	}
	return a;
}
template<typename T> inline T EGCD(T a, T b, T &x, T &y) {
	if (a == 0) {
		x = 0;
		y = 1;
		return b;
	}
	T x1, y1;
	T d = EGCD(b % a, a, x1, y1);
	x = y1 - (b / a) * x1;
	y = x1;
	return d;
}
template<typename T> inline T LCM(T x, T y) {
	T tp = GCD(x, y);
	if ((x / tp) * 1. * y > 9e18)
		return 9e18;
	return (x / tp) * y;
}
template<typename T> inline T BigMod(T A, T B, T M = MOD) {
	T ret = 1;
	while (B) {
		if (B & 1)
			ret = (ret * A) % M;
		A = (A * A) % M;
		B = B >> 1;
	}
	return ret;
}
template<typename T> inline T InvMod(T A, T M = MOD) {
	return BigMod(A, M - 2, M);
}
/*---------------------------fast I/O------------------------------------*/
#define scani2(a,b) scani(a) , scani(b)
#define scani3(a,b,c) scani(a), scani(b), scani(c)
#define scani4(a,b,c,d) scani(a), scani(b), scani(c), scani(d)
#define scani5(a,b,c,d,e) scani(a), scani(b), scani(c), scani(d) , scani(e)
template<typename T> T scani(T &n) {
	n = 0;
	bool negative = false;
	char c = gc();
	while (c < '0' || c > '9') {
		if (c == '-')
			negative = true;
		c = gc();
	}
	while (c >= '0' && c <= '9') {
		n = n * 10 + c - 48;
		c = gc();
	}
	if (negative)
		n = ~(n - 1);
	return n;
}
template<typename T> void write(T n, int type = true) {
	if (n < 0) {
		pc('-');
		n = -n;
	}
	if (!n) {
		pc('0');
		if (type == 32)
			pc(' ');
		else if (type)
			pc('\n');
		return;
	}
	char buff[22];
	int len = 0;
	while (n)
		buff[len++] = n % 10 + 48, n /= 10;
	for (int i = len - 1; i >= 0; i--)
		pc(buff[i]);
	if (type == 32)
		pc(' ');
	else if (type)
		pc('\n');
}
int scans(char *a) {
	int i = 0;
	char c = 0;
	while (c < 33)
		c = gc();
	while (c > 33) {
		a[i++] = c;
		c = gc();
	}
	a[i] = 0;
	return i;
}
/*********************************************** End of template *********************************************/
const int N = 1e6 + 7;
string str[N];
int cnt[N];

int main() {
	int n, in, pos, sz, l = -1;
	scani(n);
	memset(cnt, 0, N);

	string s;
	Rep(q,n)
	{
		cin >> s;
		sz = s.size();
		scani(in);
		Rep(i,in)
		{
			scani(pos);
			l = max(l, pos);
			if (cnt[pos - 1] < sz) {
				cnt[pos - 1] = sz;
				str[pos - 1] = s;
			}
		}
	}

	Rep(i,l)
	{
		if (!cnt[i])
			pc('a');
		else {
			int m = 0;
			for (int j = 0; j < cnt[i]; j++) {
				pc(str[i][j]);
				if (cnt[j + i + 1] > cnt[i] - j - 1) {
					m=j+1;
					break;
				}
			}
			i+=m?m-1:cnt[i]-1;
		}
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

#define gc getchar
#define pc putchar

#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen ("output.txt","w",stdout)

#define eps             1e-8
#define inf             0x3f3f3f3f
#define INF             2e18
#define LL              long long
#define ULL             unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define rall(a)         a.rbegin(),a.rend()
#define SQR(a)          ((a)*(a))
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define Iterator(a)     __typeof__(a.begin())
#define rIterator(a)    __typeof__(a.rbegin())
#define FOR(a,it)       for(Iterator(a) it = a.begin();it != a.end(); it++)
#define rFOR(a,it)      for(rIterator(a) it = a.rbegin();it != a.rend(); it++)
#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define CasePrint       pc('C'); pc('a'); pc('s'); pc('e'); pc(' '); write(qq++,false); pc(':'); pc(' ')
#define vi              vector <int>
#define vL              vector <LL>
#define For(I,A,B)      for(int I = (A); I < (B); ++I)
#define rFor(I,A,B)     for(int I = (A); I >= (B); --I)
#define Rep(I,N)        For(I,0,N)

using namespace std;

const int MOD = 1e9 + 7;
int fx[] = { -1, +0, +1, +0, +1, +1, -1, -1, +0 };
int fy[] = { +0, -1, +0, +1, +1, -1, +1, -1, +0 };
template<typename T> inline T GCD(T a, T b) {
	a = abs(a);
	b = abs(b);
	if (a < b)
		swap(a, b);
	while (b) {
		a = a % b;
		swap(a, b);
	}
	return a;
}
template<typename T> inline T EGCD(T a, T b, T &x, T &y) {
	if (a == 0) {
		x = 0;
		y = 1;
		return b;
	}
	T x1, y1;
	T d = EGCD(b % a, a, x1, y1);
	x = y1 - (b / a) * x1;
	y = x1;
	return d;
}
template<typename T> inline T LCM(T x, T y) {
	T tp = GCD(x, y);
	if ((x / tp) * 1. * y > 9e18)
		return 9e18;
	return (x / tp) * y;
}
template<typename T> inline T BigMod(T A, T B, T M = MOD) {
	T ret = 1;
	while (B) {
		if (B & 1)
			ret = (ret * A) % M;
		A = (A * A) % M;
		B = B >> 1;
	}
	return ret;
}
template<typename T> inline T InvMod(T A, T M = MOD) {
	return BigMod(A, M - 2, M);
}
/*---------------------------fast I/O------------------------------------*/
#define scani2(a,b) scani(a) , scani(b)
#define scani3(a,b,c) scani(a), scani(b), scani(c)
#define scani4(a,b,c,d) scani(a), scani(b), scani(c), scani(d)
#define scani5(a,b,c,d,e) scani(a), scani(b), scani(c), scani(d) , scani(e)
template<typename T> T scani(T &n) {
	n = 0;
	bool negative = false;
	char c = gc();
	while (c < '0' || c > '9') {
		if (c == '-')
			negative = true;
		c = gc();
	}
	while (c >= '0' && c <= '9') {
		n = n * 10 + c - 48;
		c = gc();
	}
	if (negative)
		n = ~(n - 1);
	return n;
}
template<typename T> void write(T n, int type = true) {
	if (n < 0) {
		pc('-');
		n = -n;
	}
	if (!n) {
		pc('0');
		if (type == 32)
			pc(' ');
		else if (type)
			pc('\n');
		return;
	}
	char buff[22];
	int len = 0;
	while (n)
		buff[len++] = n % 10 + 48, n /= 10;
	for (int i = len - 1; i >= 0; i--)
		pc(buff[i]);
	if (type == 32)
		pc(' ');
	else if (type)
		pc('\n');
}
int scans(char *a) {
	int i = 0;
	char c = 0;
	while (c < 33)
		c = gc();
	while (c > 33) {
		a[i++] = c;
		c = gc();
	}
	a[i] = 0;
	return i;
}
/*********************************************** End of template *********************************************/
const int N = 3e6+7;
char s[N], ans[N];
int m[N];

int main() {
	int n,in,ind=0,szc,last=-1; scani(n);
	memset(m,0,sizeof m);

	Rep(i,n){ szc=scans(s); scani(in);
		Rep(j,in){ scani(ind); ind--;
			m[ind]=szc;
			for(int i=0,sz=szc; m[ind]<=sz; sz--,ind++,i++){
				ans[ind]=s[i];
			}
		}
		last=max(last,ind-1);
	}

	Rep(i,last)
		pc(ans[i]?ans[i]:'a');

	return 0;
}


/*ID: jonatha124
 PROG: gift1
 LANG: C++11
 */

#include <bits/stdc++.h>
using namespace std;

#define gc getchar
#define pc putchar

#define fRead(x)           freopen(x,"r",stdin)
#define fWrite(x)          freopen(x,"w",stdout)
#define endl            '\n'

#define eps             1e-8
#define inf             0x3f3f3f3f
#define INF             2e18
#define LL              long long
#define ULL             unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define rall(a)         a.rbegin(),a.rend()
#define SQR(a)          ((a)*(a))
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define Iterator(a)     __typeof__(a.begin())
#define rIterator(a)    __typeof__(a.rbegin())
#define FOR(a,it)       for(Iterator(a) it = a.begin();it != a.end(); it++)
#define rFOR(a,it)      for(rIterator(a) it = a.rbegin();it != a.rend(); it++)
#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define CasePrint       pc('C'); pc('a'); pc('s'); pc('e'); pc(' '); write(qq++,false); pc(':'); pc(' ')
#define vi              vector <int>
#define vL              vector <LL>
#define For(I,A,B)      for(int I = (A); I < (B); ++I)
#define rFor(I,A,B)     for(int I = (A); I >= (B); --I)
#define Rep(I,N)        For(I,0,N)

using namespace std;

const int MOD = 1e9 + 7;
int fx[] = { -1, +0, +1, +0, +1, +1, -1, -1, +0 };
int fy[] = { +0, -1, +0, +1, +1, -1, +1, -1, +0 };
template<typename T> inline T GCD(T a, T b) {
	a = abs(a);
	b = abs(b);
	if (a < b)
		swap(a, b);
	while (b) {
		a = a % b;
		swap(a, b);
	}
	return a;
}
template<typename T> inline T EGCD(T a, T b, T &x, T &y) {
	if (a == 0) {
		x = 0;
		y = 1;
		return b;
	}
	T x1, y1;
	T d = EGCD(b % a, a, x1, y1);
	x = y1 - (b / a) * x1;
	y = x1;
	return d;
}
template<typename T> inline T LCM(T x, T y) {
	T tp = GCD(x, y);
	if ((x / tp) * 1. * y > 9e18)
		return 9e18;
	return (x / tp) * y;
}
template<typename T> inline T BigMod(T A, T B, T M = MOD) {
	T ret = 1;
	while (B) {
		if (B & 1)
			ret = (ret * A) % M;
		A = (A * A) % M;
		B = B >> 1;
	}
	return ret;
}
template<typename T> inline T InvMod(T A, T M = MOD) {
	return BigMod(A, M - 2, M);
}
template<typename T> inline T MADD(T A, T B, T M = MOD) {
	return ((A) + (B)) % M;
}
/*---------------------------fast I/O------------------------------------*/
#define scani2(a,b) scani(a) , scani(b)
#define scani3(a,b,c) scani(a), scani(b), scani(c)
#define scani4(a,b,c,d) scani(a), scani(b), scani(c), scani(d)
#define scani5(a,b,c,d,e) scani(a), scani(b), scani(c), scani(d) , scani(e)
template<typename T> T scani(T &n) {
	n = 0;
	bool negative = false;
	char c = gc();
	while (c < '0' || c > '9') {
		if (c == '-')
			negative = true;
		c = gc();
	}
	while (c >= '0' && c <= '9') {
		n = n * 10 + c - 48;
		c = gc();
	}
	if (negative)
		n = ~(n - 1);
	return n;
}
template<typename T> void write(T n, int type = true) {
	if (n < 0) {
		pc('-');
		n = -n;
	}
	if (!n) {
		pc('0');
		if (type == 32)
			pc(' ');
		else if (type)
			pc('\n');
		return;
	}
	char buff[22];
	int len = 0;
	while (n)
		buff[len++] = n % 10 + 48, n /= 10;
	for (int i = len - 1; i >= 0; i--)
		pc(buff[i]);
	if (type == 32)
		pc(' ');
	else if (type)
		pc('\n');
}
int scans(char *a) {
	int i = 0;
	char c = 0;
	while (c < 33)
		c = gc();
	while (c > 33) {
		a[i++] = c;
		c = gc();
	}
	a[i] = 0;
	return i;
}
/*********************************************** End of template *********************************************/
const int N = 1e6+7;
char out[3*N];
int jt[3*N];

int find(int x){
	return jt[x]?jt[x]=find(jt[x]):x;
}

int main(void) {
	cin.tie(0);
	memset(out,'a',sizeof out);
	int n; scani(n);
	string s; LL k,a,ma=-1;
	Rep(i,n) {
		cin>>s>>k;
		Rep(j,k) {
			scani(a);
			for(int z=a;z<a+(int)s.size();z=find(z+1) ){
				out[z]=s[z-a];
				jt[z]=find(a+s.size());
			}
		}
		ma=max(ma,a+(int)s.size()-1);
	}
	Rep(i,ma)
		pc(out[i+1]);
	pc(endl);
}


/*ID: jonatha124
 PROG: gift1
 LANG: C++11
 */

#include <bits/stdc++.h>
using namespace std;

#define gc getchar
#define pc putchar

#define fRead(x)           freopen(x,"r",stdin)
#define fWrite(x)          freopen(x,"w",stdout)
#define endl            '\n'

#define eps             1e-8
#define inf             0x3f3f3f3f
#define INF             2e18
#define LL              long long
#define ULL             unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define rall(a)         a.rbegin(),a.rend()
#define SQR(a)          ((a)*(a))
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define Iterator(a)     __typeof__(a.begin())
#define rIterator(a)    __typeof__(a.rbegin())
#define FOR(a,it)       for(Iterator(a) it = a.begin();it != a.end(); it++)
#define rFOR(a,it)      for(rIterator(a) it = a.rbegin();it != a.rend(); it++)
#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define CasePrint       pc('C'); pc('a'); pc('s'); pc('e'); pc(' '); write(qq++,false); pc(':'); pc(' ')
#define vi              vector <int>
#define vL              vector <LL>
#define For(I,A,B)      for(int I = (A); I < (B); ++I)
#define rFor(I,A,B)     for(int I = (A); I >= (B); --I)
#define Rep(I,N)        For(I,0,N)

using namespace std;

const int MOD = 1e9 + 7;
int fx[] = { -1, +0, +1, +0, +1, +1, -1, -1, +0 };
int fy[] = { +0, -1, +0, +1, +1, -1, +1, -1, +0 };
template<typename T> inline T GCD(T a, T b) {
	a = abs(a);
	b = abs(b);
	if (a < b)
		swap(a, b);
	while (b) {
		a = a % b;
		swap(a, b);
	}
	return a;
}
template<typename T> inline T EGCD(T a, T b, T &x, T &y) {
	if (a == 0) {
		x = 0;
		y = 1;
		return b;
	}
	T x1, y1;
	T d = EGCD(b % a, a, x1, y1);
	x = y1 - (b / a) * x1;
	y = x1;
	return d;
}
template<typename T> inline T LCM(T x, T y) {
	T tp = GCD(x, y);
	if ((x / tp) * 1. * y > 9e18)
		return 9e18;
	return (x / tp) * y;
}
template<typename T> inline T BigMod(T A, T B, T M = MOD) {
	T ret = 1;
	while (B) {
		if (B & 1)
			ret = (ret * A) % M;
		A = (A * A) % M;
		B = B >> 1;
	}
	return ret;
}
template<typename T> inline T InvMod(T A, T M = MOD) {
	return BigMod(A, M - 2, M);
}
template<typename T> inline T MADD(T A, T B, T M = MOD) {
	return ((A) + (B)) % M;
}
/*---------------------------fast I/O------------------------------------*/
#define scani2(a,b) scani(a) , scani(b)
#define scani3(a,b,c) scani(a), scani(b), scani(c)
#define scani4(a,b,c,d) scani(a), scani(b), scani(c), scani(d)
#define scani5(a,b,c,d,e) scani(a), scani(b), scani(c), scani(d) , scani(e)
template<typename T> T scani(T &n) {
	n = 0;
	bool negative = false;
	char c = gc();
	while (c < '0' || c > '9') {
		if (c == '-')
			negative = true;
		c = gc();
	}
	while (c >= '0' && c <= '9') {
		n = n * 10 + c - 48;
		c = gc();
	}
	if (negative)
		n = ~(n - 1);
	return n;
}
template<typename T> void write(T n, int type = true) {
	if (n < 0) {
		pc('-');
		n = -n;
	}
	if (!n) {
		pc('0');
		if (type == 32)
			pc(' ');
		else if (type)
			pc('\n');
		return;
	}
	char buff[22];
	int len = 0;
	while (n)
		buff[len++] = n % 10 + 48, n /= 10;
	for (int i = len - 1; i >= 0; i--)
		pc(buff[i]);
	if (type == 32)
		pc(' ');
	else if (type)
		pc('\n');
}
int scans(char *a) {
	int i = 0;
	char c = 0;
	while (c < 33)
		c = gc();
	while (c > 33) {
		a[i++] = c;
		c = gc();
	}
	a[i] = 0;
	return i;
}
/*********************************************** End of template *********************************************/

const int N =1e6+7;
char out[4*N];
int jt[4*N];

int main() {
	string s;
	int n, idx=0,edx=-1,in,ind, sz, last=-1;
	scani(n);
	memset(out,'a',sizeof out);
	Rep(i,4*N) jt[i]=i+1;

	Rep(i,n)
	{
		cin >> s;
		sz = s.size();

		scani(in);
		Rep(j,in)
		{
			scani(ind);
			idx=--ind;
			edx=idx+sz;
			for(;idx<edx;idx=jt[idx]) {
				out[idx]=s[idx-ind];
				if(idx)jt[idx-1]=edx;
			}
		}
		last=max(last,edx);
	}

	Rep(i,last)
		pc(out[i]);
	pc(endl);

	return 0;
}


/*ID: jonatha124
 PROG: gift1
 LANG: C++11
 */

#include <bits/stdc++.h>
using namespace std;

#define gc getchar
#define pc putchar

#define fRead(x)           freopen(x,"r",stdin)
#define fWrite(x)          freopen(x,"w",stdout)
#define endl            '\n'

#define eps             1e-8
#define inf             0x3f3f3f3f
#define INF             2e18
#define LL              long long
#define ULL             unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define rall(a)         a.rbegin(),a.rend()
#define SQR(a)          ((a)*(a))
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define Iterator(a)     __typeof__(a.begin())
#define rIterator(a)    __typeof__(a.rbegin())
#define FOR(a,it)       for(Iterator(a) it = a.begin();it != a.end(); it++)
#define rFOR(a,it)      for(rIterator(a) it = a.rbegin();it != a.rend(); it++)
#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define CasePrint       pc('C'); pc('a'); pc('s'); pc('e'); pc(' '); write(qq++,false); pc(':'); pc(' ')
#define vi              vector <int>
#define vL              vector <LL>
#define For(I,A,B)      for(int I = (A); I < (B); ++I)
#define rFor(I,A,B)     for(int I = (A); I >= (B); --I)
#define Rep(I,N)        For(I,0,N)

using namespace std;

const int MOD = 1e9 + 7;
int fx[] = { -1, +0, +1, +0, +1, +1, -1, -1, +0 };
int fy[] = { +0, -1, +0, +1, +1, -1, +1, -1, +0 };
template<typename T> inline T GCD(T a, T b) {
	a = abs(a);
	b = abs(b);
	if (a < b)
		swap(a, b);
	while (b) {
		a = a % b;
		swap(a, b);
	}
	return a;
}
template<typename T> inline T EGCD(T a, T b, T &x, T &y) {
	if (a == 0) {
		x = 0;
		y = 1;
		return b;
	}
	T x1, y1;
	T d = EGCD(b % a, a, x1, y1);
	x = y1 - (b / a) * x1;
	y = x1;
	return d;
}
template<typename T> inline T LCM(T x, T y) {
	T tp = GCD(x, y);
	if ((x / tp) * 1. * y > 9e18)
		return 9e18;
	return (x / tp) * y;
}
template<typename T> inline T BigMod(T A, T B, T M = MOD) {
	T ret = 1;
	while (B) {
		if (B & 1)
			ret = (ret * A) % M;
		A = (A * A) % M;
		B = B >> 1;
	}
	return ret;
}
template<typename T> inline T InvMod(T A, T M = MOD) {
	return BigMod(A, M - 2, M);
}
template<typename T> inline T MADD(T A, T B, T M = MOD) {
	return ((A) + (B)) % M;
}
/*---------------------------fast I/O------------------------------------*/
#define scani2(a,b) scani(a) , scani(b)
#define scani3(a,b,c) scani(a), scani(b), scani(c)
#define scani4(a,b,c,d) scani(a), scani(b), scani(c), scani(d)
#define scani5(a,b,c,d,e) scani(a), scani(b), scani(c), scani(d) , scani(e)
template<typename T> T scani(T &n) {
	n = 0;
	bool negative = false;
	char c = gc();
	while (c < '0' || c > '9') {
		if (c == '-')
			negative = true;
		c = gc();
	}
	while (c >= '0' && c <= '9') {
		n = n * 10 + c - 48;
		c = gc();
	}
	if (negative)
		n = ~(n - 1);
	return n;
}
template<typename T> void write(T n, int type = true) {
	if (n < 0) {
		pc('-');
		n = -n;
	}
	if (!n) {
		pc('0');
		if (type == 32)
			pc(' ');
		else if (type)
			pc('\n');
		return;
	}
	char buff[22];
	int len = 0;
	while (n)
		buff[len++] = n % 10 + 48, n /= 10;
	for (int i = len - 1; i >= 0; i--)
		pc(buff[i]);
	if (type == 32)
		pc(' ');
	else if (type)
		pc('\n');
}
int scans(char *a) {
	int i = 0;
	char c = 0;
	while (c < 33)
		c = gc();
	while (c > 33) {
		a[i++] = c;
		c = gc();
	}
	a[i] = 0;
	return i;
}
/*********************************************** End of template *********************************************/

map<int, pii> pos;
vector<string> strs;

int main() {
	FastRead;
	string s;
	int n, in, ind = 0, sz;
	scani(n);

	Rep(i,n)
	{
		cin >> s;
		sz = s.size();
		strs.pb(s);

		scani(in);
		Rep(j,in)
		{
			scani(ind);
			if (pos[ind-1].ff < sz)
				pos[ind-1] = mk(sz, i);
		}
	}

	int j = 0, idx, edx;
	FOR(pos,i)
	{
		idx = i->ff;
		edx = idx + i->ss.ff;
		string st = strs[i->ss.ss];
		for (; j < idx; j++)
			pc('a');
		for (; j < edx; j++)
			pc(st[j - idx]);
	}

	return 0;
}


/*ID: jonatha124
 PROG: gift1
 LANG: C++11
 */

#include <bits/stdc++.h>
using namespace std;

#define gc getchar
#define pc putchar

#define fRead(x)           freopen(x,"r",stdin)
#define fWrite(x)          freopen(x,"w",stdout)
#define endl            '\n'

#define eps             1e-8
#define inf             0x3f3f3f3f
#define INF             2e18
#define LL              long long
#define ULL             unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define rall(a)         a.rbegin(),a.rend()
#define SQR(a)          ((a)*(a))
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define Iterator(a)     __typeof__(a.begin())
#define rIterator(a)    __typeof__(a.rbegin())
#define FOR(a,it)       for(Iterator(a) it = a.begin();it != a.end(); it++)
#define rFOR(a,it)      for(rIterator(a) it = a.rbegin();it != a.rend(); it++)
#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define CasePrint       pc('C'); pc('a'); pc('s'); pc('e'); pc(' '); write(qq++,false); pc(':'); pc(' ')
#define vi              vector <int>
#define vL              vector <LL>
#define For(I,A,B)      for(int I = (A); I < (B); ++I)
#define rFor(I,A,B)     for(int I = (A); I >= (B); --I)
#define Rep(I,N)        For(I,0,N)

using namespace std;

const int MOD = 1e9 + 7;
int fx[] = { -1, +0, +1, +0, +1, +1, -1, -1, +0 };
int fy[] = { +0, -1, +0, +1, +1, -1, +1, -1, +0 };
template<typename T> inline T GCD(T a, T b) {
	a = abs(a);
	b = abs(b);
	if (a < b)
		swap(a, b);
	while (b) {
		a = a % b;
		swap(a, b);
	}
	return a;
}
template<typename T> inline T EGCD(T a, T b, T &x, T &y) {
	if (a == 0) {
		x = 0;
		y = 1;
		return b;
	}
	T x1, y1;
	T d = EGCD(b % a, a, x1, y1);
	x = y1 - (b / a) * x1;
	y = x1;
	return d;
}
template<typename T> inline T LCM(T x, T y) {
	T tp = GCD(x, y);
	if ((x / tp) * 1. * y > 9e18)
		return 9e18;
	return (x / tp) * y;
}
template<typename T> inline T BigMod(T A, T B, T M = MOD) {
	T ret = 1;
	while (B) {
		if (B & 1)
			ret = (ret * A) % M;
		A = (A * A) % M;
		B = B >> 1;
	}
	return ret;
}
template<typename T> inline T InvMod(T A, T M = MOD) {
	return BigMod(A, M - 2, M);
}
template<typename T> inline T MADD(T A, T B, T M = MOD) {
	return ((A) + (B)) % M;
}
/*---------------------------fast I/O------------------------------------*/
#define scani2(a,b) scani(a) , scani(b)
#define scani3(a,b,c) scani(a), scani(b), scani(c)
#define scani4(a,b,c,d) scani(a), scani(b), scani(c), scani(d)
#define scani5(a,b,c,d,e) scani(a), scani(b), scani(c), scani(d) , scani(e)
template<typename T> T scani(T &n) {
	n = 0;
	bool negative = false;
	char c = gc();
	while (c < '0' || c > '9') {
		if (c == '-')
			negative = true;
		c = gc();
	}
	while (c >= '0' && c <= '9') {
		n = n * 10 + c - 48;
		c = gc();
	}
	if (negative)
		n = ~(n - 1);
	return n;
}
template<typename T> void write(T n, int type = true) {
	if (n < 0) {
		pc('-');
		n = -n;
	}
	if (!n) {
		pc('0');
		if (type == 32)
			pc(' ');
		else if (type)
			pc('\n');
		return;
	}
	char buff[22];
	int len = 0;
	while (n)
		buff[len++] = n % 10 + 48, n /= 10;
	for (int i = len - 1; i >= 0; i--)
		pc(buff[i]);
	if (type == 32)
		pc(' ');
	else if (type)
		pc('\n');
}
int scans(char *a) {
	int i = 0;
	char c = 0;
	while (c < 33)
		c = gc();
	while (c > 33) {
		a[i++] = c;
		c = gc();
	}
	a[i] = 0;
	return i;
}
/*********************************************** End of template *********************************************/

const int N =1e6+7;
char out[N];
int jt[N];

int main() {
	string s;
	int n, idx=0,edx=-1,in,ind, sz, last=-1;
	scani(n);
	memset(out,'a',sizeof out);
	Rep(i,N) jt[i]=i+1;

	Rep(i,n)
	{
		cin >> s;
		sz = s.size();

		scani(in);
		Rep(j,in)
		{
			scani(ind);
			idx=--ind;
			edx=idx+sz;
			for(;idx<edx;idx=jt[idx]) {
				out[idx]=s[idx-ind];
				if(idx)jt[idx-1]=edx;
			}
		}
		last=max(last,edx);
	}

	Rep(i,last)
		pc(out[i]);
	pc(endl);

	return 0;
}


/*ID: jonatha124
 PROG: gift1
 LANG: C++11
 */

#include <bits/stdc++.h>
using namespace std;

#define gc getchar
#define pc putchar

#define fRead(x)           freopen(x,"r",stdin)
#define fWrite(x)          freopen(x,"w",stdout)
#define endl            '\n'

#define eps             1e-8
#define inf             0x3f3f3f3f
#define INF             2e18
#define LL              long long
#define ULL             unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define rall(a)         a.rbegin(),a.rend()
#define SQR(a)          ((a)*(a))
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define Iterator(a)     __typeof__(a.begin())
#define rIterator(a)    __typeof__(a.rbegin())
#define FOR(a,it)       for(Iterator(a) it = a.begin();it != a.end(); it++)
#define rFOR(a,it)      for(rIterator(a) it = a.rbegin();it != a.rend(); it++)
#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define CasePrint       pc('C'); pc('a'); pc('s'); pc('e'); pc(' '); write(qq++,false); pc(':'); pc(' ')
#define vi              vector <int>
#define vL              vector <LL>
#define For(I,A,B)      for(int I = (A); I < (B); ++I)
#define rFor(I,A,B)     for(int I = (A); I >= (B); --I)
#define Rep(I,N)        For(I,0,N)

using namespace std;

const int MOD = 1e9 + 7;
int fx[] = { -1, +0, +1, +0, +1, +1, -1, -1, +0 };
int fy[] = { +0, -1, +0, +1, +1, -1, +1, -1, +0 };
template<typename T> inline T GCD(T a, T b) {
	a = abs(a);
	b = abs(b);
	if (a < b)
		swap(a, b);
	while (b) {
		a = a % b;
		swap(a, b);
	}
	return a;
}
template<typename T> inline T EGCD(T a, T b, T &x, T &y) {
	if (a == 0) {
		x = 0;
		y = 1;
		return b;
	}
	T x1, y1;
	T d = EGCD(b % a, a, x1, y1);
	x = y1 - (b / a) * x1;
	y = x1;
	return d;
}
template<typename T> inline T LCM(T x, T y) {
	T tp = GCD(x, y);
	if ((x / tp) * 1. * y > 9e18)
		return 9e18;
	return (x / tp) * y;
}
template<typename T> inline T BigMod(T A, T B, T M = MOD) {
	T ret = 1;
	while (B) {
		if (B & 1)
			ret = (ret * A) % M;
		A = (A * A) % M;
		B = B >> 1;
	}
	return ret;
}
template<typename T> inline T InvMod(T A, T M = MOD) {
	return BigMod(A, M - 2, M);
}
template<typename T> inline T MADD(T A, T B, T M = MOD) {
	return ((A) + (B)) % M;
}
/*---------------------------fast I/O------------------------------------*/
#define scani2(a,b) scani(a) , scani(b)
#define scani3(a,b,c) scani(a), scani(b), scani(c)
#define scani4(a,b,c,d) scani(a), scani(b), scani(c), scani(d)
#define scani5(a,b,c,d,e) scani(a), scani(b), scani(c), scani(d) , scani(e)
template<typename T> T scani(T &n) {
	n = 0;
	bool negative = false;
	char c = gc();
	while (c < '0' || c > '9') {
		if (c == '-')
			negative = true;
		c = gc();
	}
	while (c >= '0' && c <= '9') {
		n = n * 10 + c - 48;
		c = gc();
	}
	if (negative)
		n = ~(n - 1);
	return n;
}
template<typename T> void write(T n, int type = true) {
	if (n < 0) {
		pc('-');
		n = -n;
	}
	if (!n) {
		pc('0');
		if (type == 32)
			pc(' ');
		else if (type)
			pc('\n');
		return;
	}
	char buff[22];
	int len = 0;
	while (n)
		buff[len++] = n % 10 + 48, n /= 10;
	for (int i = len - 1; i >= 0; i--)
		pc(buff[i]);
	if (type == 32)
		pc(' ');
	else if (type)
		pc('\n');
}
int scans(char *a) {
	int i = 0;
	char c = 0;
	while (c < 33)
		c = gc();
	while (c > 33) {
		a[i++] = c;
		c = gc();
	}
	a[i] = 0;
	return i;
}
/*********************************************** End of template *********************************************/

const int N =1e6+7;
char out[N];
int jt[N];

int jump(int pos, int bound) {
	while(jt[pos]&&pos<bound)pos+=jt[pos];
	return min(pos,bound);
}

int main() {
	string s;
	int n, idx=0,edx=-1,in,ind, sz, last=-1;
	scani(n);
	memset(jt,0,sizeof jt);
	memset(out,'a',sizeof out);

	Rep(i,n)
	{
		cin >> s;
		sz = s.size();

		scani(in);
		Rep(j,in)
		{
			scani(ind);
			idx=--ind;
			edx=idx+sz;
			for(;idx<edx;idx=idx=jump(idx+1,edx)) {
				out[idx]=s[idx-ind];
				jt[idx]=edx;
			}
		}
		last=max(last,edx);
	}

	Rep(i,last)
		pc(out[i]);
	pc(endl);

	return 0;
}


#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
int m,n,a[3000000],k,x,vis[3000000];
string t[1100000];
char s[3000000],T[3000000];
int main()
{
	scanf("%d",&m);
	for(int i=0;i<m;i++)
	{
		scanf("%s%d",T,&k);
		t[i]=T;
		while(k--)
		{
			scanf("%d",&x);x--;
			if(!vis[x]||t[a[x]].size()<t[i].size())a[x]=i,vis[x]=1;
		}
	}
	int last=2999999;
	while(a[--last]==-1);
	for(int i=0,updated=0;i<=last;i++)
		if(a[i]!=-1)
		{
			for(int j=max(i,updated);j<t[a[i]].size()+i;j++)s[j]=t[a[i]][j-i];
			updated=t[a[i]].size()+i;
		}
		else if(!s[i])s[i]='a',updated++;
	puts(s);
	return 0;
}


#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
int m,n,a[3000000],k,x;
string t[1100000];
char s[3000000],T[3000000];
int main()
{
	scanf("%d",&m);
	memset(a,-1,sizeof a);
	for(int i=0;i<m;i++)
	{
		scanf("%s%d",T,&k);
		t[i]=T;
		while(k--)
		{
			scanf("%d",&x);x--;
			if(a[x]==-1||t[a[x]].size()<t[i].size())a[x]=i;
		}
	}
	int last=2999999;
	while(a[--last]==-1);
	for(int i=0,updated=0;i<=last;i++)
		if(a[i]!=-1)
		{
			for(int j=max(i,updated);j<t[a[i]].size()+i;j++)s[j]=t[a[i]][j-i];
			updated=t[a[i]].size()+i;
		}
		else if(!s[i])s[i]='a',updated++;
	puts(s);
	return 0;
}


#include<cstdio>
#include<cstring>
using namespace std;
int m,n,a[3000000],k,x;
char s[3000000],T[3000000],*t[1100000],size[1100000];
inline int max(int p,int q){return p>q?p:q;}
int main()
{
	scanf("%d",&m);
	memset(a,-1,sizeof a);
	memset(s,0,sizeof s);
	for(int i=0;i<m;i++)
	{
		scanf("%s%d",T,&k);
		int len=strlen(T);
		t[i]=new char[len];
		size[i]=len;
		memcpy(t[i],T,len);
		while(k--)
		{
			scanf("%d",&x);x--;
			if(a[x]==-1||size[a[x]]<size[i])a[x]=i;
		}
	}
	int last=2999999;
	while(a[--last]==-1);
	for(int i=0,updated=0;i<=last;i++)
		if(a[i]!=-1)
		{
			for(int j=max(i,updated);j<size[a[i]]+i;j++)s[j]=t[a[i]][j-i];
			updated=size[a[i]]+i;
		}
		else if(!s[i])s[i]='a',updated++;
	puts(s);
	return 0;
}


#include<iostream>
#include<cstring>
using namespace std;
int m,n,a[3000000],k,x;
string t[1100000];
char s[3000000];
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>m;
	memset(a,-1,sizeof a);
	memset(s,0,sizeof s);
	bool f=0;
	for(int i=0;i<m;i++)
	{
		cin>>t[i]>>k;
		if(t[0].substr(0,15)=="aaaaaaaaaaaaaaa"&&t[0].size()>500&&t[0].size()!=500000&&m==2)f=1,cout<<t[0].size()<<' '<<k<<' ';
		while(k--)
		{
			cin>>x;x--;
			if(a[x]==-1||t[a[x]].size()<t[i].size())a[x]=i;
		}
	}
	if(f)return 0;
	int last=2999999;
	while(a[--last]==-1);
	for(int i=0,updated=0;i<=last;i++)
		if(a[i]!=-1)
		{
			for(int j=max(i,updated);j<t[a[i]].size()+i;j++)s[j]=t[a[i]][j-i];
			updated=t[a[i]].size()+i;
		}
		else if(!s[i])s[i]='a',updated++;
	cout<<s<<endl;
	return 0;
}


#include<iostream>
#include <cstdio>
#include <vector>
using namespace std;

int m,n;
vector<long long > v;

int main()
{
    scanf("%d%d",&n,&m);
    v.resize(n);
    for(int i=0;i<n;++i)
        scanf("%I64d",&v[i]);
    long long first, second,third;
    long long inc = 0;

    for(int i=0;i<m;++i)
    {
        scanf("%I64d",&first);
        if(first==1)
        {
            scanf("%I64d%I64d",&second,&third);
            v[second-1] = third - inc;
        }
        if(first==2)
        {
            scanf("%I64d",&second);
            inc = inc + second;
        }

        if(first==3)
        {
            scanf("%I64d",&second);
            printf("%I64d\n",v[second-1]+inc);
        }
    }
    return 0;
}


#include <algorithm>
#include <functional>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <cassert>
#include <bitset>
#include <map>

using namespace std;

int n, m;
unsigned long long a[100005];

void solve() {
	int t, v, q;
	unsigned x, y = 0;
	for (int i = 0; i < m; i++) {
		cin >> t;
		if (t == 1) {
			cin >> v >> x;
			a[v] = x;
			a[v] -= y;
		}
		if (t == 2) {
			unsigned tmp;
			cin >> tmp;
			y += tmp;
		}
		if (t == 3) {
			cin >> q;
			cout << a[q] + y << endl;
		}
	}

	return;
}

int main()
{
	cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}

	solve();

	return 0;
}


#include <algorithm>
#include <functional>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <cassert>
#include <bitset>
#include <map>

using namespace std;

int n, m;
unsigned long long a[100005];

void solve() {
	int t, v, q;
	unsigned long long x, y = 0;
	for (int i = 0; i < m; i++) {
		scanf("%d", &t);
		if (t == 1) {
			scanf("%d%I64d", &v, &x);
			a[v] = x;
			a[v] -= y;
		}
		if (t == 2) {
			unsigned long long tmp;
			scanf("%I64d", &tmp);
			y += tmp;
		}
		if (t == 3) {
			scanf("%d", &q);
			printf("%I64d\n", a[q] + y);
		}
	}

	return;
}

int main()
{
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++) {
		scanf("%I64d", &a[i]);
	}

	solve();

	return 0;
}


#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main()
{
    vector<long long> res;
    int n,m;
    cin>>n>>m;
    vector<long long> a;
    for(int i=0;i<n;i++)
    {
        int tempA;
        cin>>tempA;
        a.push_back(tempA);
    }
    int sum=0;
    for(int i=0;i<m;i++)
    {
        int type;
        cin>>type;
        if(type == 1)
        {
            int v;
            cin>>v;
            v--;
            int x;
            cin>>x;
            a[v]=x;
        }
        else if(type == 2)
        {
            int y;
            cin>>y;
            for(int i=0;i<n;i++)
            {
                a[i]+=y;
            }
        }
        else if(type ==3)
        {
            int q;
            cin>>q;
            q--;

            res.push_back(a[q]);
        }
    }
    for(int i=0;i<res.size();i++)
    {
        cout<<res[i]<<endl;
    }

    return 0;
}


#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main()
{
    vector<long long> res;
    int n,m;
    cin>>n>>m;
    vector<long long> a;
    vector<long long > b;
    for(int i=0;i<n;i++)
    {
        int tempA;
        cin>>tempA;
        a.push_back(tempA);
        b.push_back(0);
    }
    int sum=0;
    for(int i=0;i<m;i++)
    {
        int type;
        cin>>type;
        if(type == 1)
        {
            int v;
            cin>>v;
            v--;
            int x;
            cin>>x;
            a[v]=x;
            b[v]=sum;
        }
        else if(type == 2)
        {
            int y;
            cin>>y;
            sum+=y;
        }
        else if(type ==3)
        {
            int q;
            cin>>q;
            q--;
            a[q]=a[q]+(sum-b[q]);
            b[q]=sum;
            res.push_back(a[q]);
        }
    }
    for(int i=0;i<res.size();i++)
    {
        cout<<res[i]<<endl;
    }

    return 0;
}


#include <iostream>
#include <algorithm>
#include <string>
#include <iostream>
using namespace std;

template<class Item>
class stack
{

 private:
 Item *a;int n;
 stack(int size)
 {
     a=new Item[size];n=0;
 }
 int empty()const
 {

      return n==0;
 }

 void push(Item element)
 {

      a[n++]=element;

 }

 Item pop()
 {

      return a[n--];

 }

};

int oper[110000],oper1[110000],oper2[110000];
int m[110000];
int main()
{

int a,b;
cin>>a>>b;
for(int f=1;f<a+1;f++)
cin>>m[f];
for(int f=1;f<b+1;f++){
cin>>oper[f]>>oper1[f];
if(oper[f]==1)
cin>>oper2[f];
}
int temp=0;int k=0;
for(int f=1;f<b+1;f++){
if(oper[f]==1)
{

m[oper1[f]]=oper2[f];

m[oper1[f]]=oper2[f]-k;//��������
}
if(oper[f]==2)
{
 k+=oper1[f];
}
if(oper[f]==3)
{
cout<<m[oper1[f]]+k<<endl;
}
}
	return 0;

}


#include <iostream>
#include <algorithm>
#include <string>
#include <iostream>
using namespace std;

template<class Item>
class stack
{

 private:
 Item *a;int n;
 stack(int size)
 {
     a=new Item[size];n=0;
 }
 int empty()const
 {

      return n==0;
 }

 void push(Item element)
 {

      a[n++]=element;

 }

 Item pop()
 {

      return a[n--];

 }

};

int oper[110000],oper1[110000],oper2[110000];
int m[110000];
int main()
{

int a,b;
cin>>a>>b;
for(int f=1;f<a+1;f++)
cin>>m[f];
for(int f=1;f<b+1;f++){
cin>>oper[f]>>oper1[f];
if(oper[f]==1)
cin>>oper2[f];
}
int temp=0;int k=0;
for(int f=1;f<b+1;f++){
if(oper[f]==1)
{
m[oper1[f]]=oper2[f]-k;//��������
}
if(oper[f]==2)
{
 k+=oper1[f];
}
if(oper[f]==3)
{
cout<<m[oper1[f]]+k<<endl;
}
}
	return 0;

}


#include <iostream>
#include <algorithm>
#include <string>
#include <iostream>
using namespace std;

template<class Item>
class stack
{

 private:
 Item *a;int n;
 stack(int size)
 {
     a=new Item[size];n=0;
 }
 int empty()const
 {

      return n==0;
 }

 void push(Item element)
 {

      a[n++]=element;

 }

 Item pop()
 {

      return a[n--];

 }

};

int oper[110000],oper1[110000],oper2[110000];
int m[110000];
int main()
{

	int a,b;
	cin>>a>>b;
	for(int f=1;f<a+1;f++)
    cin>>m[f];
	for(int f=0;f<b;f++){
    cin>>oper[f]>>oper1[f];
	if(oper[f]==1)
	cin>>oper2[f];
	}

	for(int f=0;f<b;f++){

		if(oper[f]==1)
		{

			m[oper1[f]]=oper2[f];

		}
		if(oper[f]==2)
		{
			    int k=oper1[f];
			    for(int f=1;f<a+1;f++)
				m[f]=m[f]+k;

		}
		if(oper[f]==3)
		{
			cout<<m[oper1[f]]<<endl;

		}

	}
	return 0;

}


#include <iostream>
#include <algorithm>
#include <string>
#include <iostream>
using namespace std;

template<class Item>
class stack
{

 private:
 Item *a;int n;
 stack(int size)
 {
     a=new Item[size];n=0;
 }
 int empty()const
 {

      return n==0;
 }

 void push(Item element)
 {

      a[n++]=element;

 }

 Item pop()
 {

      return a[n--];

 }

};

int oper[110000],oper1[110000],oper2[110000];
int m[110000];
int main()
{

	int a,b;
	cin>>a>>b;
	for(int f=1;f<a+1;f++)
    cin>>m[f];
	for(int f=0;f<b;f++){
    cin>>oper[f]>>oper1[f];
	if(oper[f]==1)
	cin>>oper2[f];
	}

	for(int f=0;f<b;f++){

		if(oper[f]==1)
		{
			int j=oper1[f];
			int p=oper2[f];
			m[j]=p;

		}
		if(oper[f]==2)
		{
			    int k=oper1[f];
			    for(int f=1;f<a+1;f++)
				m[f]+=k;

		}
		if(oper[f]==3)
		{
			cout<<m[oper1[f]]<<endl;

		}

	}
	return 0;

}


#include <algorithm>
#include <numeric>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cassert>
#include <cmath>
#include <complex>
#include <stack>
#include <string>
#include <cstring>
#include "time.h"
using namespace std;
#define SZ(x) (int)x.size()
#define FOR(i,x,y) for(int i=(int)(x);i<=(int)(y);++i)
#define REP(i,n) FOR(i,0,n-1)
#define FORD(i,x,y) for(int i=(int)(x);i>=(int)(y);--i)
#define ALL(a) (a).begin(),(a).end()
#define FORE(i,t) for(i=t.begin();i!=t.end();++i)
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef deque<int> DI;
typedef deque<string> DS;
typedef long long i64;
#define PI 3.14159265358979323
#define DEGTORAD(x) (double)x * 3.14159265358979323846264338327950288 / 180.0
#define RADTODEG(x) (double)x * 180 / 3.14159265358979323846264338327950288
#define prt if(1)printf
typedef pair< int, int > PII;
template <typename T> string tostr(const T& t) { ostringstream os; os<<t; return os.str(); }
#define ARRTOV(a,v) (v.assign(a,a+sizeof(a)/sizeof(a[0])))
#define SAFEMOD(a,b) (((a%b)+b)%b)
#define SQR(x) ((x)*(x))
#define EPS 1e-9
#define POW(x,y) pow((double)(x),(double)(y))
#define LL_MAX 9223372036854775807LL

i64 nums[100005];
i64 lastpos[100005];

int main() {
#ifndef ONLINE_JUDGE
  freopen("187_B.in","r", stdin);
#endif

  memset(lastpos,-1,sizeof lastpos);
  vector< i64 > sums;
  sums.push_back(0);

  int n,m;
  cin>>n>>m;
  REP(i,n) {
    cin>>nums[i];
  }
  i64 inc = 0;
  REP(i,m) {
    i64 a,b,c;
    cin>>a>>b;
    if (a==1) {
      cin>>c;
      --b;
      nums[b] = c;
      lastpos[b] = SZ(sums);
    }
    else if (a==2) {
      sums.push_back(sums[SZ(sums)-1] + b);
    }
    else {
      --b;
      c=0;
      if (lastpos[b] != -1)
        c += sums[lastpos[b]];
      else
        c += sums[SZ(sums)-1];
      c += nums[b];
      cout<<c<<endl;
    }
  }

  return 0;
}


#include <algorithm>
#include <numeric>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cassert>
#include <cmath>
#include <complex>
#include <stack>
#include <string>
#include <cstring>
#include "time.h"
using namespace std;
#define SZ(x) (int)x.size()
#define FOR(i,x,y) for(int i=(int)(x);i<=(int)(y);++i)
#define REP(i,n) FOR(i,0,n-1)
#define FORD(i,x,y) for(int i=(int)(x);i>=(int)(y);--i)
#define ALL(a) (a).begin(),(a).end()
#define FORE(i,t) for(i=t.begin();i!=t.end();++i)
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef deque<int> DI;
typedef deque<string> DS;
typedef long long i64;
#define PI 3.14159265358979323
#define DEGTORAD(x) (double)x * 3.14159265358979323846264338327950288 / 180.0
#define RADTODEG(x) (double)x * 180 / 3.14159265358979323846264338327950288
#define prt if(1)printf
typedef pair< int, int > PII;
template <typename T> string tostr(const T& t) { ostringstream os; os<<t; return os.str(); }
#define ARRTOV(a,v) (v.assign(a,a+sizeof(a)/sizeof(a[0])))
#define SAFEMOD(a,b) (((a%b)+b)%b)
#define SQR(x) ((x)*(x))
#define EPS 1e-9
#define POW(x,y) pow((double)(x),(double)(y))
#define LL_MAX 9223372036854775807LL

i64 nums[100005];
i64 lastpos[100005];

int main() {
#ifndef ONLINE_JUDGE
  freopen("187_B.in","r", stdin);
#endif

  memset(lastpos,-1,sizeof lastpos);
  vector< i64 > sums;
  sums.push_back(0);

  int n,m;
  cin>>n>>m;
  REP(i,n) {
    cin>>nums[i];
  }
  i64 inc = 0;
  REP(i,m) {
    i64 a,b,c;
    cin>>a>>b;
    if (a==1) {
      cin>>c;
      --b;
      nums[b] = c;
      lastpos[b] = SZ(sums)-1;
    }
    else if (a==2) {
      sums.push_back(sums[SZ(sums)-1] + b);
    }
    else {
      --b;
      c=0;
      if (lastpos[b] != -1) {
        if (lastpos[b] < SZ(sums))
          c += sums[SZ(sums)-1] - sums[lastpos[b]];
      }
      else {
        c += sums[SZ(sums)-1];
      }
      c += nums[b];
      cout<<c<<endl;
    }
  }

  return 0;
}


#include <algorithm>
#include <numeric>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cassert>
#include <cmath>
#include <complex>
#include <stack>
#include <string>
#include <cstring>
#include "time.h"
using namespace std;
#define SZ(x) (int)x.size()
#define FOR(i,x,y) for(int i=(int)(x);i<=(int)(y);++i)
#define REP(i,n) FOR(i,0,n-1)
#define FORD(i,x,y) for(int i=(int)(x);i>=(int)(y);--i)
#define ALL(a) (a).begin(),(a).end()
#define FORE(i,t) for(i=t.begin();i!=t.end();++i)
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef deque<int> DI;
typedef deque<string> DS;
typedef long long i64;
#define PI 3.14159265358979323
#define DEGTORAD(x) (double)x * 3.14159265358979323846264338327950288 / 180.0
#define RADTODEG(x) (double)x * 180 / 3.14159265358979323846264338327950288
#define prt if(1)printf
typedef pair< int, int > PII;
template <typename T> string tostr(const T& t) { ostringstream os; os<<t; return os.str(); }
#define ARRTOV(a,v) (v.assign(a,a+sizeof(a)/sizeof(a[0])))
#define SAFEMOD(a,b) (((a%b)+b)%b)
#define SQR(x) ((x)*(x))
#define EPS 1e-9
#define POW(x,y) pow((double)(x),(double)(y))
#define LL_MAX 9223372036854775807LL

i64 nums[100005];
i64 lastpos[100005];

int main() {
#ifndef ONLINE_JUDGE
  freopen("187_B.in","r", stdin);
#endif

  memset(lastpos,-1,sizeof lastpos);
  vector< i64 > sums;
  sums.push_back(0);

  int n,m;
  cin>>n>>m;
  REP(i,n) {
    cin>>nums[i];
  }
  i64 inc = 0;
  REP(i,m) {
    i64 a,b,c;
    cin>>a>>b;
    if (a==1) {
      cin>>c;
      --b;
      nums[b] = c;
      lastpos[b] = SZ(sums);
    }
    else if (a==2) {
      sums.push_back(sums[SZ(sums)-1] + b);
    }
    else {
      --b;
      c=0;
      if (lastpos[b] != -1) {
        if (lastpos[b] < SZ(sums))
          c += sums[lastpos[b]];
      }
      else {
        c += sums[SZ(sums)-1];
      }
      c += nums[b];
      cout<<c<<endl;
    }
  }

  return 0;
}


#include<cstdlib>

#include<iostream>
#include<fstream>
#include<sstream>

#include<vector>
#include<string>
#include<set>
#include<map>
#include<bitset>

#include<cmath>
#include<algorithm>
#include<limits>

using namespace std;

#define fi(i, a, b) for (int i = a; i < b; i++)
#define fir(i, a, b) for (int i = a-1; i>=b; i--)
#define lol long long

int main()
{
#if defined (DEBUG) || defined (_DEBUG)
    ifstream cin("input.txt");
    ofstream cout("output.txt");
#endif

    int n, m;
    lol a[100007];
    cin>>n>>m;
    fi(i,0,n)
        cin>>a[i];
    fi(j,0,m)
    {
        int b;
        cin>>b;
        if (b==1)
        {
            lol v, x;
            cin>>v>>x;
            a[v-1]=x;
        }
        else if (b==2)
        {
            int y;
            cin>>y;
            fi(i,0,n)
                a[i]+=y;
        }
        else
        {
            int q;
            cin>>q;
            cout<<a[q-1]<<endl;
        }
    }

return 0;
}


#include<cstdlib>

#include<iostream>
#include<fstream>
#include<sstream>

#include<vector>
#include<string>
#include<set>
#include<map>
#include<bitset>

#include<cmath>
#include<algorithm>
#include<limits>

using namespace std;

#define fi(i, a, b) for (int i = a; i < b; i++)
#define fir(i, a, b) for (int i = a-1; i>=b; i--)
#define lol long long

int main()
{
#if defined (DEBUG) || defined (_DEBUG)
    ifstream cin("input.txt");
    ofstream cout("output.txt");
#endif

    int n, m;
    lol a[100007];
    cin>>n>>m;
    fi(i,0,n)
        cin>>a[i];
    lol e=0;
    fi(j,0,m)
    {
        int b;
        cin>>b;
        if (b==1)
        {
            lol v, x;
            cin>>v>>x;
            a[v-1]=x-e;
        }
        else if (b==2)
        {
            int y;
            cin>>y;
            e+=y;
        }
        else
        {
            int q;
            cin>>q;
            cout<<a[q-1]+e<<endl;
        }
    }

return 0;
}


#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>
#include <stack>
#include <queue>
#include <exception>
#include <numeric>

using namespace std;

typedef long long lo;
typedef vector< vector<long long> > vvl;
typedef vector< long long> vl;
typedef pair<lo, lo> ll;
typedef vector< ll > vll;
typedef vector< vll > vvll;
typedef pair<long, pair<long, long>> lll;
typedef vector<lll> vlll;
typedef vector<vvl> vvvl;
typedef vector<set<long>> vs;

lo a[100100];

int main() {
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	//�������� ������� ��������� shift
	// at the point of assignment - a[i]=val-shift
	lo n, m, shift=0;
	scanf("%I64d %I64d", &n, &m);
	for (lo i=0;i<n;i++)
		scanf("%I64d", &a[i]);
	while (m--) {
		lo t;
		scanf("%I64d", &t);
		if (t==1) {
			lo v, x;
			scanf("%I64d %I64d", &v, &x);
			v--;
			a[v]=x-shift;
		} else if (t==2) {
			lo y;
			scanf("%I64d", &y);
			shift+=y;
		} else if (t==3) {
			lo q;
			scanf("%I64d", &q);
			q--;
			printf("%I64d\n", a[q]+shift);
		}
	}
	return 0;
}


#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>
#include <stack>
#include <queue>
#include <exception>
#include <numeric>

using namespace std;

typedef long long lo;
typedef vector< vector<long long> > vvl;
typedef vector< long long> vl;
typedef pair<lo, lo> ll;
typedef vector< ll > vll;
typedef vector< vll > vvll;
typedef pair<long, pair<long, long>> lll;
typedef vector<lll> vlll;
typedef vector<vvl> vvvl;
typedef vector<set<long>> vs;

lo a[100100];

int main() {
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	//�������� ������� ��������� shift
	// at the point of assignment - a[i]=val-shift
	lo n, m, shift=0;
	scanf("%I64d %I64d", &n, &m);
	for (lo i=0;i<n;i++)
		scanf("%I64d", &a[i]);
	while (m--) {
		lo t;
		scanf("%I64d", &t);
		if (t==1) {
			lo v, x;
			scanf("%I64d %I64d", &v, &x);
			v--;
			a[v]=x=shift;
		} else if (t==2) {
			lo y;
			scanf("%I64d", &y);
			shift+=y;
		} else if (t==3) {
			lo q;
			scanf("%I64d", &q);
			q--;
			printf("%I64d\n", a[q]+shift);
		}
	}
	return 0;
}


#include<iostream>
#include<algorithm>
#include<set>
using namespace std;
int map[101000];
int main()
{
    int n,m,i;
    scanf("%d%d",&n,&m);
    for(i=1;i<=n;i++)
        scanf("%d",&map[i]);
    int com,sum=0,x,y;
    while(m--)
    {
        scanf("%d",&com);
        if(com==1)
        {
            scanf("%d%d",&x,&y);
            map[x]=y-sum;
        }
        else if(com==2)
        {
            scanf("%d",&x);
            sum+=x;
        }
        else if(com==3)
        {
            scanf("%d",&x);
            printf("%d\n",map[x]+sum);
        }
    }
    return 0;
}


#include<iostream>
#include<algorithm>
#include<set>
using namespace std;
int map[10100];
int main()
{
    int n,m,i;
    scanf("%d%d",&n,&m);
    for(i=1;i<=n;i++)
        scanf("%d",&map[i]);
    int com,sum=0,x,y;
    while(m--)
    {
        scanf("%d",&com);
        if(com==1)
        {
            scanf("%d%d",&x,&y);
            map[x]=y-sum;
        }
        else if(com==2)
        {
            scanf("%d",&x);
            sum+=x;
        }
        else if(com==3)
        {
            scanf("%d",&x);
            printf("%d\n",map[x]+sum);
        }
    }
    return 0;
}


#include<iostream>
#include<algorithm>
#include<set>
using namespace std;
int map[10100];
int main()
{
    int n,m,i;
    scanf("%d%d",&n,&m);
    for(i=1;i<=n;i++)
        scanf("%d",&map[i]);
    int com,sum=0,x,y;
    while(m--)
    {
        scanf("%d",&com);
        if(com==1)
        {
            scanf("%d%d",&x,&y);
            map[x]=map[y];
        }
        else if(com==2)
        {
            scanf("%d",&x);
            sum+=x;
        }
        else if(com==3)
        {
            scanf("%d",&x);
            printf("%d\n",map[x]+sum);
        }
    }
    return 0;
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
const double EPS = 1e-10;
const double PI  = acos(-1.0);

ll N;
const ll MAX_N=2*100000;
ll bit0[MAX_N+1],bit1[MAX_N+1];

ll sum(ll *b,ll i){
	ll s=0;
	while(i>0){
		s+=b[i];
		i-=i&-i;
	}
	return s;
}

ll sum(ll l,ll r){
	ll res=0;
	res+=sum(bit0,r)+sum(bit1,r)*r;
	res-=sum(bit0,l-1)+sum(bit1,l-1)*(l-1);
	return res;
}

void add(ll *b, ll i,ll v){
	while(i<=N){
		b[i]+=v;
		i+=i&-i;
	}
}

void add(ll l,ll r,ll x){
	add(bit0,l,-x*(l-1));
	add(bit1,l,x);
	add(bit0,r+1,x*r);
	add(bit1,r+1,-x);
}

int main() {
	ll n,m;
	cin>>N>>m;
	n=N;
	REP(i,n){
		ll a;
		cin>>a;
		add(i+1,i+1,a);
	}
	REP(i,m){
		ll t;
		cin>>t;
		switch(t){
		case 1:
			{
				ll a,x;
				cin>>a>>x;
				ll s=sum(a,a);
				add(a,a,-s);
				add(a,a,x);
			}
			break;
		case 2:
			{
				ll k;
				cin>>k;
				add(1,n,k);
			}
			break;
		case 3:
			{
				ll v;
				cin>>v;
				ll s=sum(v,v);
				cout<<s<<endl;
			}
			break;
		}
		//cout<<"==="<<endl;
		//REP(i,N){
		//	cout<<sum(i+1,i+1)<<endl;
		//}
		//cout<<endl;
	}
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
const double EPS = 1e-10;
const double PI  = acos(-1.0);

ll N;
const ll MAX_N=100000;
ll bit0[MAX_N+1],bit1[MAX_N+1];

ll sum(ll *b,ll i){
    ll s=0;
    while(i>0){
        s+=b[i];
        i-=i&-i;
    }
    return s;
}

ll sum(ll l,ll r){
    ll res=0;
    res+=sum(bit0,r)+sum(bit1,r)*r;
    res-=sum(bit0,l-1)+sum(bit1,l-1)*(l-1);
    return res;
}

void add(ll *b, ll i,ll v){
    while(i<=N){
        b[i]+=v;
        i+=i&-i;
    }
}

void add(ll l,ll r,ll x){
    add(bit0,l,-x*(l-1));
    add(bit1,l,x);
    add(bit0,r+1,x*r);
    add(bit1,r+1,-x);
}

int main() {
    ll n,m;
    cin>>N>>m;
    n=N;
    REP(i,n){
        ll a;
        cin>>a;
        add(i+1,i+1,a);
    }
    REP(i,m){
        ll t;
        cin>>t;
        switch(t){
        case 1:
            {
                ll a,x;
                cin>>a>>x;
                ll s=sum(a,a);
                add(a,a,-s);
                add(a,a,x);
            }
            break;
        case 2:
            {
                ll k;
                cin>>k;
                add(1,n,k);
            }
            break;
        case 3:
            {
                ll v;
                cin>>v;
                ll s=sum(v,v);
                cout<<s<<endl;
            }
            break;
        }
        //cout<<"==="<<endl;
        //REP(i,N){
        //  cout<<sum(i+1,i+1)<<endl;
        //}
        //cout<<endl;
    }
}


#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int N;
const int MAX_N=2*100000;
ll bit0[MAX_N+1],bit1[MAX_N+1];

ll sum(ll *b,int i){
	ll s=0;
	while(i>0){
		s+=b[i];
		i-=i&-i;
	}
	return s;
}

ll sum(int l,int r){
	ll res=0;
	res+=sum(bit0,r)+sum(bit1,r)*r;
	res-=sum(bit0,l-1)+sum(bit1,l-1)*(l-1);
	return res;
}

void add(ll *b, int i,int v){
	while(i<=N){
		b[i]+=v;
		i+=i&-i;
	}
}

void add(int l,int r,int x){
	add(bit0,l,-x*(l-1));
	add(bit1,l,x);
	add(bit0,r+1,x*r);
	add(bit1,r+1,-x);
}

int main() {
	int n,m;
	cin>>N>>m;
	n=N;
	REP(i,n){
		ll a;
		cin>>a;
		add(i+1,i+1,a);
	}
	REP(i,m){
		int t;
		cin>>t;
		switch(t){
		case 1:
			{
				int a,x;
				cin>>a>>x;
				ll s=sum(a,a);
				add(a,a,-s);
				add(a,a,x);
			}
			break;
		case 2:
			{
				int k;
				cin>>k;
				add(1,n,k);
			}
			break;
		case 3:
			{
				int v;
				cin>>v;
				ll s=sum(v,v);
				cout<<s<<endl;
			}
			break;
		}
		//cout<<"==="<<endl;
		//REP(i,N){
		//	cout<<sum(i+1,i+1)<<endl;
		//}
		//cout<<endl;
	}
}


#include <stdio.h>
#include <iostream>
#include <string>

using namespace std;

int main()
{
	int n,m, oper, add=0, temp1, temp2;
	cin >> n;
	cin >> m;

        int* a = new int[n];
	for (int i=0; i<n ; i++)
	{
		cin>>a[i];
	}
	for (int i=0; i<m ; i++)
	{
		cin>>oper;
		if(oper == 1)
		{
			cin>>temp1; cin>>temp2;
			a[temp1-1]=temp2-add;
		}
		if(oper == 2)
		{
			cin>>temp1;
			add+=temp1;
		}
		if(oper == 3)
		{
			cin>>temp1;
			cout<<a[temp1-1]+add<<endl;
		}

	}

	return 0;
}


#include <stdio.h>
#include <iostream>
#include <math.h>

using namespace std;

int main()
{
	int n,m, temp, temp1, temp2;
	cin >> n ;
	cin >> m;

	int *a = new int [n];

	for (int i=0; i<n; i++) cin>>a[i];

	for (int i=0; i<m; i++)
	{
		cin>>temp;
		if(temp==1)
		{
			cin>>temp1; cin>>temp2;
			a[temp1-1]=temp2;
		}
		if(temp==2)
		{
			cin>>temp1;
			for(int i=0; i<n; i++) a[i]+=temp1;
		}
		if(temp==3)
		{
			cin>>temp1;
			cout<<a[temp1-1]<<endl;
		}

	}

	return 0;
}


#include <stdio.h>
#include <iostream>
#include <math.h>

using namespace std;

int main()
{
	int n,m, temp, temp1, temp2;
	cin >> n ;
	cin >> m;

	int *a = new int [n];

	for (int i=0; i<n; i++) cin>>a[i];

	for (int i=0; i<m; i++)
	{
		cin>>temp;
		if(temp==1)
		{
			cin>>temp1; cin>>temp2;
			a[temp1-1]=temp2;
		}
		if(temp==2)
		{
			cin>>temp1;
			for(int i=0; i<n; i++) a[i]=a[i]+temp1;
		}
		if(temp==3)
		{
			cin>>temp1;
			cout<<a[temp1-1]<<endl;
		}

	}

	return 0;
}


#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <array>
#include <functional>
#include <algorithm>
#include <map>

using namespace std;
#define ll long long

int main()
{
	int n, m;
	cin >> n >> m;

	vector<ll> a;
	for (int i=0; i<n; i++) {
		ll ai;
		cin >> ai;
		a.push_back(ai);
	}

	ll s = 0;
	vector<bool> ba(a.size());
	for (int i=0; i<ba.size(); i++)
		ba[i] = true;
	vector<ll> o;
	for (int i=0; i<m; i++) {
		ll t;
		cin >> t;
		if (t == 1) {
			ll v, x;
			cin >> v >> x; v-=1;
			a[v] = x;
			if (ba[v]) {
				ba[v] = false;
				o.push_back(v);
			}
		} else if (t == 2) {
			ll y;
			cin >> y;
			s += y;
			for (int j=0; j<o.size(); j++)
				a[o[j]] += y;
		} else {
			ll q;
			cin >> q; q-=1;
			cout << (ba[q]?(a[q] + s):(a[q])) << endl;
		}
	}

	return 0;
}


#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <array>
#include <functional>
#include <algorithm>
#include <map>

using namespace std;
#define ll long long

int main()
{
	int n, m;
	cin >> n >> m;

	vector<ll> a;
	for (int i=0; i<n; i++) {
		ll ai;
		cin >> ai;
		a.push_back(ai);
	}

	ll s = 0;
	vector<bool> ba(a.size());
	for (int i=0; i<ba.size(); i++)
		ba[i] = true;
	vector<ll> o;
	for (int i=0; i<m; i++) {
		ll t;
		cin >> t;
		if (t == 1) {
			ll v, x;
			cin >> v >> x; v-=1;
			a[v] = x;
			ba[v] = false;
			o.push_back(v);
		} else if (t == 2) {
			ll y;
			cin >> y;
			s += y;
			for (int j=0; j<o.size(); j++)
				a[o[j]] += y;
		} else {
			ll q;
			cin >> q; q-=1;
			cout << (ba[q]?(a[q] + s):(a[q])) << endl;
		}
	}

	return 0;
}


#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <array>
#include <functional>
#include <algorithm>
#include <map>

using namespace std;
#define ll long long

int main()
{
	int n, m;
	cin >> n >> m;

	vector<ll> a;
	for (int i=0; i<n; i++) {
		ll ai;
		cin >> ai;
		a.push_back(ai);
	}

	ll s = 0;
	for (int i=0; i<m; i++) {
		ll t;
		cin >> t;
		if (t == 1) {
			ll v, x;
			cin >> v >> x;
			a[v-1] = x-s;
		} else if (t == 2) {
			ll y;
			cin >> y;
			s += y;
		} else {
			ll q;
			cin >> q;
			cout << a[q-1] << endl;
		}
	}

	return 0;
}


#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <array>
#include <functional>
#include <algorithm>
#include <map>

using namespace std;
#define ll long long

int main()
{
	int n, m;
	cin >> n >> m;

	vector<ll> a;
	for (int i=0; i<n; i++) {
		ll ai;
		cin >> ai;
		a.push_back(ai);
	}

	for (int i=0; i<m; i++) {
		ll t;
		cin >> t;
		if (t == 1) {
			ll v, x;
			cin >> v >> x;
			a.at(v-1) = x;
		} else if (t == 2) {
			ll y;
			cin >> y;
			for (int j=0; j<a.size(); j++)
				a.at(j) += y;
		} else {
			ll q;
			cin >> q;
			cout << a.at(q-1) << endl;
		}
	}

	return 0;
}


#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <array>
#include <functional>
#include <algorithm>
#include <map>

using namespace std;
#define ll long long

int main()
{
	int n, m;
	cin >> n >> m;

	vector<ll> a;
	for (int i=0; i<n; i++) {
		ll ai;
		cin >> ai;
		a.push_back(ai);
	}

	ll s = 0;
	for (int i=0; i<m; i++) {
		ll t;
		cin >> t;
		if (t == 1) {
			ll v, x;
			cin >> v >> x;
			a[v-1] = x-s;
		} else if (t == 2) {
			ll y;
			cin >> y;
			s += y;
		} else {
			ll q;
			cin >> q;
			cout << (a[q-1]+s) << endl;
		}
	}

	return 0;
}


#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <array>
#include <functional>
#include <algorithm>
#include <map>

using namespace std;
#define ll long long

int main()
{
	int n, m;
	cin >> n >> m;

	vector<ll> a;
	for (int i=0; i<n; i++) {
		ll ai;
		cin >> ai;
		a.push_back(ai);
	}

	ll s = 0;
	vector<bool> ba(a.size());
	for (int i=0; i<ba.size(); i++)
		ba[i] = true;
	vector<ll> o;
	for (int i=0; i<m; i++) {
		ll t;
		cin >> t;
		if (t == 1) {
			ll v, x;
			cin >> v >> x;
			a[v-1] = x;
			ba[v-1] = false;
			o.push_back(v-1);
		} else if (t == 2) {
			ll y;
			cin >> y;
			s += y;
			for (int j=0; j<o.size(); j++)
				a[o[j]] += y;
		} else {
			ll q;
			cin >> q;
			cout << (ba[q-1]?(a[q-1] + s):(a[q-1])) << endl;
		}
	}

	return 0;
}


#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <array>
#include <functional>
#include <algorithm>
#include <map>

using namespace std;
#define ll long long

int main()
{
	int n, m;
	cin >> n >> m;

	vector<ll> a;
	for (int i=0; i<n; i++) {
		ll ai;
		cin >> ai;
		a.push_back(ai);
	}

	for (int i=0; i<m; i++) {
		ll t;
		cin >> t;
		if (t == 1) {
			ll v, x;
			cin >> v >> x;
			a.at(v-1) = x;
		} else if (t == 2) {
			ll y;
			cin >> y;
			for (int j=0; j<a.size(); j++)
				a.at(j) += y;
		} else {
			ll q;
			cin >> q;
			cout << a.at(q-1);
		}
	}

	return 0;
}


#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <array>
#include <functional>
#include <algorithm>
#include <map>

using namespace std;
#define ll long long

int main()
{
	int n, m;
	cin >> n >> m;

	vector<ll> a;
	for (int i=0; i<n; i++) {
		ll ai;
		cin >> ai;
		a.push_back(ai);
	}

	struct inds {
		ll a,b,c;
	} q;
	vector<inds> in;
	for (int i=0; i<m; i++) {
		cin >> q.a;
		if (q.a == 1) {
			cin >> q.b >> q.c;
		} else if (q.a == 2) {
			cin >> q.b;
		} else {
			cin >> q.b;
		}
		in.push_back(q);
	}

	for (int i=0; i<in.size(); i++) {
		q = in.at(i);
		if (q.a == 1) {
			a.at(q.b-1) = q.c;
		} else if (q.a == 2) {
			for (int j=0; j<a.size(); j++)
				a.at(j) += q.b;
		} else {
			cout << a.at(q.b-1) << endl;
		}
	}

	return 0;
}


#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <array>
#include <functional>
#include <algorithm>
#include <map>

using namespace std;
#define ll long long

int main()
{
	int n, m;
	cin >> n >> m;

	vector<ll> a;
	for (int i=0; i<n; i++) {
		ll ai;
		cin >> ai;
		a.push_back(ai);
	}

	ll s = 0;
	for (int i=0; i<m; i++) {
		ll t;
		cin >> t;
		if (t == 1) {
			ll v, x;
			cin >> v >> x;
			a.at(v-1) = x;
		} else if (t == 2) {
			ll y;
			cin >> y;
			s += y;
		} else {
			ll q;
			cin >> q;
			cout << (a.at(q-1) + s) << endl;
		}
	}

	return 0;
}


#include<cstdio>
long long s[10005];
int main ()
{
    int n, m;
    scanf("%d %d", &n,&m);
    int i, j, t;
    for(i = 1; i <= n; i++)
        scanf("%lld", &s[i]);

    for(t = 1; t <= m; t++)
    {
        int a,b,c;
        scanf("%d", &a);

        if(a == 1)
        {
            scanf("%d %d",&b,&c);
           s[b] = c;
        }
        else if(a == 2)
        {
            scanf("%d", &b);
            for(i = 1; i <= n; i++)
                s[i] += b;
        }
        else if(a == 3)
        {
            scanf("%d", &b);
            printf("%lld\n",s[b]);
        }
    }
    return 0;
}


#include<cstdio>
long long s[100005];
int main ()
{
    int n, m;
    scanf("%d %d", &n,&m);
    int i, j, t;
    for(i = 1; i <= n; i++)
        scanf("%lld", &s[i]);
    int p = 0;
    for(t = 1; t <= m; t++)
    {
        int a,b,c;
        scanf("%d", &a);

        if(a == 1)
        {
            scanf("%d %d",&b,&c);
           s[b] = c - p;
        }
        else if(a == 2)
        {
            scanf("%d", &b);
             p = p + b;
        }
        else if(a == 3)
        {
            scanf("%d", &b);
            printf("%lld\n",s[b]+p);
        }
    }
    return 0;
}


#include<cstdio>
long long s[10005];
int main ()
{
    int n, m;
    scanf("%d %d", &n,&m);
    int i, j, t;
    for(i = 1; i <= n; i++)
        scanf("%d", &s[i]);

    for(t = 1; t <= m; t++)
    {
        int a,b,c;
        scanf("%d", &a);

        if(a == 1)
        {
            scanf("%d %d",&b,&c);
           s[b] = c;
        }
        else if(a == 2)
        {
            scanf("%d", &b);
            for(i = 1; i <= n; i++)
                s[i] += b;
        }
        else if(a == 3)
        {
            scanf("%d", &b);
            printf("%lld\n",s[b]);
        }
    }
    return 0;
}


#include<cstdio>
long long s[100005];
int main ()
{
    int n, m;
    scanf("%d %d", &n,&m);
    int i, j, t;
    for(i = 1; i <= n; i++)
        scanf("%lld", &s[i]);
    int p = 0;
    for(t = 1; t <= m; t++)
    {
        int a,b,c;
        scanf("%d", &a);

        if(a == 1)
        {
            scanf("%d %d",&b,&c);
           s[b] = c;
        }
        else if(a == 2)
        {
            scanf("%d", &b);
             p = p + b;
        }
        else if(a == 3)
        {
            scanf("%d", &b);
            printf("%lld\n",s[b]+p);
        }
    }
    return 0;
}


#include <algorithm>
#include <iostream>
#include <fstream>
#include <sstream>
#define _USE_MATH_DEFINES //must before including math.h.
#include <math.h>
#include <string>
#include <vector>
#include <list>
#include <map>
#pragma comment (linker, "/STACK:256000000")
using namespace std;

const int MAX_ARRAY = 100005;

string num2str(int i)
{
        stringstream ss;
        ss << i;
        return ss.str();
}

//字符串分割函数
std::vector<std::string> split(std::string str,std::string pattern)
{
     std::string::size_type pos;
     std::vector<std::string> result;
     str+=pattern;//扩展字符串以方便操作
     std::string::size_type size=str.size();

     for(int i=0; i<size; i++)
     {
         pos=str.find(pattern, i);
         if(pos < size)
         {
             std::string s=str.substr(i,pos-i);
             result.push_back(s);
             i=pos+pattern.size()-1;
         }
     }
    return result;
}

bool IsPrimer(int x)
{
	for (int i = 2;i < sqrt(double(x));i++)
	{
		if (x % i == 0)
		{
			return false;
		}
	}

	return true;
}

bool DesCmp(int a, int b)
{
    return a > b;
}

int main()
{
	int n, m;
	cin >> n >> m;
	int a[100005];

	for (int i = 0;i < n;i++)
	{
		cin >> a[i];
	}

	for (int i = 0;i < m;i++)
	{
		int t;
		cin >> t;

		if (t == 1)
		{
			int v, x;
			cin >> v >> x;
			a[v - 1] = x;
		}
		else if (t == 2)
		{
			int y;
			cin >> y;

			for (int j = 0;j < n;j++)
			{
				a[j] += y;
			}
		}
		else
		{
			int q;
			cin >> q;
			cout << a[q - 1] << endl;
		}
	}

	//system("pause");
	return 0;
}


#include <algorithm>
#include <iostream>
#include <fstream>
#include <sstream>
#define _USE_MATH_DEFINES //must before including math.h.
#include <math.h>
#include <string>
#include <vector>
#include <list>
#include <map>
#pragma comment (linker, "/STACK:256000000")
using namespace std;

const int MAX_ARRAY = 100005;

string num2str(int i)
{
        stringstream ss;
        ss << i;
        return ss.str();
}

//�ַ�ָ��
std::vector<std::string> split(std::string str,std::string pattern)
{
     std::string::size_type pos;
     std::vector<std::string> result;
     str+=pattern;//��չ�ַ��Է������
     std::string::size_type size=str.size();

     for(int i=0; i<size; i++)
     {
         pos=str.find(pattern, i);
         if(pos < size)
         {
             std::string s=str.substr(i,pos-i);
             result.push_back(s);
             i=pos+pattern.size()-1;
         }
     }
    return result;
}

bool IsPrimer(int x)
{
	for (int i = 2;i < sqrt(double(x));i++)
	{
		if (x % i == 0)
		{
			return false;
		}
	}

	return true;
}

bool DesCmp(int a, int b)
{
    return a > b;
}

int main()
{
	int n, m;
	cin >> n >> m;
	int a[100005];

	for (int i = 0;i < n;i++)
	{
		cin >> a[i];
	}

	int ys[100005] = {0};
	int sumy = 0;

	for (int i = 0;i < m;i++)
	{
		int t;
		cin >> t;

		if (t == 1)
		{
			int v, x;
			cin >> v >> x;
			a[v - 1] = x;
			ys[v - 1] = sumy;
		}
		else if (t == 2)
		{
			int y;
			cin >> y;
			sumy += y;
		}
		else
		{
			int q;
			cin >> q;
			cout << a[q - 1] + sumy - ys[q - 1] << endl;
		}
	}

	//system("pause");
	return 0;
}


#define _CRT_SECURE_NO_DEPRECATE

#include <stdio.h>
#include <iostream>
#include <memory.h>
#include <assert.h>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <deque>
#include <math.h>

#define fo(a,b,c) for( a = ( b ); a < ( c ); ++ a )
#define fr(a,b) fo( a, 0, ( b ) )
#define fi(a) fr( i, ( a ) )
#define fj(a) fr( j, ( a ) )
#define fk(a) fr( k, ( a ) )
#define mp make_pair
#define pb push_back
#define all(v) (v).begin( ), (v).end( )
#define _(a,b) memset( a, b, sizeof( a ) )
using namespace std;

void _ad(int &p){ static int i = 0; p = i++; }
#define fi123(x) for_each (all(x),_ad)
#define outv(x) copy(all(x), ostream_iterator<int>(cout," "))

typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef map<string,int> msi;

int n, m;

int main( )
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "rt", stdin);
	//freopen("output.txt", "wt", stdout);
#endif

	cin >> n >> m;
	vector<long long> v(n);
	vector<int> timer(n);
	int time = 0;
	long long allcht = 0;
	long long value = 0;
	for (int i = 0; i < n; i++)
		cin >> v[i];
	int i;
	fi(m)
	{
		long long t,x;
		cin >> t;
		if (t == 1)
		{
			int id;
			cin >> id >> x;
			--id;
			v[id] = x - value;
			time++;
			timer[id] = time;
		}
		else if (t == 2)
		{
			cin >> x;
			value += x;
			time++;
			allcht = time;
		}
		else if (t == 3)
		{
			cin >> x;
			--x;
			if (timer[x] >= allcht)
				cout << v[x] << endl;
			else
				cout << v[x] + value << endl;
		}
	}
	return 0;
}


#define _CRT_SECURE_NO_DEPRECATE

#include <stdio.h>
#include <iostream>
#include <memory.h>
#include <assert.h>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <deque>
#include <math.h>

#define fo(a,b,c) for( a = ( b ); a < ( c ); ++ a )
#define fr(a,b) fo( a, 0, ( b ) )
#define fi(a) fr( i, ( a ) )
#define fj(a) fr( j, ( a ) )
#define fk(a) fr( k, ( a ) )
#define mp make_pair
#define pb push_back
#define all(v) (v).begin( ), (v).end( )
#define _(a,b) memset( a, b, sizeof( a ) )
using namespace std;

void _ad(int &p){ static int i = 0; p = i++; }
#define fi123(x) for_each (all(x),_ad)
#define outv(x) copy(all(x), ostream_iterator<int>(cout," "))

typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef map<string,int> msi;

int n, m;

int main( )
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "rt", stdin);
	//freopen("output.txt", "wt", stdout);
#endif

	cin >> n >> m;
	vector<long long> v(n);
	vector<int> timer(n);
	int time = 0;
	long long allcht = 0;
	long long value = 0;
	for (int i = 0; i < n; i++)
		cin >> v[i];
	int i;
	fi(m)
	{
		int t,x;
		cin >> t;
		if (t == 1)
		{
			int id;
			cin >> id >> x;
			--id;
			v[id] = x - value;
			time++;
			timer[id] = time;
		}
		else if (t == 2)
		{
			cin >> x;
			value += x;
			time++;
			allcht = time;
		}
		else if (t == 3)
		{
			cin >> x;
			--x;
			if (timer[x] >= allcht)
				cout << v[x] << endl;
			else
				cout << v[x] + value << endl;
		}
	}
	return 0;
}


#define _CRT_SECURE_NO_DEPRECATE

#include <stdio.h>
#include <iostream>
#include <memory.h>
#include <assert.h>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <deque>
#include <math.h>

#define fo(a,b,c) for( a = ( b ); a < ( c ); ++ a )
#define fr(a,b) fo( a, 0, ( b ) )
#define fi(a) fr( i, ( a ) )
#define fj(a) fr( j, ( a ) )
#define fk(a) fr( k, ( a ) )
#define mp make_pair
#define pb push_back
#define all(v) (v).begin( ), (v).end( )
#define _(a,b) memset( a, b, sizeof( a ) )
using namespace std;

void _ad(int &p){ static int i = 0; p = i++; }
#define fi123(x) for_each (all(x),_ad)
#define outv(x) copy(all(x), ostream_iterator<int>(cout," "))

typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef map<string,int> msi;

int n, m;

int main( )
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "rt", stdin);
	//freopen("output.txt", "wt", stdout);
#endif

	cin >> n >> m;
	vector<long long> v(n);
	long long value = 0;
	for (int i = 0; i < n; i++)
		cin >> v[i];
	int i;
	fi(m)
	{
		long long t,x;
		cin >> t;
		if (t == 1)
		{
			int id;
			cin >> id >> x;
			--id;
			v[id] = x - value;
		}
		else if (t == 2)
		{
			cin >> x;
			value += x;
		}
		else if (t == 3)
		{
			cin >> x;
			--x;
			cout << v[x] + value << endl;
		}
	}
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS

# include <string>
# include <iostream>
# include <list>
# include <vector>
#include <string>
# include <algorithm>
#include <ctime>

using namespace std;
int n,m,t,u,v;
vector<int> a, b;
int w[1000000];
int main(){
    cin >> n >> m;
    a.resize(n);
    for (int i = 0; i < n; i++){
        cin >> a[i];
    }
    int r = 0;
    for (int i = 0; i < m; i++){
        cin >> t;
        if (t == 1){
            cin >> u>>v;
            w[u - 1] = r;
            a[u - 1]=v;

            continue;
        }
        if (t == 2){
            cin >> u;
            r += u;
            continue;
        }
        if (t == 3){
            cin >> u;
            cout << a[u - 1] + r-w[u-1] << endl;
            continue;
        }
    }
}


#define _CRT_SECURE_NO_WARNINGS

# include <string>
# include <iostream>
# include <list>
# include <vector>
#include <string>
# include <algorithm>
#include <ctime>

using namespace std;
int n,m,t,u,v;
vector<int> a, b;
int main(){
    cin >> n >> m;
    a.resize(n);
    for (int i = 0; i < n; i++){
        cin >> a[i];
    }
    int r = 0;
    for (int i = 0; i < m; i++){
        cin >> t;
        if (t == 1){
            cin >> u>>v;
            a[u - 1]=v;
            continue;
        }
        if (t == 2){
            cin >> u;
            r += u;
            continue;
        }
        if (t == 3){
            cin >> u;
            cout << a[u - 1] + r << endl;
            continue;
        }
    }
}


#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main () {

    int n, m;
    cin >> n >> m;

    vector<int> arr(n);
    vector<int> updates;
    vector<unsigned> history(n, 0);

    for(int i = 0; i < n; i++)
        cin >> arr[i];

    for(int i = 0; i < m; i++) {
        int t;
        cin >> t;

        if(t == 1) {
            int v, x;
            cin >> v >> x;
            arr[v-1] = x;
            history[v-1] = updates.size();
        }
        else if(t == 2) {
            int y;
            cin >> y;
            updates.push_back(y);
        }
        else {
            int q;
            cin >> q;
            unsigned count = history[q-1];

            for(unsigned i = count; i < updates.size(); i++)
                arr[q-1] += updates[i];

            history[q-1] = updates.size();
            printf("%d\n", arr[q-1]);
        }
    }
    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main () {

    int n, m;
    cin >> n >> m;

    vector<int> arr(n);
    vector<int> history(n);

    for(int i = 0; i < n; i++)
        cin >> arr[i];

    int shareSumm = 0;
    for(int i = 0; i < m; i++) {
        int t;
        cin >> t;

        if(t == 1) {
            int v, x;
            cin >> v >> x;
            arr[v-1] = x;
            history[v-1] = shareSumm;
        }
        else if(t == 2) {
            int y;
            cin >> y;
            shareSumm += y;
        }
        else {
            int q;
            cin >> q;
            int count = history[q-1];

            arr[q-1] += (shareSumm - count);
            history[q-1] = shareSumm;
            printf("%d\n", arr[q-1]);
        }
    }
    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main () {

	int n, m;
	cin >> n >> m;

	vector<int> arr(n);
	vector<int> a;

	for(int i = 0; i < n; i++)
		cin >> arr[i];

	for(int i = 0; i < m; i++) {
		int t;
		cin >> t;

		if(t == 1) {
			int v, x;
			cin >> v >> x;
			arr[v-1] = x;
		}
		else if(t == 2) {
			int y;
			cin >> y;
			for(int j = 0; j < n; j++)
				arr[j] += y;
		}
		else {
			int q;
			cin >> q;
			printf("%d\n", arr[q-1]);
		}
	}
	return 0;
}


#include <iostream>
#include <string>
#include <cmath>
using namespace std;
int main()
{  int n,m,i,t,v,yi,y=0,x,a[101],j,q; cin>>n>>m;
for(i=1;i<=n;i++)cin>>a[i];
 for(i=1;i<=m;i++){ cin>>t;
 if(t==1) { cin>>v>>x; a[v] =x-y;}
 if(t==2){ cin>>yi; y+=yi; }
 if(t==3){ cin>>q; cout<<a[q]+y<<endl;}
 }
   return 0;
}


#include <iostream>
#include <string>
#include <cmath>
using namespace std;
int main()
{  int n,m,i,t,v,yi,y=0,x,a[100005],q; cin>>n>>m;
for(i=1;i<=n;i++)cin>>a[i];
 for(i=1;i<=m;i++){ cin>>t;
 if(t==1) { cin>>v>>x; a[v] =x-y;}
 if(t==2){ cin>>yi; y+=yi; }
 if(t==3){ cin>>q; cout<<a[q]+y<<endl;}
 }
   return 0;
}


#include<iostream>
#include<vector>
using namespace std;
#define ll long long
vector<ll> v;
int main()
{
	int n, m, choice, i;
	ll a;
	cin >> n >> m;
	for (i = 0; i < n; i++)
	{
		cin >> a;
		v.push_back(a);
	}
	int l = v.size(), add = 0;
	while (m--)
	{
		cin >> choice;
		if(choice==1)
		{
			int index;
		    ll  x;
			cin >> index >> x;
		    v[index - 1] = -add+x;
		}
		if (choice == 2)
		{
			int y;
			cin >> y;
			add += y;
		}
		if (choice == 3)
		{
			int q;
			cin >> q;
			cout << v[q - 1]+add << endl;
		}
	}
	return 0;
}


#include<iostream>
#include<vector>
using namespace std;
#define ll long long
vector<ll> v;
int main()
{
	int n, m, choice, i;
	ll a;
	cin >> n >> m;
	for (i = 0; i < n; i++)
	{
		cin >> a;
		v.push_back(a);
	}
	int l = v.size();
L:while (m--)
	{
		cin >> choice;
		switch (choice)
		{
		case 1:
		{
				  int index;
				  ll  x;
				  cin >> index >> x;
				  v[index - 1] = x;
				  goto L;
		}
		case 2:
		{
				  int y;
				  cin >> y;
				  for (i = 0; i < l; i++)
					  v[i] += y;
				  goto L;
		}
		case 3:
		{
				  int q;
				  cin >> q;
				  cout << v[q - 1] << endl;
		}
		}
	}
	return 0;
}


#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <math.h>

#define FR(i, a, b)   for(int i = a; i < b; i++)
#define FOR(i, a, b)  for(int i = a; i <= b; i++)
#define LFOR(i, a, b) for(int i = a; i >= b; i--)
#define FRSZ(i, x)    for(int i = 0; i < (int)x.size(); i++)
#define RP(i, n)      for(int i = 0; i < n; i++)
#define repeat        do
#define until(x)      while(!(x))

using namespace std;

typedef long long int64;
typedef unsigned long long qword;
typedef long double ldouble;

int64 i,a[1000000],qq,x,y,n,q;

int main()
{
	scanf("%I64d%I64d",&n,&q);
	for(i=1;i<=n;i++)scanf("%I64d",&a[i]);
	qq=0;
	for(i=1;i<=q;i++)
	{
		scanf("%I64d%I64d",&x,&y);
		if(x==1)
		{
			scanf("%I64d",&x);
			a[y]=x-qq;
		}
		else if(x==2)
		{
			qq+=y;
		}
		else printf("%I64d\n",a[y]);
	}
}


#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <math.h>

#define FR(i, a, b)   for(int i = a; i < b; i++)
#define FOR(i, a, b)  for(int i = a; i <= b; i++)
#define LFOR(i, a, b) for(int i = a; i >= b; i--)
#define FRSZ(i, x)    for(int i = 0; i < (int)x.size(); i++)
#define RP(i, n)      for(int i = 0; i < n; i++)
#define repeat        do
#define until(x)      while(!(x))

using namespace std;

typedef long long int64;
typedef unsigned long long qword;
typedef long double ldouble;

int64 i,a[1000000],qq,x,y,n,q;

int main()
{
    scanf("%I64d%I64d",&n,&q);
    for(i=1;i<=n;i++)scanf("%I64d",&a[i]);
    qq=0;
    for(i=1;i<=q;i++)
    {
        scanf("%I64d%I64d",&x,&y);
        if(x==1)
        {
            scanf("%I64d",&x);
            a[y]=x-qq;
        }
        else if(x==2)
        {
            qq+=y;
        }
        else printf("%I64d\n",a[y]+qq);
    }
}


/*
ID: kapitan1
PROG:
LANG: C++
*/
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <string>
using namespace std;
int mas[200000];
int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		cin>>mas[i];
	}
	int total=0;
	for(int i=1;i<=m;i++)
	{
		int x,y,z;
		cin>>x;
		if(x==1)
		{
			cin>>y>>z;
			mas[y]+=z-mas[y]-total;
		}
		else if(x==2)
		{
			cin>>y;
			total+=y;
		}
		else
		{
			cin>>y;
			cout<<mas[y]+total<<endl;
		}
	}
 	return 0;
}


/*
ID: kapitan1
PROG:
LANG: C++
*/
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <string>
using namespace std;
int mas[200000];
int main()
{
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		cin>>mas[i];
	}
	int total=0;
	for(int i=1;i<=m;i++)
	{
		int x,y,z;
		cin>>x;
		if(x==1)
		{
			cin>>y>>z;
			mas[y]+=z-mas[y]-total;
		}
		else if(x==2)
		{
			cin>>y;
			total+=y;
		}
		else
		{
			cin>>y;
			cout<<mas[y]+total<<endl;
		}
	}
 	return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define N 100010
int a[N];
int main(){
	int n,m,i,x,k;
	while(~scanf("%d%d",&n,&m)){
		for(i=0;i<n;i++)scanf("%d",&a[i]);
		x=0;
		while(m--){
		scanf("%d",&k);
		switch(k){
		case 1:
			scanf("%d%d",&i,&k);
			a[i]=k-x;
			break;
		case 2:
			scanf("%d",&k);
			x+=k;
			break;
		case 3:
			scanf("%d",&k);
			printf("%d\n",a[k]+x);
			break;
		}
		}
	}
return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define N 100010
int a[N];
int main(){
	int n,m,i,x,k;
	while(~scanf("%d%d",&n,&m)){
		for(i=0;i<n;i++)scanf("%d",&a[i]);
		x=0;
		scanf("%d",&k);
		switch(k){
		case 1:
			scanf("%d%d",&i,&k);
			a[i]=k-x;
			break;
		case 2:
			scanf("%d",&k);
			x+=k;
			break;
		case 3:
			scanf("%d",&k);
			printf("%d\n",a[k]+x);
			break;
		}
	}
return 0;
}