#include<bits/stdc++.h>
using namespace std;
typedef int wint;
struct cint{
	int num[55];
	cint(){for(int i=0;i<55;i++)num[i]=0;}
	cint operator+(const cint &a){
		cint ret;
		for(int i=0;i<55;i++)ret.num[i]=num[i]+a.num[i];
		return ret;
	}
	cint operator-(const cint &a){
		cint ret;
		for(int i=0;i<55;i++)ret.num[i]=num[i]-a.num[i];
		return ret;
	}
	cint operator-(){
		cint ret;
		for(int i=0;i<55;i++)ret.num[i]=-num[i];
		return ret;
	}
	cint operator*(const int &k){
		cint ret;
		for(int i=0;i<55;i++)ret.num[i]=num[i]*k;
		return ret;
	}
};
inline bool operator<(const cint &a,const cint &b){
	for(int i=0;i<55;i++){
		if(a.num[i]!=b.num[i])return a.num[i]<b.num[i];
	}
	return false;
}
namespace MCF{
	#define MAXN 1000
	#define MAXM 100000
	const wint wEPS=0;
	const wint wINF=1001001001;
	const cint cEPS;
	cint cINF;
	int n,m,ptr[MAXN],next[MAXM],zu[MAXM];
	wint capa[MAXM],tof;
	cint cost[MAXM],toc,d[MAXN],pot[MAXN];
	int vis[MAXN],pree[MAXN];
	void init(int _n){
		cINF.num[0]=100000;
		n=_n;m=0;memset(ptr,~0,n*4);
	}
	void ae(int u,int v,wint w,cint c){
		next[m]=ptr[u];ptr[u]=m;zu[m]=v;capa[m]=w;cost[m]=c;++m;
		next[m]=ptr[v];ptr[v]=m;zu[m]=u;capa[m]=0;cost[m]=-c;++m;
	}
	bool solve(int src,int ink,wint flo=wINF){
		int i,u,v;
		wint f;
		cint c,cc;
		memset(pot,0,n*sizeof(cint));
		for(bool cont=1;cont;){
			cont=0;
			for(u=0;u<n;++u)for(i=ptr[u];~i;i=next[i])if(capa[i]>wEPS){
				if(pot[u]+cost[i]+cEPS<pot[zu[i]]){
					pot[zu[i]]=pot[u]+cost[i];cont=1;
				}
			}
		}
		for(toc=cint(),tof=0;tof+wEPS<flo;){
			typedef pair<cint,int> node;
			priority_queue<node,vector<node>,greater<node> >q;
			for(u=0;u<n;++u){d[u]=cINF;vis[u]=0;}
			for(q.push(make_pair(d[src]=cint(),src));!q.empty();){
				c=q.top().first;u=q.top().second;q.pop();
				if(vis[u]++)continue;
				for(i=ptr[u];~i;i=next[i])if(capa[i]>wEPS){
					cc=c+cost[i]+pot[u]-pot[v=zu[i]];
					if(cc<d[v]){q.push(make_pair(d[v]=cc,v));pree[v]=i;}
				}
			}
			if(!vis[ink])return 0;
			f=flo-tof;
			for(v=ink;v!=src;v=zu[i^1]){i=pree[v];f=min(f,capa[i]);}
			for(v=ink;v!=src;v=zu[i^1]){i=pree[v];capa[i]-=f;capa[i^1]+=f;}
			tof+=f;
			toc=toc+(d[ink]-pot[src]+pot[ink])*f;
			for(u=0;u<n;++u)pot[u]=pot[u]+d[u];
		}
		return 1;
	}
}
char str[100][100];
int main(){
	int a;
	scanf("%d",&a);
	for(int i=0;i<a;i++)scanf("%s",str[i]);
	MCF::init(a*2+2);
	int s=a*2;
	int t=a*2+1;
	for(int i=0;i<a;i++){
		MCF::ae(s,i,1,cint());
		MCF::ae(a+i,t,1,cint());
	}
	for(int i=0;i<a;i++){
		for(int j=0;j<a;j++){
			cint val;
			if('A'<=str[i][j]&&str[i][j]<='Z')val.num[str[i][j]-'A']--;
			else val.num[str[i][j]-'a'+26]--;
			MCF::ae(i,a+j,1,val);
		}
	}
	MCF::solve(s,t,a);
	for(int i=0;i<52;i++){
		for(int j=0;j<-(MCF::toc.num[i]);j++){
			if(i<26)printf("%c",'A'+i);
			else printf("%c",'a'+i-26);
		}
	}
	printf("\n");
}
### Prompt

In cpp, your task is to solve the following problem:

Example

Input

3
aab
czc
baa


Output

aac

### Response

```cpp
#include<bits/stdc++.h>
using namespace std;
typedef int wint;
struct cint{
	int num[55];
	cint(){for(int i=0;i<55;i++)num[i]=0;}
	cint operator+(const cint &a){
		cint ret;
		for(int i=0;i<55;i++)ret.num[i]=num[i]+a.num[i];
		return ret;
	}
	cint operator-(const cint &a){
		cint ret;
		for(int i=0;i<55;i++)ret.num[i]=num[i]-a.num[i];
		return ret;
	}
	cint operator-(){
		cint ret;
		for(int i=0;i<55;i++)ret.num[i]=-num[i];
		return ret;
	}
	cint operator*(const int &k){
		cint ret;
		for(int i=0;i<55;i++)ret.num[i]=num[i]*k;
		return ret;
	}
};
inline bool operator<(const cint &a,const cint &b){
	for(int i=0;i<55;i++){
		if(a.num[i]!=b.num[i])return a.num[i]<b.num[i];
	}
	return false;
}
namespace MCF{
	#define MAXN 1000
	#define MAXM 100000
	const wint wEPS=0;
	const wint wINF=1001001001;
	const cint cEPS;
	cint cINF;
	int n,m,ptr[MAXN],next[MAXM],zu[MAXM];
	wint capa[MAXM],tof;
	cint cost[MAXM],toc,d[MAXN],pot[MAXN];
	int vis[MAXN],pree[MAXN];
	void init(int _n){
		cINF.num[0]=100000;
		n=_n;m=0;memset(ptr,~0,n*4);
	}
	void ae(int u,int v,wint w,cint c){
		next[m]=ptr[u];ptr[u]=m;zu[m]=v;capa[m]=w;cost[m]=c;++m;
		next[m]=ptr[v];ptr[v]=m;zu[m]=u;capa[m]=0;cost[m]=-c;++m;
	}
	bool solve(int src,int ink,wint flo=wINF){
		int i,u,v;
		wint f;
		cint c,cc;
		memset(pot,0,n*sizeof(cint));
		for(bool cont=1;cont;){
			cont=0;
			for(u=0;u<n;++u)for(i=ptr[u];~i;i=next[i])if(capa[i]>wEPS){
				if(pot[u]+cost[i]+cEPS<pot[zu[i]]){
					pot[zu[i]]=pot[u]+cost[i];cont=1;
				}
			}
		}
		for(toc=cint(),tof=0;tof+wEPS<flo;){
			typedef pair<cint,int> node;
			priority_queue<node,vector<node>,greater<node> >q;
			for(u=0;u<n;++u){d[u]=cINF;vis[u]=0;}
			for(q.push(make_pair(d[src]=cint(),src));!q.empty();){
				c=q.top().first;u=q.top().second;q.pop();
				if(vis[u]++)continue;
				for(i=ptr[u];~i;i=next[i])if(capa[i]>wEPS){
					cc=c+cost[i]+pot[u]-pot[v=zu[i]];
					if(cc<d[v]){q.push(make_pair(d[v]=cc,v));pree[v]=i;}
				}
			}
			if(!vis[ink])return 0;
			f=flo-tof;
			for(v=ink;v!=src;v=zu[i^1]){i=pree[v];f=min(f,capa[i]);}
			for(v=ink;v!=src;v=zu[i^1]){i=pree[v];capa[i]-=f;capa[i^1]+=f;}
			tof+=f;
			toc=toc+(d[ink]-pot[src]+pot[ink])*f;
			for(u=0;u<n;++u)pot[u]=pot[u]+d[u];
		}
		return 1;
	}
}
char str[100][100];
int main(){
	int a;
	scanf("%d",&a);
	for(int i=0;i<a;i++)scanf("%s",str[i]);
	MCF::init(a*2+2);
	int s=a*2;
	int t=a*2+1;
	for(int i=0;i<a;i++){
		MCF::ae(s,i,1,cint());
		MCF::ae(a+i,t,1,cint());
	}
	for(int i=0;i<a;i++){
		for(int j=0;j<a;j++){
			cint val;
			if('A'<=str[i][j]&&str[i][j]<='Z')val.num[str[i][j]-'A']--;
			else val.num[str[i][j]-'a'+26]--;
			MCF::ae(i,a+j,1,val);
		}
	}
	MCF::solve(s,t,a);
	for(int i=0;i<52;i++){
		for(int j=0;j<-(MCF::toc.num[i]);j++){
			if(i<26)printf("%c",'A'+i);
			else printf("%c",'a'+i-26);
		}
	}
	printf("\n");
}
```