stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

#define V vector

#define L long

#define W V<L>

L E=70,M=2e17,n,a,b;W S(V<W>p){if(!E){return{1,0};}V<V<W>>T(2);for(W x:p){T[x[1]&1].push_back({x[0]/2,x[1]/2});if(x[0]&1){T[(x[1]+1)&1].push_back({x[0]/2,(x[1]+1)/2});}}for(L i;i<2;i++){L c=0;for(W x:T[!i]){L Q=(2*x[0]+x[1])%3;c^=Q+1;}if(!c){E--;W A=S(T[i]);A[0]*=2;A[1]*=2;A[1]+=i;return A;}}for(W&v:p){v[0]++;}W A=S(p);A[0]--;return A;}int main(){cin>>n;V<W>p(n);while(n--){cin>>a>>b;p[n]={a+M,b+M};}W x=S(p);cout<<x[0]-M<<" "<<x[1]-M;}

// Optimized solution to the same problem (faster):
#include<iostream>

#include<vector>

using namespace std;

#define int long long

#define V vector

#define vel V<int>

#define rep(i,n) for(int i=0;i<n;i++)

#define mkp make_pair

#define pin pair<int,int>

pin solve(V<pin>& ab, int ex) {

	if (!ex) { return mkp(0, 0); }

	V<V<pin>> qab(2);

	int sz = ab.size();

	qab[0].reserve(sz);

	qab[1].reserve(sz);

	for (pin& x : ab) {

		qab[x.second & 1].push_back(mkp(x.first>>1, x.second>>1));

		if (x.first & 1) { qab[(x.second + 1) & 1].push_back(mkp(x.first>>1, (x.second + 1)>>1)); }

	}

	int c = 0;

	for (pin& x : qab[0]) {

		c ^= ((2 * x.first + x.second)%3+1);

	}

	if (!c) {

		pin ans = solve(qab[1], ex - 1);

		ans.first *= 2; ans.second *= 2; ans.second++;

		return ans;

	}

	pin ans = solve(qab[0], ex - 1);

	c = 0;

	int d = 0;

	for (pin& x : qab[1]) {

		int w = ans.second - x.second - 1;

		if ((w & x.first) == w) { c ^= 1; }

		w++;

		if ((w & x.first) == w) { d ^= 1; }

	}

	ans.first *= 2; ans.second *= 2;

	ans.first += (c | d); ans.second -= c;

	return ans;

}

signed main() {

	cin.tie(0); ios::sync_with_stdio(false);

	long long inf = 1e17;

	int n; cin >> n;

	V<pin> ab(n);

	rep(i, n) {

		long long a, b; cin >> a >> b;

		ab[i] = { a + inf,b + inf };

	}

	pin ret = solve(ab, 59);

	cout << ret.first - inf << " " << ret.second - inf << "\n";

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

#define V vector

#define L long

#define W V<L>

L E=70,M=2e17,i,a,b;W S(V<W>p){if(!E){return{1,0};}V<V<W>>T(2);for(W x:p){T[x[1]&1].push_back({x[0]/2,x[1]/2});if(x[0]&1){T[(x[1]+1)&1].push_back({x[0]/2,(x[1]+1)/2});}}for(L i;i<2;i++){L c=0;for(W x:T[!i])c^=(2*x[0]+x[1])%3+1;if(!c){E--;W A=S(T[i]);A[0]*=2;A[1]*=2;A[1]+=i;return A;}}for(W&v:p)v[0]++;W A=S(p);A[0]--;return A;}int main(){cin>>i;V<W>p(i);while(i--,cin>>a>>b)p[i]={a+M,b+M};W x=S(p);cout<<x[0]-M<<" "<<x[1]-M;}

// Optimized solution to the same problem (faster):
#include<iostream>

#include<vector>

using namespace std;

#define int long long

#define V vector

#define vel V<int>

#define rep(i,n) for(int i=0;i<n;i++)

#define mkp make_pair

#define pin pair<int,int>

pin solve(V<pin>& ab, int ex) {

	if (!ex) { return mkp(0, 0); }

	V<V<pin>> qab(2);

	int sz = ab.size();

	qab[0].reserve(sz);

	qab[1].reserve(sz);

	for (pin& x : ab) {

		qab[x.second & 1].push_back(mkp(x.first>>1, x.second>>1));

		if (x.first & 1) { qab[(x.second + 1) & 1].push_back(mkp(x.first>>1, (x.second + 1)>>1)); }

	}

	int c = 0;

	for (pin& x : qab[0]) {

		c ^= ((2 * x.first + x.second)%3+1);

	}

	if (!c) {

		pin ans = solve(qab[1], ex - 1);

		ans.first *= 2; ans.second *= 2; ans.second++;

		return ans;

	}

	pin ans = solve(qab[0], ex - 1);

	c = 0;

	int d = 0;

	for (pin& x : qab[1]) {

		int w = ans.second - x.second - 1;

		if ((w & x.first) == w) { c ^= 1; }

		w++;

		if ((w & x.first) == w) { d ^= 1; }

	}

	ans.first *= 2; ans.second *= 2;

	ans.first += (c | d); ans.second -= c;

	return ans;

}

signed main() {

	cin.tie(0); ios::sync_with_stdio(false);

	long long inf = 1e17;

	int n; cin >> n;

	V<pin> ab(n);

	rep(i, n) {

		long long a, b; cin >> a >> b;

		ab[i] = { a + inf,b + inf };

	}

	pin ret = solve(ab, 59);

	cout << ret.first - inf << " " << ret.second - inf << "\n";

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

#define V vector

#define L long

#define W V<L>

L E=70,M=2e17,i,a,b;W S(V<W>p){if(!E)return{1,0};V<V<W>>T(2);for(W x:p){T[x[1]&1].push_back({x[0]/2,x[1]/2});if(x[0]&1)T[(x[1]+1)&1].push_back({x[0]/2,(x[1]+1)/2});}for(L i;i<2;i++){L c=0;for(W x:T[!i])c^=(2*x[0]+x[1])%3+1;if(!c){E--;W A=S(T[i]);A[0]*=2;A[1]*=2;A[1]+=i;return A;}}for(W&v:p)v[0]++;W A=S(p);A[0]--;return A;}int main(){cin>>i;V<W>p(i);while(i--,cin>>a>>b)p[i]={a+M,b+M};W x=S(p);cout<<x[0]-M<<" "<<x[1]-M;}

// Optimized solution to the same problem (faster):
#include<iostream>

#include<vector>

using namespace std;

#define int long long

#define V vector

#define vel V<int>

#define rep(i,n) for(int i=0;i<n;i++)

#define mkp make_pair

#define pin pair<int,int>

pin solve(V<pin>& ab, int ex) {

	if (!ex) { return mkp(0, 0); }

	V<V<pin>> qab(2);

	int sz = ab.size();

	qab[0].reserve(sz);

	qab[1].reserve(sz);

	for (pin& x : ab) {

		qab[x.second & 1].push_back(mkp(x.first>>1, x.second>>1));

		if (x.first & 1) { qab[(x.second + 1) & 1].push_back(mkp(x.first>>1, (x.second + 1)>>1)); }

	}

	int c = 0;

	for (pin& x : qab[0]) {

		c ^= ((2 * x.first + x.second)%3+1);

	}

	if (!c) {

		pin ans = solve(qab[1], ex - 1);

		ans.first *= 2; ans.second *= 2; ans.second++;

		return ans;

	}

	pin ans = solve(qab[0], ex - 1);

	c = 0;

	int d = 0;

	for (pin& x : qab[1]) {

		int w = ans.second - x.second - 1;

		if ((w & x.first) == w) { c ^= 1; }

		w++;

		if ((w & x.first) == w) { d ^= 1; }

	}

	ans.first *= 2; ans.second *= 2;

	ans.first += (c | d); ans.second -= c;

	return ans;

}

signed main() {

	cin.tie(0); ios::sync_with_stdio(false);

	long long inf = 1e17;

	int n; cin >> n;

	V<pin> ab(n);

	rep(i, n) {

		long long a, b; cin >> a >> b;

		ab[i] = { a + inf,b + inf };

	}

	pin ret = solve(ab, 59);

	cout << ret.first - inf << " " << ret.second - inf << "\n";

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<vector>

#include<bitset>

#include<cstdio>

#include<iostream>

#include<algorithm>

#define pb push_back

#define nc getchar

using namespace std;

inline void read(int &x) {

	char b = nc(); x = 0;

	for (; !isdigit(b); b = nc());

	for (; isdigit(b); b = nc()) x = x * 10 + b - '0';

}

struct Node {

	int x, y, id;	

	inline bool operator<(const Node &o) const {

		return x < o.x || (x == o.x && y < o.y);

	}

} a[100005];

int n, s, t, D, f[100005];

long long ans;

vector < int > g[100005];

bitset < 100005 > vis;

inline int ABS(int x) {return x > 0 ? x : -x;}

inline void ae(int u, int v) {

	g[u].pb(v); g[v].pb(u);	

}

void build(int k) {

	sort(a + 1, a + 1 + n); int i, j, l, r;

	for (i = j = l = r = 1; i <= n; ++i) {

		while (a[l].x < a[i].x - D || (a[l].x == a[i].x - D && a[i].y - a[l].y > k)) ++l;

		while (a[r].x < a[i].x - D || (a[r].x == a[i].x - D && a[r].y - a[i].y <= k)) ++r;

		f[a[i].id] += r - l; j = max(j, l); if (j < r) ae(a[i].id, a[j].id);

		for (; j + 1 < r; ++j) ae(a[j].id, a[j+1].id);

	}

}

void dfs(int u) {

	if (vis[u]) return; vis[u] = 1; ans += f[u];

	for (int i = 0; i < g[u].size(); ++i) dfs(g[u][i]);

}

int main() {

	read(n); read(s); read(t);

	for (int x, y, i = 1; i <= n; ++i)

		read(x), read(y), a[i] = (Node){x + y, x - y, i};

	D = max(ABS(a[s].x - a[t].x), ABS(a[s].y - a[t].y));

	build(D);

	for (int i = 1; i <= n; ++i) swap(a[i].x, a[i].y);

	build(D-1);

	dfs(s);

	printf("%lld\n", ans);

	return 0;

}


// Optimized solution to the same problem (faster):
#include<vector>

#include<bitset>

#include<cstdio>

#include<iostream>

#include<algorithm>

#define pb push_back

#define nc getchar

using namespace std;

inline void read(int &x) {

	char b = nc(); x = 0;

	for (; !isdigit(b); b = nc());

	for (; isdigit(b); b = nc()) x = x * 10 + b - '0';

}

struct Node {

	int x, y, id;	

	inline bool operator<(const Node &o) const {

		return x < o.x || (x == o.x && y < o.y);

	}

} a[100005];

int n, s, t, D, f[100005], fa[100005];

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

long long ans;

bitset < 100005 > vis;

inline int ABS(int x) {return x > 0 ? x : -x;}

inline void ae(int u, int v) {

	if ((u = find(u)) != (v = find(v))) fa[v] = u;

}

void build(int k) {

	sort(a + 1, a + 1 + n); int i, j, l, r;

	for (i = j = l = r = 1; i <= n; ++i) {

		while (a[l].x < a[i].x - D || (a[l].x == a[i].x - D && a[i].y - a[l].y > k)) ++l;

		while (a[r].x < a[i].x - D || (a[r].x == a[i].x - D && a[r].y - a[i].y <= k)) ++r;

		f[a[i].id] += r - l; j = max(j, l); if (j < r) ae(a[i].id, a[j].id);

		for (; j + 1 < r; ++j) ae(a[j].id, a[j+1].id);

	}

}

int main() {

	read(n); read(s); read(t);

	for (int i = 1; i <= n; ++i) fa[i] = i;

	for (int x, y, i = 1; i <= n; ++i)

		read(x), read(y), a[i] = (Node){x + y, x - y, i};

	D = max(ABS(a[s].x - a[t].x), ABS(a[s].y - a[t].y));

	build(D);

	for (int i = 1; i <= n; ++i) swap(a[i].x, a[i].y);

	build(D-1);

	for (int i = 1; i <= n; ++i)

		if (find(i) == find(s)) ans += f[i];

	printf("%lld\n", ans);

	return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <algorithm>

#include <string>

#include <map>

#include <set>

#include <cstdlib>

using namespace std;

map <string,int> cost;

multimap <string,string>  rule;

set <string> his,his2;

int flg;



void update(string a){

  his2.insert(a);

  multimap<string,string>::iterator it=rule.find(a);

  while(it != rule.end() && it->first == a) {

    if(his2.count(it->second)==0&&cost[it->second]>cost[a])cost[it->second] =cost[a],update(it->second);

    it++;

  }

}



int  mk_rule(string a){

  if(his.count(a) == 0){

    his.insert(a);    

    multimap<string,string>::iterator it=rule.find(a);

    while(it != rule.end() && it->first == a) {

      cost[a] = min(cost[a],mk_rule(it->second));

      it++;

    }

    his2.clear();

    update(a);

    it=rule.find(a);

    while(it != rule.end() && it->first == a) {

      if(cost[it->second]  > cost[a])exit(1);

      it++;

    }



  }

  return cost[a];

}



int main(){

  int n,m,b;

  cin >> n;

  string a,c,ls[5002];

  for(int i=0;i<n;i++) {

    cin >> a >> b;

    cost[a] = b , ls[i] = a;

  }

  cin >> m;

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

    cin >> a >> c;

    rule.insert(pair<string,string>(a,c));

    rule.insert(pair<string,string>(c,a));

  }

  int ans=0;

  for(int i=0;i<n;i++) ans += mk_rule(ls[i]);

  cout << ans <<endl;

  return 0;

}

// Optimized solution to the same problem (faster):
#include <iostream>

#include <string>

#include <algorithm>

#include <map>

using namespace std;

map <string,string> mp;

map <string,int> in;



string find(string  x){

  if(mp[x] != x) mp[x] = find(mp[x]);

  return mp[x];

}



void unite(string x,string y){

  x=find(x),y=find(y);

  if(in[x]<in[y]) swap(x,y);

  mp[x] = mp[y];

}



int main() {

  int n,m,a;

  string str,str2;

  cin >> n;

  for(int i=0;i<n;i++) {

    cin >> str >> a;

    in[str] = a;

    mp[str] = str;

  } 



  cin >> m;

  for(int i=0;i<m;i++)cin >> str >> str2,unite(str,str2);



  int ans =0;

  map<string,int> :: iterator it;

  for(it=in.begin();it!=in.end();it++) ans += in[find(it->first)];

  cout << ans <<endl;

  return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <algorithm>

#include <string>

#include <map>

#include <set>

using namespace std;

map <string,int> cost;

multimap <string,string>  rule;

set <string> his,his2;

int flg;



void update(string a){

  his2.insert(a);

  multimap<string,string>::iterator it=rule.find(a);

  while(it != rule.end() && it->first == a) {

    if(his2.count(it->second)==0&&cost[it->second]>cost[a])cost[it->second] =cost[a],update(it->second);

    it++;

  }

}

int  mk_rule(string a){

  if(his.count(a) == 0){

    his.insert(a);    

    multimap<string,string>::iterator it=rule.find(a);

    while(it != rule.end() && it->first == a) {

      cost[a] = min(cost[a],mk_rule(it->second));

      it++;

    }

    his2.clear() , update(a);

  }

  return cost[a];

}



int main(){

  int n,m,b;

  cin >> n;

  string a,c,ls[5002];

  for(int i=0;i<n;i++) {

    cin >> a >> b;

    cost[a] = b , ls[i] = a;

  }

  cin >> m;

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

    cin >> a >> c;

    rule.insert(pair<string,string>(a,c));

    rule.insert(pair<string,string>(c,a));

  }

  int ans=0;

  for(int i=0;i<n;i++) ans += mk_rule(ls[i]);

  cout << ans <<endl;

  return 0;

}

// Optimized solution to the same problem (faster):
#include <iostream>

#include <string>

#include <algorithm>

#include <map>

using namespace std;

map <string,string> mp;

map <string,int> in;



string find(string  x){

  if(mp[x] != x) mp[x] = find(mp[x]);

  return mp[x];

}



void unite(string x,string y){

  x=find(x),y=find(y);

  if(in[x]<in[y]) swap(x,y);

  mp[x] = mp[y];

}



int main() {

  int n,m,a;

  string str,str2;

  cin >> n;

  for(int i=0;i<n;i++) {

    cin >> str >> a;

    in[str] = a;

    mp[str] = str;

  } 



  cin >> m;

  for(int i=0;i<m;i++)cin >> str >> str2,unite(str,str2);



  int ans =0;

  map<string,int> :: iterator it;

  for(it=in.begin();it!=in.end();it++) ans += in[find(it->first)];

  cout << ans <<endl;

  return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <algorithm>

#include <string>

#include <map>

#include <set>

using namespace std;

map <string,int> cost;

multimap <string,string>  rule;

set <string> his;

int mk_rule(string a){

  if(his.count(a) == 0){

    his.insert(a);    

    multimap<string,string>::iterator it=rule.find(a);

    while(it != rule.end() && it->first == a) cost[a]= min(cost[a],mk_rule(it->second)),it++;

  }

  return cost[a];

}



int main(){

  int n,m,b;

  cin >> n;

  string a,c,ls[5002];

  for(int i=0;i<n;i++) cin >> ls[i] >> b, cost[ls[i]] = b;

  

  cin >> m;

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

    cin >> a >> c;

    rule.insert(pair<string,string>(a,c));

    rule.insert(pair<string,string>(c,a));

  }

  int ans=0;

  for(int i=0;i<n;i++)his.clear(), ans += mk_rule(ls[i]);

  cout << ans <<endl;

  return 0;

}

// Optimized solution to the same problem (faster):
#include <iostream>

#include <string>

#include <algorithm>

#include <map>

using namespace std;

map <string,string> mp;

map <string,int> in;



string find(string  x){

  if(mp[x] != x) mp[x] = find(mp[x]);

  return mp[x];

}



void unite(string x,string y){

  x=find(x),y=find(y);

  if(in[x]<in[y]) swap(x,y);

  mp[x] = mp[y];

}



int main() {

  int n,m,a;

  string str,str2;

  cin >> n;

  for(int i=0;i<n;i++) {

    cin >> str >> a;

    in[str] = a;

    mp[str] = str;

  } 



  cin >> m;

  for(int i=0;i<m;i++)cin >> str >> str2,unite(str,str2);



  int ans =0;

  map<string,int> :: iterator it;

  for(it=in.begin();it!=in.end();it++) ans += in[find(it->first)];

  cout << ans <<endl;

  return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <algorithm>

#include <string>

#include <map>

#include <set>

using namespace std;

map <string,int> cost;

multimap <string,string>  rule;

set <string> his;

int mk_rule(string a,int mae){

  if(his.count(a) == 0||cost[a]>mae){

    his.insert(a);    

    multimap<string,string>::iterator it=rule.find(a);

    while(it != rule.end() && it->first == a) cost[a]= min(cost[a],mk_rule(it->second,cost[a])),it++;

    it=rule.find(a);

    while(it != rule.end() && it->first == a) cost[a]= min(cost[a],mk_rule(it->second,cost[a])),it++;

  }

  return cost[a];

}

int main(){

  int n,m,b;

  cin >> n;

  string a,c,ls[5002];

  for(int i=0;i<n;i++) cin >> ls[i] >> b, cost[ls[i]] = b;



  cin >> m;

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

    cin >> a >> c;

    rule.insert(pair<string,string>(a,c));

    rule.insert(pair<string,string>(c,a));

  }

  int ans=0;

  for(int i=0;i<n;i++) ans += mk_rule(ls[i],cost[ls[i]]);

  cout << ans <<endl;

  return 0;

}

// Optimized solution to the same problem (faster):
#include <iostream>

#include <string>

#include <algorithm>

#include <map>

using namespace std;

map <string,string> mp;

map <string,int> in;



string find(string  x){

  if(mp[x] != x) mp[x] = find(mp[x]);

  return mp[x];

}



void unite(string x,string y){

  x=find(x),y=find(y);

  if(in[x]<in[y]) swap(x,y);

  mp[x] = mp[y];

}



int main() {

  int n,m,a;

  string str,str2;

  cin >> n;

  for(int i=0;i<n;i++) {

    cin >> str >> a;

    in[str] = a;

    mp[str] = str;

  } 



  cin >> m;

  for(int i=0;i<m;i++)cin >> str >> str2,unite(str,str2);



  int ans =0;

  map<string,int> :: iterator it;

  for(it=in.begin();it!=in.end();it++) ans += in[find(it->first)];

  cout << ans <<endl;

  return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <algorithm>

#include <string>

#include <map>

#include <set>

using namespace std;

map <string,int> cost;

multimap <string,string>  rule;

set <string> his;

void update(string a){

  multimap<string,string>::iterator it=rule.find(a);

  while(it != rule.end() && it->first == a) {

    if(cost[it->second]>cost[a])cost[it->second]=cost[a], update(it->second);

    it++;

  }

}

int mk_rule(string a){

  if(his.count(a) == 0){

    his.insert(a);    

    multimap<string,string>::iterator it=rule.find(a);

    while(it != rule.end() && it->first == a) cost[a]= min(cost[a],mk_rule(it->second)),it++;

    update(a);

  }

  return cost[a];

}

int main(){

  int n,m,b;

  cin >> n;

  string a,c,ls[5002];

  for(int i=0;i<n;i++) cin >> ls[i] >> b, cost[ls[i]] = b;



  cin >> m;

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

    cin >> a >> c;

    rule.insert(pair<string,string>(a,c));

    rule.insert(pair<string,string>(c,a));

  }

  int ans=0;

  for(int i=0;i<n;i++) ans += mk_rule(ls[i]);

  cout << ans <<endl;

  return 0;

}

// Optimized solution to the same problem (faster):
#include <iostream>

#include <string>

#include <algorithm>

#include <map>

using namespace std;

map <string,string> mp;

map <string,int> in;



string find(string  x){

  if(mp[x] != x) mp[x] = find(mp[x]);

  return mp[x];

}



void unite(string x,string y){

  x=find(x),y=find(y);

  if(in[x]<in[y]) swap(x,y);

  mp[x] = mp[y];

}



int main() {

  int n,m,a;

  string str,str2;

  cin >> n;

  for(int i=0;i<n;i++) {

    cin >> str >> a;

    in[str] = a;

    mp[str] = str;

  } 



  cin >> m;

  for(int i=0;i<m;i++)cin >> str >> str2,unite(str,str2);



  int ans =0;

  map<string,int> :: iterator it;

  for(it=in.begin();it!=in.end();it++) ans += in[find(it->first)];

  cout << ans <<endl;

  return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

using namespace std;



#define INF 2147483647

#define ASTART (1<<17)

int a[1<<18][2];

int ti=1;



int find(int i){

  int nv=INF,t=0;

  i+=ASTART-1;

  nv=a[i][0];

  t=a[i][1];

  while (i>0){

    i=(i-1)/2;

    if (t<a[i][1])nv=a[i][0],t=a[i][1];

    //cout << i << " = " << a[i][0]<< " = " << a[i][1]<< endl;

  }

  return nv;

}

void update(int s,int t,int x,int k,int l,int r){

  if (l>=s&&r<=t){

    a[k][0]=x;

    a[k][1]=ti;

    return;

  }

  if (r<=s||l>=t)return;

  int m=(l+r)/2;

  update(s,t,x,k*2+1,l,m);

  update(s,t,x,k*2+2,m,r);

}

int main(){

  int n,q,com,s,t,x;

  for (int i=0;i<(1<<18);i++)a[i][0]=INF,a[i][1]=0;

  cin >> n>>q;



  for (int i=0;i<q;i++){

    cin >> com;

    if (com==0) {

      cin >> s >> t >> x;

      update(s,t+1,x,0,0,ASTART);

      ti++;

    }else {

      cin >> s;

      cout << find(s)<< endl;

    }

    //for (int i=0;i<5;i++)cout << a[i] << endl;

    //cout << a[ASTART];

  }



  return 0;

}

// Optimized solution to the same problem (faster):
#include <iostream>

using namespace std;



#define INF (1 << 30) - 1 + (1 << 30)



int a[262144], n2, lazy[262144];



void lazyeval(int i) {

  if (lazy[i] == INF) return;

  a[i] = lazy[i];

  if (i < n2 - 1) {

    lazy[2 * i + 1] = lazy[2 * i + 2] = lazy[i];

  }

  lazy[i] = INF;

}



int findsingle(int i) {

  int j = i + n2 - 1;

  int val = a[i + n2 - 1];

  if (lazy[j] != INF) val = lazy[j];

  while (j > 0) {

    j = (j - 1) / 2;

    if (lazy[j] != INF) val = lazy[j];

  }



  return val;

}



void updaterange(int s, int t, int i, int l, int r, int x) {

  lazyeval(i);

  // cout << s << " " << t << " " << i << " " << l << " " << r << endl;

  if (s <= l && r <= t) {

    a[i] = x;

    if (i < n2 - 1) {

      lazy[2 * i + 1] = lazy[2 * i + 2] = a[i];

    }

    return;

  }

  if (t <= l || r <= s) return;

  updaterange(s, t, i * 2 + 1, l, (l + r) / 2, x);

  updaterange(s, t, i * 2 + 2, (l + r) / 2, r, x);



  a[i] = min(a[i * 2 + 1], a[i * 2 + 2]);

}



int main() {

  int n, q, com, s, t, x;



  cin >> n >> q;

  n2 = 1;

  while (n > n2) n2 *= 2;

  for (int i = 0; i < n2 * 2; i++) a[i] = lazy[i] = INF;



  for (int i = 0; i < q; i++) {

    cin >> com >> s;

    if (com == 0) {

      cin >> t >> x;

      updaterange(s, t + 1, 0, 0, n2, x);

    } else

      cout << findsingle(s) << endl;

  }

  return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;



const int N = 55;



string s[N];

int cnt[26];



int main() {

  ios::sync_with_stdio(false);

  cin.tie(nullptr);

  int n; cin >> n;

  for (int i = 0; i < n; i++) {

    cin >> s[i];

  }

  for (int i = 0; i < (int)s[0].size(); i++) {

    cnt[s[0][i] - 'a']++;

  }

  for (int i = 1; i < n; i++) {

    int curcnt[26];

    for (int j = 0; j < 26; j++) curcnt[j] = 0;

    for (int j = 0; j < (int)s[i].size(); j++) {

      curcnt[s[i][j] - 'a']++;

    }

    for (int j = 0; j < 26; j++) {

      cnt[j] = min(cnt[j], curcnt[j]);

    }

  }

  vector<char> v;

  for (int i = 0; i < 26; i++) {

    for (int j = 0; j < cnt[i]; j++) {

      v.push_back(i + 'a');

    }

  }

  sort(v.begin(), v.end());

  for (char c : v) cout << c;

  cout << endl;

  return 0;

}


// Optimized solution to the same problem (faster):
#include       <set>

#include       <map>

#include     <queue>

#include     <cmath>

#include    <cstdio>

#include    <cctype>

#include    <vector>

#include   <cstring>

#include <algorithm>

using namespace std;



typedef long long ll;

const ll mod = 1e9+7;

const double eps = 1e-7;

const int maxn = 1e5+5;



ll fast_pow(ll a,ll b,ll mod){

    ll ans = 1;

    while(b){

        if(b&1)

            ans = ans*a%mod;

        a = a*a%mod;

        b>>=1;

    }

    return ans;

}

int a[127];

int c[127];

int main(){

    int n;

    char str[55];

    scanf("%d",&n);

    memset(c,0x3f,sizeof(c));

    for(int i=0;i<n;i++){

        scanf("%s",str);

        memset(a,0,sizeof(a));

        for(int j=0;str[j];j++)

            a[str[j]]++;

        for(int j='a';j<='z';j++)

            c[j] = min(c[j],a[j]);

    }

    for(int j='a';j<='z';j++)

        while(c[j])putchar(j),c[j]--;

}



/*



1592794101

989097785





232162543



*/


// Fastest known solution for this problem: