#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<map>
#include<vector>
#include<deque>
using namespace std;
string ans="";
int main(){
  int u4=0,u7=0;
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(abs(c-d)>1){
    printf("-1\n"); return 0;
  }
  if(c>d) for(int i=0;i<c;i++)u4++,u7++,ans+="47";
  if(c==d) {
    for(int i=0;i<c;i++)u4++,u7++,ans+="47";
    ans+="4";
    u4++;
  }
  if(d>c) for(int i=0;i<d;i++)u4++,u7++,ans+="74";
  int n4=a-u4,n7=b-u7;
  if(n4<0||n7<0){
    printf("-1\n");
    return 0;
  }
  string a4="",a7="";
  for(int i=0;i<n4;i++)a4+="4";
  for(int i=0;i<n7;i++)a7+="7";
  bool found4=0,found7=0;
  for(int i=0;i<ans.length();i++){
    if(!found4&&ans[i]=='4'){
      cout<<a4;
      found4=1;
    }
    if(!found7&&ans[i]=='7'){
      cout<<a7;
      found7=1;
    }
    cout<<ans[i];
  }
  cout<<"\n";
  return 0;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<map>
#include<vector>
#include<deque>
using namespace std;
string ans="",ans1="";
bool use1=false;
int find4(){
  for(int i=0;i<ans.length();i++)
    if(ans[i]=='4') return i;
}
int find7(){
  for(int i=ans.length();i>=0;i--)
    if(ans[i]=='7') return i;
}
int main(){
  int u4=0,u7=0;
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(abs(c-d)>1){
    printf("-1\n"); return 0;
  }
  if(c>d) for(int i=0;i<c;i++)u4++,u7++,ans+="47";
  if(c==d) {
    for(int i=0;i<c;i++)u4++,u7++,ans+="47",ans1+="74";
    ans+="4";
    ans1+="7";
  }
  if(d>c) for(int i=0;i<d;i++)u4++,u7++,ans+="74";
  int n4=a-u4,n7=b-u7;
  bool ok=false;
  if(c==d){
    if(n4-1>=0 && n7>=0){
      ok=true;
      n4--;
    }else if(n4>=0 && n7-1>=0){
      n7--;
      ok=true;
      use1=1;
    }
  }
  if(c!=d && (n4<0||n7<0) ){
    printf("-1\n");
    return 0;
  }
  if(use1)ans=ans1;
  string a4="",a7="";
  for(int i=0;i<n4;i++)a4+="4";
  for(int i=0;i<n7;i++)a7+="7";
  bool found4=0,found7=0;
  int pos4=find4(),pos7=find7();
  for(int i=0;i<ans.length();i++){
    cout<<ans[i];
    if(i==pos4)cout<<a4;
    if(i==pos7)cout<<a7;
  }
  cout<<"\n";
  return 0;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<map>
#include<vector>
#include<deque>
using namespace std;
string ans="";
int find4(){
  for(int i=0;i<ans.length();i++)
    if(ans[i]=='4') return i;
}
int find7(){
  for(int i=ans.length();i>=0;i--)
    if(ans[i]=='7') return i;
}
int main(){
  int u4=0,u7=0;
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(abs(c-d)>1){
    printf("-1\n"); return 0;
  }
  if(c>d) for(int i=0;i<c;i++)u4++,u7++,ans+="47";
  if(c==d) {
    for(int i=0;i<c;i++)u4++,u7++,ans+="47";
    ans+="4";
    u4++;
  }
  if(d>c) for(int i=0;i<d;i++)u4++,u7++,ans+="74";
  int n4=a-u4,n7=b-u7;
  if(n4<0||n7<0){
    printf("-1\n");
    return 0;
  }
  string a4="",a7="";
  for(int i=0;i<n4;i++)a4+="4";
  for(int i=0;i<n7;i++)a7+="7";
  bool found4=0,found7=0;
  int pos4=find4(),pos7=find7();
  for(int i=0;i<ans.length();i++){
    cout<<ans[i];
    if(i==pos4)cout<<a4;
    if(i==pos7)cout<<a7;
  }
  cout<<"\n";
  return 0;
}


#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<map>
#include<vector>
#include<deque>
using namespace std;
string ans="",ans1="";
bool use1=false;
int find4(){
  for(int i=0;i<ans.length();i++)
    if(ans[i]=='4') return i;
}
int find7(){
  for(int i=ans.length();i>=0;i--)
    if(ans[i]=='7') return i;
}
int main(){
  int u4=0,u7=0;
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(abs(c-d)>1){
    printf("-1\n"); return 0;
  }
  if(c>d) for(int i=0;i<c;i++)u4++,u7++,ans+="47";
  if(c==d) {
    for(int i=0;i<c;i++)u4++,u7++,ans+="47",ans1+="74";
    ans+="4";
    ans1+="7";
  }
  if(d>c) for(int i=0;i<d;i++)u4++,u7++,ans+="74";
  int n4=a-u4,n7=b-u7;
  bool ok=false;
  if(c==d){
    if(n4-1>=0 && n7>=0){
      ok=true;
      n4--;
    }else if(n4>=0 && n7-1>=0){
      n7--;
      ok=true;
      use1=1;
    }
    if(!ok){
      printf("-1\n");
      return 0;
    }
  }
  if(n4<0||n7<0){
    printf("-1\n");
    return 0;
  }
  if(use1)ans=ans1;
  string a4="",a7="";
  for(int i=0;i<n4;i++)a4+="4";
  for(int i=0;i<n7;i++)a7+="7";
  bool found4=0,found7=0;
  int pos4=find4(),pos7=find7();
  for(int i=0;i<ans.length();i++){
    cout<<ans[i];
    if(i==pos4)cout<<a4;
    if(i==pos7)cout<<a7;
  }
  cout<<"\n";
  return 0;
}


	#include <cstdio>
	#include <iostream>
	#include <vector>
	#include <set>
	#include <queue>
	#include <cmath>
	#include <string>
	#include <algorithm>
	using namespace std;
	int a1,a2,a3,a4;
	string root,ans;
	string first,second;
	int abs_(int a){
	 return a<0?-a:a;
	}
	int solve(){
	int a5=a1,a6=a2;
	for(int i=0;i<max(a3,a4);i++)
	{
	 root+=first;
	 if(i<a4)root+=second;
	}
	if(root.size()!=0)ans=root[0];
	for(int i=1;i<root.size();i++)
	 if(root[i-1]!=root[i])ans+=root[i];
	for(int i=0;i<ans.size();i++){
	 if(ans[i]=='4')a5--;
	 if(ans[i]=='7')a6--;
	}
	 if(a5<0 || a6<0){
		return -1; return 0;
	 }
     a1 = a5;
     a2 = a6;
     return 0;
	}
    int main()
	{
	 int c4,c7,ret;
	 cin >> a1 >> a2 >> a3 >> a4;
	 if(abs_(a3-a4)>1){ cout << -1 << endl; return 0;}
	 if(a1>0 && a2>0 && a3==0 && a4==0){ cout << -1 << endl; return 0;}
	 if(a3>a4){
		first = "47"; second = "74";
	  ret = solve();
      if(ret==-1){ cout << -1 << endl; return 0;
      }
     }else if(a3==a4){
		first = "47"; second = "74";
	    ret = solve();
        if(ret==-1){ first = "74"; second = "47";swap(a3,a4); root="";ret = solve();
        if(ret==-1){cout << -1 << endl; return 0;}}
        }
	 else{
		first = "74"; second = "47";
	swap(a3,a4);
    ret = solve();
    if(ret==-1){ cout << -1 << endl; return 0;}
    }

	int in4=0,in7=0;
	for(int i=0;i<ans.size();i++)
	 if(ans[i]=='4'){in4=i; break;}
	for(int i=ans.size()-1;i>=0;i--)
	 if(ans[i]=='7'){in7=i; break;}

	if(ans.size()!=0){

	 for(int i=0;i<ans.size();i++){
	 cout << ans[i];
	 if(i==in4)
		while(a1>0){cout << 4;a1--;}
	 if(i==in7)
		while(a2>0){cout << 7;a2--;}
	}
	}else{
	while(a1>0){cout << 4;a1--;}
	while(a2>0){cout << 7;a2--;}

	}
	cout << endl;
	}


	#include <cstdio>
	#include <iostream>
	#include <vector>
	#include <set>
	#include <queue>
	#include <cmath>
	#include <string>
	#include <algorithm>
	using namespace std;
	int a1,a2,a3,a4;
	string root,ans;
	string first,second;
	int abs_(int a){
	 return a<0?-a:a;
	}
	int main()
	{
	 int c4,c7;
	 cin >> a1 >> a2 >> a3 >> a4;
	 if(abs_(a3-a4)>1){ cout << -1 << endl; return 0;}
	if(a1>0 && a2>0 && a3==0 && a4==0){ cout << -1 << endl; return 0;}
	 if(a3>a4){
		first = "47"; second = "74";
	 }else if(a3==a4){
		if(a1>1){first = "47"; second = "74";}
	    else {
	     first = "74"; second = "47"; swap(a3,a4);
	    }
	 }else{
		first = "74"; second = "47";
	swap(a3,a4); }

	for(int i=0;i<max(a3,a4);i++)
	{
	 root+=first;
	 if(i<a4)root+=second;
	}
	if(root.size()!=0)ans=root[0];
	for(int i=1;i<root.size();i++)
	 if(root[i-1]!=root[i])ans+=root[i];
	for(int i=0;i<ans.size();i++){
	 if(ans[i]=='4')a1--;
	 if(ans[i]=='7')a2--;
	}
	 if(a1<0 || a2<0){
		cout << -1 << endl; return 0;
	 }
	int in4=0,in7=0;
	for(int i=0;i<ans.size();i++)
	 if(ans[i]=='4'){in4=i; break;}
	for(int i=ans.size()-1;i>=0;i--)
	 if(ans[i]=='7'){in7=i; break;}

	if(ans.size()!=0){

	 for(int i=0;i<ans.size();i++){
	 cout << ans[i];
	 if(i==in4)
		while(a1>0){cout << 4;a1--;}
	 if(i==in7)
		while(a2>0){cout << 7;a2--;}
	}
	}else{
	while(a1>0){cout << 4;a1--;}
	while(a2>0){cout << 7;a2--;}

	}
	cout << endl;
	}


#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
int a1,a2,a3,a4;
string root,ans;
string first,second;
int abs_(int a){
 return a<0?-a:a;
}
int main()
{
 int c4,c7;
 cin >> a1 >> a2 >> a3 >> a4;
 if(abs_(a3-a4)>1){ cout << -1 << endl; return 0;}
if(a1>0 && a2>0 && a3==0 && a4==0){ cout << -1 << endl; return 0;}
 if(a3>=a4){
	first = "47"; second = "74";
 }else{
	first = "74"; second = "47";
swap(a3,a4); }

for(int i=0;i<max(a3,a4);i++)
{
 root+=first;
 if(i<a4)root+=second;
}
if(root.size()!=0)ans=root[0];
for(int i=1;i<root.size();i++)
 if(root[i-1]!=root[i])ans+=root[i];
for(int i=0;i<ans.size();i++){
 if(ans[i]=='4')a1--;
 if(ans[i]=='7')a2--;
}
 if(a1<0 || a2<0){
	cout << -1 << endl; return 0;
 }
int in4=0,in7=0;
for(int i=0;i<ans.size();i++)
 if(ans[i]=='4'){in4=i; break;}
for(int i=ans.size()-1;i>=0;i--)
 if(ans[i]=='7'){in7=i; break;}

if(ans.size()!=0){

 for(int i=0;i<ans.size();i++){
 cout << ans[i];
 if(i==in4)
	while(a1>0){cout << 4;a1--;}
 if(i==in7)
	while(a2>0){cout << 7;a2--;}
}
}else{
while(a1>0){cout << 4;a1--;}
while(a2>0){cout << 7;a2--;}

}
cout << endl;
}


	#include <cstdio>
	#include <iostream>
	#include <vector>
	#include <set>
	#include <queue>
	#include <cmath>
	#include <string>
	#include <algorithm>
	using namespace std;
	int a1,a2,a3,a4;
	string root,ans;
	string first,second;
	int abs_(int a){
	 return a<0?-a:a;
	}
	int main()
	{
	 int c4,c7;
	 cin >> a1 >> a2 >> a3 >> a4;
	 if(abs_(a3-a4)>1){ cout << -1 << endl; return 0;}
	if(a1>0 && a2>0 && a3==0 && a4==0){ cout << -1 << endl; return 0;}
	 if(a3>a4){
		first = "47"; second = "74";
	 }else if(a3==a4){
		if(a1>=a2){first = "47"; second = "74";}
	    else {
	     first = "74"; second = "47"; swap(a3,a4);
	    }
	 }else{
		first = "74"; second = "47";
	swap(a3,a4); }

	for(int i=0;i<max(a3,a4);i++)
	{
	 root+=first;
	 if(i<a4)root+=second;
	}
	if(root.size()!=0)ans=root[0];
	for(int i=1;i<root.size();i++)
	 if(root[i-1]!=root[i])ans+=root[i];
	for(int i=0;i<ans.size();i++){
	 if(ans[i]=='4')a1--;
	 if(ans[i]=='7')a2--;
	}
	 if(a1<0 || a2<0){
		cout << -1 << endl; return 0;
	 }
	int in4=0,in7=0;
	for(int i=0;i<ans.size();i++)
	 if(ans[i]=='4'){in4=i; break;}
	for(int i=ans.size()-1;i>=0;i--)
	 if(ans[i]=='7'){in7=i; break;}

	if(ans.size()!=0){

	 for(int i=0;i<ans.size();i++){
	 cout << ans[i];
	 if(i==in4)
		while(a1>0){cout << 4;a1--;}
	 if(i==in7)
		while(a2>0){cout << 7;a2--;}
	}
	}else{
	while(a1>0){cout << 4;a1--;}
	while(a2>0){cout << 7;a2--;}

	}
	cout << endl;
	}


#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
char S[2000002];
int main()
{
    int a1,a2,a3,a4;
    char s1[]="47",s2[]="74";
    while(cin>>a1>>a2>>a3>>a4)
    {
        memset(S,0,sizeof(S));
        int i,j;
        for(i=0; i<a1; i++)
        {
            S[i]='4';
        }
        for(j=i; j<a1+a2; j++)
        {
            S[j]='7';
        }
        int m,n;
        char* str1;
        do
        {
            str1=S;
            m=0,n=0;

            str1=S;
            while (str1 = strstr(str1, s2))
            {
                n++;
                str1 += 2;
            }
            if(m==a3&&n==a4)
            {
                cout<<S<<endl;
                break;
            }
        }
        while(next_permutation(S,S+a1+a2));
        if(m!=a3||n!=a4)
            cout<<-1<<endl;
    }
    return 0;
}


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

int main(){
	int n4, n7, n47, n74;
	bool flag = true;
	string ans;
	ans.clear();
	cin >>n4 >>n7 >>n47 >>n74;
	//cout<<n4 <<' ' <<n7 <<' ' <<n47 << ' ' <<n74 <<endl;
	if((n4==0 && (n47||n74))||n4<n47||n7<n47){
		cout <<-1;
		//cout <<"h1";
		return 0;
	}
	int cur = 0;
	int front7=0;

	for(int i=0; i<n47; i++){
		ans += "47";
		n4--, n7--;
		if(i>0) n74--;
		if(n74<0) {
			flag=false;
		//	cout <<"here";
			break;
		}

	}

	if(flag){

		if(n74==0){
			for(int i=0; i<n7; i++)
				ans.push_back('7');
			string tmp;
			for(int i=0; i<n4; i++){

			    tmp.clear();

				tmp.push_back('4');
			}
			ans = tmp+ans;
		}
		else if(n74>0 && n74<=2 &&n4>0){
			if(n74>1) n7--;
			for(int i=0; i<n7; i++)
				ans.push_back('7');
			ans.push_back('4');
			n4--;

			string tmp;
			for(int i=0; i<n4; i++){

			    tmp.clear();

				tmp.push_back('4');
			}
			ans=tmp+ans;
			if(n74>1){
				ans.insert(0, 1, '7');
			}
		}
		else flag = false;
	}

	if(!flag) cout <<-1;
	else cout <<ans;

	return 0;
}


#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int M =2000002;
char S[M];
int main()
{
    int a1,a2,a3,a4;
    while(cin>>a1>>a2>>a3>>a4)
    {
        memset(S,0,sizeof(S));

        int i,j;
        for(i=0; i<a1; i++)
        {
            S[i]='4';

        }
        for(j=i; j<a1+a2; j++)
        {
            S[j]='7';
        }
        int m,n;
        do
        {
            m=0;
            n=0;
            for(i=0,j=0; i+1<(a1+a2); i++)
            {
                if(S[i]==S[i+1])
                    continue;

                if(S[i]=='4'&&S[i+1]=='7')
                        m++;
                else if(S[i]=='7'&&S[i+1]=='4')
                        n++;
                    j++;

            }
            if(m==a3&&n==a4)
            {
                cout<<S<<endl;
                break;
            }
        }
        while(next_permutation(S,S+a1+a2));
        if(m!=a3||n!=a4)
            cout<<-1<<endl;
    }
    return 0;
}


#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
const int M =2000002;
char S[M],B[M][3];
int main()
{
    int a1,a2,a3,a4;
    char s1[]="47",s2[]="74";
    while(cin>>a1>>a2>>a3>>a4)
    {
        memset(S,0,sizeof(S));
        memset(B,0,sizeof(B));
        int i,j;
        for(i=0; i<a1; i++)
        {
            S[i]='4';
        }
        for(j=i; j<a1+a2; j++)
        {
            S[j]='7';
        }
        int m,n;
        do
        {
            m=0;
            n=0;
            for(i=0,j=0; i+1<(a1+a2); i++)
            {
                if(S[i]==S[i+1])
                    continue;
                else
                {
                    B[j][0]=S[i];
                    B[j][1]=S[i+1];

                    if(strcmp(B[j],s1)==0)
                        m++;
                    if(strcmp(B[j],s2)==0)
                        n++;
                    j++;
                }
            }
            if(m==a3&&n==a4)
            {
                cout<<S<<endl;
                break;
            }
        }
        while(next_permutation(S,S+a1+a2));
        if(m!=a3||n!=a4)
            cout<<-1<<endl;
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
using namespace std;
int a,b,c,d;
string s;
bool solve()
{
    if(abs(c-d)>1)return false;
    if(c==d)
    {
        if(a>c&&b>=d)
        {
            for(int i=0;i<a-(c+1);i++)s=s+'4';
        for(int i=0;i<c;i++){s=s+'4';s=s+'7';}
            for(int i=0;i<b-c;i++)s=s+'7';
            s=s+'4';
            cout<<s<<endl;return true;
        }
        else if(a==c&&b>d)
        {
            s=s+'7';
            for(int i=0;i<c;i++){s=s+'4';s=s+'7';}
            for(int i=0;i<b-c-1;i++)s=s+'7';
            cout<<s<<endl;return true;
        }
        else
            return false;
    }
    else if(c>d)
    {
        if(a>=c&&b>=c){
            for(int i=0;i<a-c;i++)s=s+'4';
        for(int i=0;i<c;i++){s=s+'4';s=s+'7';}
            for(int i=0;i<b-c;i++)s=s+'7';
            cout<<s<<endl;
            return true;
        }
        else
            return false;
    }
    else if(d>c)
    {
        if(a>=d&&b>=d){
            s=s+'7';
            for(int i=0;i<a-(c+1);i++)s=s+'4';
        for(int i=0;i<c;i++){s=s+'4';s=s+'7';}
            for(int i=0;i<b-(1+c);i++)s=s+'7';
            s=s+'4';
            cout<<s<<endl;return true;
        }
        return false;
    }

    return false;
}
int main()
{
    cin>>a>>b>>c>>d;
    s="";
    if(!solve())cout<<"-1\n";
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
using namespace std;
int a,b,c,d;
char s[2000010];
int k;
bool solve()
{
    if(abs(c-d)>1)return false;
    if(c==d)
    {
        if(a>c&&b>=d)
        {
        //cout<<"Yes\n";
            for(int i=0;i<a-(c+1);i++)s[k++]='4';
        for(int i=0;i<c;i++){s[k++]='4';s[k++]='7';}
            for(int i=0;i<b-c;i++)s[k++]='7';
            s[k++]='4';
            s[k]='\0';printf("%s\n",s);return true;
        }
        else if(a==c&&b>d)
        {

            s[k++]='7';
            for(int i=0;i<c;i++){s[k++]='4';s[k++]='7';}
            for(int i=0;i<b-c-1;i++)s[k++]='7';
            s[k]='\0';printf("%s\n",s);return true;
        }
        else
            return false;
    }
    else if(c>d)
    {
        if(a>=c&&b>=c){
            for(int i=0;i<a-c;i++)s[k++]='4';
        for(int i=0;i<c;i++){s[k++]='4';s[k++]='7';}
            for(int i=0;i<b-c;i++)s[k++]='7';
            s[k]='\0';printf("%s\n",s);
            return true;
        }
        else
            return false;
    }
    else if(d>c)
    {
        if(a>=d&&b>=d){
            s[k++]='7';
            for(int i=0;i<a-(c+1);i++)s[k++]='4';
        for(int i=0;i<c;i++){s[k++]='4';s[k++]='7';}
            for(int i=0;i<b-(1+c);i++)s[k++]='7';
            s[k++]='4';
            s[k]='\0';printf("%s\n",s);return true;
        }
        return false;
    }

    return false;
}
int main()
{
    cin>>a>>b>>c>>d;

    if(!solve())cout<<"-1\n";
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
using namespace std;
int m4,m7;
bool  recure(int a,int b,int c,int d,int l,string s)
{

//    getchar();
//cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<s<<endl;
    if(!a&&!b&&!c&&!d){cout<<s<<endl;return true;}
    if(a<d)return false;
    if(b<c)return false;

    if(a)
    {
        if(l==7){if(recure(a-1,b,c,d-1,4,s+"4"))return true;}
            else if(recure(a-1,b,c,d,4,s+"4"))return true;
    }
    if(b)
    {
        if(l==4){if(recure(a,b-1,c-1,d,7,s+"7"))return true;}
            else if(recure(a,b-1,c,d,7,s+"7"))return true;
    }
    return false;
}
int main()
{
    int a,b,c,d;
    string s;
    while(cin>>a>>b>>c>>d)
    {
    s="";
        bool first,sec;
        first=sec=false;
        if(a&&recure(a-1,b,c,d,4,"4"))continue;
        else if(b&&recure(a,b-1,c,d,7,"7"))continue;
        else cout<<-1<<endl;
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
using namespace std;
int m4,m7;
bool  recure(int a,int b,int c,int d,int l,string s)
{

//    getchar();
//cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<s<<endl;
if(c<0||d<0)return false;
    if(!a&&!b&&!c&&!d){cout<<s<<endl;return true;}
    if(a<d)return false;
    if(b<c)return false;

    if(a)
    {
        if(l==7){if(recure(a-1,b,c,d-1,4,s+"4"))return true;}
            else if(recure(a-1,b,c,d,4,s+"4"))return true;
    }
    if(b)
    {
        if(l==4){if(recure(a,b-1,c-1,d,7,s+"7"))return true;}
            else if(recure(a,b-1,c,d,7,s+"7"))return true;
    }
    return false;
}
int main()
{
    int a,b,c,d;
    string s;
    while(cin>>a>>b>>c>>d)
    {
    s="";
        bool first,sec;
        first=sec=false;
        if(a&&recure(a-1,b,c,d,4,"4"))continue;
        else if(b&&recure(a,b-1,c,d,7,"7"))continue;
        else cout<<-1<<endl;
    }
    return 0;
}


#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <functional>
#include <cmath>

using namespace std;

int main()
{
	int c4, c7, c47, c74;
	int cc4 = 0;
	int cc7 = 0;
	cin >> c4 >> c7 >> c47 >> c74;
	string str = "";
	if (fabs(c47 - c74) > 1)
	{
		cout << -1;
	}
	else
	{
		for (int i = 0; i < c47; i++)
		{
			str += "47";
			cc4++;
			cc7++;
		}
		if (c47 == c74 && c4 > cc4)
		{
			if (c4 > cc4)
			{
				str += "4";
				cc4++;
			}
			else
			{
				str = '7' + str;
				cc7++;
			}
		}
		if (c74 > c47)
		{
			cc4++;
			cc7++;
			str += "4";
			str = "7" + str;
		}
		if (c4 < cc4 || c7 < cc7)
		{
			cout << -1 << endl;
			return 0;
		}
		string str4 = string(c4 - cc4, '4');
		string str7 = string(c7 - cc7, '7');

		if (str[0] == '4')
			cout << str4 << '4';
		else
			cout << '7' << str4;
		for (int i = 1; i < str.size()-1; i++)
		{
			cout << str[i];
		}
		if (str[str.size() - 1] == '4')
			cout << str7 << '4';
		else
			cout << '7' << str7;
		cout << endl;
	}
	return 0;
}


#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <functional>
#include <cmath>

using namespace std;

int main()
{
	int c4, c7, c47, c74;
	int cc4 = 0;
	int cc7 = 0;
	cin >> c4 >> c7 >> c47 >> c74;
	string str = "";
	if (fabs(c47 - c74) > 1)
	{
		cout << -1;
	}
	else
	{
		while (c47)
		{
			str += "47";
			c47--; c74--;
			c4--; c7--;
		}
		c74++;

		if (c74 == 2)
		{
			if (c4 > 0 && c7 > 0)
			{
				str = "7" + str + "4";
				c74 -= 2;
				c4--; c7--;
			}
			else
			{
				cout << -1 << endl;
				return 0;
			}
		}

		if (c74 == 1)
		{
			if (c4 > 0)
			{
				str += "4";
				c4--;
			}
			else if (c7 > 0)
			{
				str = "7" + str;
				c7--;
			}
			else
			{
				cout << -1 << endl;
				return 0;
			}
		}

		cout << str[0];
		while (c4)
		{
			cout << '4';
			c4--;
		}
		for (int i = 1; i < str.size() - 1; i++)
			cout << str[i];
		while (c7)
		{
			cout << '7';
			c7--;
		}
		cout << str[str.size() - 1] << endl;
	}
	return 0;
}


#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <functional>
#include <cmath>
#include <sstream>

using namespace std;

int main()
{
	int c4, c7, c47, c74;
	int cc4 = 0;
	int cc7 = 0;
	cin >> c4 >> c7 >> c47 >> c74;
	string str = "";
	if (fabs(c47 - c74) > 1)
	{
		cout << -1;
	}
	else
	{
		while (c47)
		{
			str += "47";
			c47--; c74--;
			c4--; c7--;
		}
		c74++;

		if (c74 == 2)
		{
			if (c4 > 0 && c7 > 0)
			{
				str = "7" + str + "4";
				c74 -= 2;
				c4--; c7--;
			}
			else
			{
				cout << -1 << endl;
				return 0;
			}
		}

		if (c74 == 1)
		{
			if (c4 > 0)
			{
				str += "4";
				c4--;
			}
			else if (c7 > 0)
			{
				str = "7" + str;
				c7--;
			}
			else
			{
				cout << -1 << endl;
				return 0;
			}
		}

		stringstream ss;
		ss << str[0];
		while (c4)
		{
			ss << '4';
			c4--;
		}
		for (int i = 1; i < str.size() - 1; i++)
			ss << str[i];
		while (c7)
		{
			ss << '7';
			c7--;
		}
		ss << str[str.size() - 1];
		cout << ss.str() << endl;
	}
	return 0;
}


#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <functional>
#include <cmath>
#include <sstream>

using namespace std;

int main()
{
	int c4, c7, c47, c74;
	int cc4 = 0;
	int cc7 = 0;
	cin >> c4 >> c7 >> c47 >> c74;
	string str = "";
	if (fabs(c47 - c74) > 1)
	{
		cout << -1;
	}
	else
	{
		while (c47)
		{
			str += "47";
			c47--; c74--;
			c4--; c7--;
		}
		c74++;

		if (c74 == 2)
		{
			if (c4 > 0 && c7 > 0)
			{
				str = "7" + str + "4";
				c74 -= 2;
				c4--; c7--;
			}
			else
			{
				cout << -1 << endl;
				return 0;
			}
		}

		if (c74 == 1)
		{
			if (c4 > 0)
			{
				str += "4";
				c4--;
			}
			else if (c7 > 0)
			{
				str = "7" + str;
				c7--;
			}
			else
			{
				cout << -1 << endl;
				return 0;
			}
		}

		stringstream ss;
		ss << str[0];
		while (c4 > 0)
		{
			ss << '4';
			c4--;
		}
		for (int i = 1; i < str.size() - 1; i++)
			ss << str[i];
		while (c7 > 0)
		{
			ss << '7';
			c7--;
		}
		ss << str[str.size() - 1];
		cout << ss.str() << endl;
	}
	return 0;
}


#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <functional>
#include <cmath>

using namespace std;

int main()
{
	int c4, c7, c47, c74;
	int cc4 = 0;
	int cc7 = 0;
	cin >> c4 >> c7 >> c47 >> c74;
	string str = "";
	if (fabs(c47 - c74) > 1)
	{
		cout << -1;
	}
	else
	{
		for (int i = 0; i < c47; i++)
		{
			str += "47";
			cc4++;
			cc7++;
		}
		if (c47 == c74)
		{
			str += "4";
			cc4++;
		}
		if (c74 > c47)
		{
			cc4++;
			cc7++;
			str += "4";
			str = "7" + str;
		}
		if (c4 < cc4 || c7 < cc7)
		{
			cout << -1 << endl;
			return 0;
		}
		string str4 = string(c4 - cc4, '4');
		string str7 = string(c7 - cc7, '7');

		if (str[0] == '4')
			cout << str4 << '4';
		else
			cout << '7' << str4;
		for (int i = 1; i < str.size()-1; i++)
		{
			cout << str[i];
		}
		if (str[str.size() - 1] == '4')
			cout << str7 << '4';
		else
			cout << '7' << str7;
		cout << endl;
	}
	return 0;
}


#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <functional>
#include <cmath>

using namespace std;

int main()
{
	int c4, c7, c47, c74;
	int cc4 = 0;
	int cc7 = 0;
	cin >> c4 >> c7 >> c47 >> c74;
	string str = "";
	if (fabs(c47 - c74) > 1)
	{
		cout << -1;
	}
	else
	{
		while (c47)
		{
			str += "47";
			c47--; c74--;
			c4--; c7--;
		}
		c74++;

		if (c74 == 2)
		{
			if (c4 > 0 && c7 > 0)
			{
				str = "7" + str + "4";
				c74 -= 2;
				c4--; c7--;
			}
			else
			{
				cout << -1 << endl;
				return 0;
			}
		}

		if (c74 == 1)
		{
			if (c4 > 0)
			{
				str += "4";
				c4--;
			}
			else if (c7 > 0)
			{
				str = "7" + str;
				c7--;
			}
			else
			{
				cout << -1 << endl;
				return 0;
			}

			cout << str[0];
			while (c4)
			{
				cout << '4';
				c4--;
			}
			for (int i = 1; i < str.size() - 1; i++)
				cout << str[i];
			while (c7)
			{
				cout << '7';
				c7--;
			}
			cout << str[str.size() - 1] << endl;
		}
	}
	return 0;
}


#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <functional>
#include <cmath>
#include <sstream>

using namespace std;

int main()
{
	int c4, c7, c47, c74;
	int cc4 = 0;
	int cc7 = 0;
	cin >> c4 >> c7 >> c47 >> c74;
	string str = "";
	if (fabs(c47 - c74) > 1)
	{
		cout << -1;
	}
	else
	{
		while (c47)
		{
			str += "47";
			c47--; c74--;
			c4--; c7--;
		}
		c74++;

		if (c4 < 0 || c7 < 0)
		{
			cout << -1 << endl;
			return 0;
		}

		if (c74 == 2)
		{
			if (c4 > 0 && c7 > 0)
			{
				str = "7" + str + "4";
				c74 -= 2;
				c4--; c7--;
			}
			else
			{
				cout << -1 << endl;
				return 0;
			}
		}

		if (c74 == 1)
		{
			if (c4 > 0)
			{
				str += "4";
				c4--;
			}
			else if (c7 > 0)
			{
				str = "7" + str;
				c7--;
			}
			else
			{
				cout << -1 << endl;
				return 0;
			}
		}

		stringstream ss;
		ss << str[0];
		while (c4 > 0)
		{
			ss << '4';
			c4--;
		}
		for (int i = 1; i < str.size() - 1; i++)
			ss << str[i];
		while (c7 > 0)
		{
			ss << '7';
			c7--;
		}
		ss << str[str.size() - 1];
		cout << ss.str() << endl;
	}
	return 0;
}


#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <functional>
#include <cmath>

using namespace std;

int main()
{
	int c4, c7, c47, c74;
	int cc4 = 0;
	int cc7 = 0;
	cin >> c4 >> c7 >> c47 >> c74;
	string str = "";
	if (fabs(c47 - c74) > 1)
	{
		cout << -1;
	}
	else
	{
		for (int i = 0; i < c47; i++)
		{
			str += "47";
			cc4++;
			cc7++;
		}
		if (c47 == c74)
		{
			str += "4";
			cc4++;
		}
		if (c74 > c47)
		{
			cc4++;
			cc7++;
			str += "4";
			str = "7" + str;
		}
		if (c4 < cc4 || c7 < cc7)
		{
			cout << -1 << endl;
			return 0;
		}
		for (int i = 0; i < c4 - cc4; i++)
		{
			if (str[0] == '4')
				str.insert(str.begin(), '4');
			else
				str.insert(str.begin() + 1, '4');
		}
		for (int i = 0; i < c7 - cc7; i++)
		{
			if (str[str.size() - 1] == '7')
				str += "7";
			else
				str.insert(str.end() - 2, '7');
		}
		cout << str << endl;
	}
	return 0;
}


#include<iostream>
#include<cstring>
#include<cstdio>
#include<string>
#include<cmath>
using namespace std;
int a,b,ab,ba;
int main()
{
   // freopen("check.in","r",stdin);
   // freopen("check.out","w",stdout);
    cin>>a>>b>>ab>>ba;
    if(ab>a||ab>b||ba>a||ba>b||ab+ba>=a+b||abs(ba-ab)>1)
    {
      cout<<"-1"<<endl;
      return 0;
    }
    string ans="";
    for(int i=1;i<=ab;i++)
            ans=ans+"47",a--,b--;
    if(ba>=ab)ans=ans+"4",a--;
    if(ba>ab)ans="7"+ans,b--;
    if(a>0)
    {
    if(ans[0]=='4')
    for(int i=1;i<=a;i++)ans="4"+ans;
    else
    {
        ans[0]='4';a--;
        for(int i=1;i<=a;i++)ans="4"+ans;
        ans="7"+ans;
    }
    }
    if(b>0)
    {
           if(ans[ans.size()-1]=='7')
           for(int i=1;i<=b;i++)ans=ans+"7";
           else
           {
               ans[ans.size()-1]='7';b--;
               for(int i=1;i<=b;i++)ans=ans+"7";
               ans=ans+"4";
           }
    }
    cout<<ans<<endl;
    return 0;

}


import java.util.*;
import java.lang.*;
import java.io.*;

public class A
{

	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		int t=Integer.parseInt(br.readLine());
		while(t-->0){
		    int n=Integer.parseInt(br.readLine());
		    int arr[]=new int[26];
		    int v=n;
		    while(n-->0) {
		    	String s=br.readLine();
		    	for(char c:s.toCharArray()) {
		    		arr[c-'a']++;
		    	}
		    }
		    int ans=0;
		    for(int i=0;i<25;i++) {
		    	if((arr[i]%v)!=0)
		    	{
		    		ans=1;
		    		break;
		    	}
		    }
		    if(ans==0)
		    	System.out.println("YES");
		    else
		    	System.out.println("NO");
		}
	}
}


import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();

		ArrayList<String[]> a = new ArrayList<>();
		for(int i=0; i<t; i++) {
			int n = sc.nextInt();
			String[] s = new String[n];
			for(int j=0; j<n; j++)
				s[j] = sc.next();
			a.add(s);
		}

		for(int i=0; i<t; i++)
			System.out.println(check(a.get(i)));

		sc.close();

	}

	private static String check(String[] s) {
		int n = s.length;
		HashMap<Character, Integer> hmap = new HashMap<>();

		for(int i=0; i<n; i++) {
			for(char c : s[i].toCharArray())
				hmap.put(c, hmap.getOrDefault(c, 0) + 1);
		}

		for(Map.Entry<Character, Integer> entry : hmap.entrySet() ) {
			if(entry.getValue() %n != 0)
				return "NO";
		}
		return "YES";
	}

}


import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();

		ArrayList<String[]> a = new ArrayList<>();
		for(int i=0; i<t; i++) {
			int n = sc.nextInt();
			String[] s = new String[n];
			for(int j=0; j<n; j++)
				s[j] = sc.next();
			a.add(s);
		}

		for(int i=0; i<t; i++)
			System.out.println(check(a.get(i)));

		sc.close();

	}

	private static String check(String[] s) {
		int n = s.length;
		int[] a = new int[26];

		for(int i=0; i<n; i++) {
			for(char c : s[i].toCharArray()) {
				int num = c;
				a[num-97]++;
			}
		}

		for(int num : a) {
			if(num %n != 0)
				return "NO";
		}
		return "YES";
	}

}


import java.util.*;

public class JugglingLetters {
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int t = scanner.nextInt();

		while (t-- > 0) {

			int n = scanner.nextInt();
			scanner.nextLine();

			int letters[] = new int[26];

			boolean cando = true;
			while (n-- > 0){
				String str = scanner.nextLine();

				for (int i = 0; i < str.length(); ++i) {
					letters[str.charAt(i) - 'a']++;
				}
			}

			for (int i = 0; i < 26; ++i) {
				if (letters[i] % n != 0)
					cando = false;
			}

			if (cando) {
				System.out.println("YES");
			}
			else {
				System.out.println("NO");
			}
		}
	}
}


import java.util.*;

public class JugglingLetters {
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int t = scanner.nextInt();

		while (t-- > 0) {

			int n = scanner.nextInt();
			scanner.nextLine();

			int letters[] = new int[26];

			boolean cando = true;
			for (int l = 0; l < n; l++) {
				String str = scanner.nextLine();

				for (int i = 0; i < str.length(); ++i) {
					letters[str.charAt(i) - 'a']++;
				}
			}

			for (int i = 0; i < 26; ++i) {
				if (letters[i] % n != 0)
					cando = false;
			}

			if (cando) {
				System.out.println("YES");
			}
			else {
				System.out.println("NO");
			}
		}
	}
}


//package com.cf.r666;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class A {

	FastScanner in;
	PrintWriter out;

	public static void main(String[] args) {
		new A().solve();
	}

	private void solve() {
		in = new FastScanner(System.in);
		out = new PrintWriter(System.out);

		int t = in.nextInt();
		for (int i = 0; i < t; i++) {
			int n = in.nextInt();

			int[] count = new int[32];
			for (int j = 0; j < n; j++) {
				in.next().chars().forEach(c -> count[c - 'a']++);
			}

			if (Arrays.stream(count).allMatch(c -> c % n == 0)) out.println("YES");
			else out.println("NO");
		}

		out.close();
	}

	static class FastScanner {

		BufferedReader br;
		StringTokenizer st;

		public FastScanner(File f) {
			try {
				br = new BufferedReader(new FileReader(f));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}

		public FastScanner(InputStream f) {
			br = new BufferedReader(new InputStreamReader(f));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				String s = null;
				try {
					s = br.readLine();
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (s == null)
					return null;
				st = new StringTokenizer(s);
			}
			return st.nextToken();
		}

		boolean hasMoreTokens() {
			while (st == null || !st.hasMoreTokens()) {
				String s = null;
				try {
					s = br.readLine();
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (s == null)
					return false;
				st = new StringTokenizer(s);
			}
			return true;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}
	}
}


package com.cf.r666;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;

public class A {

	FastScanner in;
	PrintWriter out;

	public static void main(String[] args) {
		new A().solve();
	}

	private void solve() {
		in = new FastScanner(System.in);
		out = new PrintWriter(System.out);

		int t = in.nextInt();
		for (int i = 0; i < t; i++) {
			int n = in.nextInt();

			int[] count = new int[32];
			for (int j = 0; j < n; j++) {
				in.next().chars().forEach(c -> count[c - 'a']++);
			}

			if (Arrays.stream(count).allMatch(c -> c % n == 0)) out.println("YES");
			else out.println("NO");
		}

		out.close();
	}

	static class FastScanner {

		BufferedReader br;
		StringTokenizer st;

		public FastScanner(File f) {
			try {
				br = new BufferedReader(new FileReader(f));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}

		public FastScanner(InputStream f) {
			br = new BufferedReader(new InputStreamReader(f));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				String s = null;
				try {
					s = br.readLine();
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (s == null)
					return null;
				st = new StringTokenizer(s);
			}
			return st.nextToken();
		}

		boolean hasMoreTokens() {
			while (st == null || !st.hasMoreTokens()) {
				String s = null;
				try {
					s = br.readLine();
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (s == null)
					return false;
				st = new StringTokenizer(s);
			}
			return true;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}
	}
}


import java.util.Scanner;
public class JugglingLetters {
    public static void main(String[] args) {
        Scanner entrada = new Scanner(System.in);
        int numero, diferente, m = 1;
        numero = entrada.nextInt();
        for (int i = 0; i < numero; i++) {
            int n = entrada.nextInt();
            entrada.nextLine();
            String nombre="",nuevo;
            boolean comparar = true;
            for (int j = 0; j < n; j++) {
                String palabras = entrada.nextLine();
                nombre = nombre + palabras;
            }
            nuevo = nombre;
            while (comparar == true) {
                int cont=0;
                for (int k = 0; k < nombre.length(); k++) {
                    if (nombre.charAt(0) == nombre.charAt(k)) {
                        cont = cont + 1;
                        if(cont==nombre.length()){
                            nuevo="";
                        }
                        nuevo = nuevo.replace(String.valueOf(nombre.charAt(k)), "");
                    }
                }
                if (cont % n != 0) {
                    comparar = false;
                    break;
                }
                if(nuevo==""){
                    break;
                }
                nombre = nuevo;
            }
            if(comparar==true){
                System.out.println("YES");
            }
            else{
                if (comparar==false){
                System.out.println("NO");}
            }
        }
    }
}


import java.util.*;
import java.io.*;
import java.lang.*;

public class test {

     public static void main(String args[]) {

                  try{
		  Scanner sc= new Scanner(System.in);

		  int t = sc.nextInt();

		  while(t-->0) {

			  int a[] = new int[256];
			  boolean check = true;

			  int n = sc.nextInt();
			  int b = n;
			  while(n-->0) {
				  String s = sc.next();

				  for(int i=0;i<s.length();i++) {
					  a[(int)s.charAt(i)]++;
				  }

			  }

			  for(int i=0;i<256;i++) {
				  if(a[i]%b!=0) {
					  check=false;
				  }
			  }

			  if(check==true) {
				  System.out.println("YES");
			  }
			  else
				  System.out.println("NO");
			}
		  }
                 catch( Exception e){ return;}

	  }
	}


import java.text.DecimalFormat;
import java.util.stream.LongStream;
import java.util.stream.IntStream;
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        int t = sc.nextInt();
        while(t-->0){
        Naveen problem = new Naveen(sc);
            problem.solve(out,sc);
        }
        out.flush();
    }

}

class Naveen {

    int n;
    String s;

    Naveen(FastScanner sc) {

         n = sc.nextInt();
       //  arr = sc.arrayInt(n);

    }

    void solve(PrintWriter out,FastScanner sc) {

  int[] arr = new int[26];
  int i;
  for(i =0;i<n;i++){
      s = sc.next();
      for(int j =0;j<s.length();j++)
      arr[s.charAt(j)-'a']++;
  }

int j;
  for(j =0;j<26;j++){
      if(arr[j]%n!=0){
          break;
      }
  }
  if(j==26){
      out.println("YES");
  }else{
      out.println("NO");
  }

    }

}

class FastScanner {

    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte()) {
            return buffer[ptr++];
        } else {
            return -1;
        }
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
            ptr++;
        }
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
            throw new NumberFormatException();
        }
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }

    public int[] arrayInt(int N) {
        int[] array = new int[N];
        for (int i = 0; i < N; i++) {
            array[i] = nextInt();
        }
        return array;
    }

    public long[] arrayLong(int N) {
        long[] array = new long[N];
        for (int i = 0; i < N; i++) {
            array[i] = nextLong();
        }
        return array;
    }

    public double[] arrayDouble(int N) {
        double[] array = new double[N];
        for (int i = 0; i < N; i++) {
            array[i] = nextDouble();
        }
        return array;
    }

    public String[] arrayString(int N) {
        String[] array = new String[N];
        for (int i = 0; i < N; i++) {
            array[i] = next();
        }
        return array;
    }

    public int randomInt() {
        Random r = new Random();
        int value = r.nextInt((int) 1e6);
        System.out.println(value);
        return value;
    }

    public int[] randomInt(int N) {
        int[] array = new int[N];
        Random r = new Random();
        for (int i = 0; i < N; i++) {
            array[i] = r.nextInt((int) 1e6);
        }
        System.out.println(Arrays.toString(array));
        return array;
    }

}

class My {

  public static long lower(long arr[],long key){
        int low = 0;
        int high = arr.length-1;
        while(low < high){
            int mid = low + (high - low)/2;
            if(arr[mid] >= key){
                high = mid;
            }
            else{
                low = mid+1;
            }
        }
        return low;
    }
public static int upper(int arr[],int key){
    int low = 0;
    int high = arr.length-1;
    while(low < high){
        int mid = low + (high - low+1)/2;
        if(arr[mid] <= key){
            low = mid;
        }
        else{
            high = mid-1;
        }
    }
    return low;
}
    static void ans(boolean b) {
        System.out.println(b ? "Yes" : "No");
    }

    static void ANS(boolean b) {
        System.out.println(b ? "YES" : "NO");
    }

    static String sort(String s) {
        char[] ch = s.toCharArray();
        Arrays.sort(ch);
        return String.valueOf(ch);
    }

    static String reverse(String s) {
        return new StringBuilder(s).reverse().toString();
    }

    static int[] reverse(int[] array) {
        for (int i = 0; i < array.length / 2; i++) {
            int temp = array[i];
            array[i] = array[array.length - 1 - i];
            array[array.length - 1 - i] = temp;
        }
        return array;
    }

    static long[] reverse(long[] array) {
        for (int i = 0; i < array.length / 2; i++) {
            long temp = array[i];
            array[i] = array[array.length - 1 - i];
            array[array.length - 1 - i] = temp;
        }
        return array;
    }

    static double[] reverse(double[] array) {
        for (int i = 0; i < array.length / 2; i++) {
            double temp = array[i];
            array[i] = array[array.length - 1 - i];
            array[array.length - 1 - i] = temp;
        }
        return array;
    }

    static String[] reverse(String[] array) {
        for (int i = 0; i < array.length / 2; i++) {
            String temp = array[i];
            array[i] = array[array.length - 1 - i];
            array[array.length - 1 - i] = temp;
        }
        return array;
    }

    static char[] reverse(char[] array) {
        for (int i = 0; i < array.length / 2; i++) {
            char temp = array[i];
            array[i] = array[array.length - 1 - i];
            array[array.length - 1 - i] = temp;
        }
        return array;
    }

    static long min(long... numbers) {
        Arrays.sort(numbers);
        return numbers[0];
    }

    static int min(int... numbers) {
        Arrays.sort(numbers);
        return numbers[0];
    }

    static double min(double... numbers) {
        Arrays.sort(numbers);
        return numbers[0];
    }

    static long max(long... numbers) {
        Arrays.sort(numbers);
        return numbers[numbers.length - 1];
    }

    static int max(int... numbers) {
        Arrays.sort(numbers);
        return numbers[numbers.length - 1];
    }

    static double max(double... numbers) {
        Arrays.sort(numbers);
        return numbers[numbers.length - 1];
    }

    static int sum(long number) {
        int sum = 0;
        while (number > 0) {
            sum += number % 10;
            number /= 10;
        }
        return sum;
    }

}


import java.text.DecimalFormat;
import java.util.stream.LongStream;
import java.util.stream.IntStream;
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        int t = sc.nextInt();
        while(t-->0){
        Naveen problem = new Naveen(sc);
            problem.solve(out,sc);
        }
        out.flush();
    }

}

class Naveen {

    int n;
    String s;

    Naveen(FastScanner sc) {

         n = sc.nextInt();
       //  arr = sc.arrayInt(n);

    }

    void solve(PrintWriter out,FastScanner sc) {

  int[] arr = new int[26];
  int i;
  for(i =0;i<n;i++){
      s = sc.next();
      for(int j =0;j<s.length();j++)
      arr[s.charAt(j)-'a']++;
  }

  for(i =0;i<26;i++){
      if(arr[i]%n!=0){
          break;
      }
  }
  if(i==26){
      out.println("YES");
  }else{
      out.println("NO");
  }

    }

}

class FastScanner {

    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte()) {
            return buffer[ptr++];
        } else {
            return -1;
        }
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
            ptr++;
        }
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
            throw new NumberFormatException();
        }
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }

    public int[] arrayInt(int N) {
        int[] array = new int[N];
        for (int i = 0; i < N; i++) {
            array[i] = nextInt();
        }
        return array;
    }

    public long[] arrayLong(int N) {
        long[] array = new long[N];
        for (int i = 0; i < N; i++) {
            array[i] = nextLong();
        }
        return array;
    }

    public double[] arrayDouble(int N) {
        double[] array = new double[N];
        for (int i = 0; i < N; i++) {
            array[i] = nextDouble();
        }
        return array;
    }

    public String[] arrayString(int N) {
        String[] array = new String[N];
        for (int i = 0; i < N; i++) {
            array[i] = next();
        }
        return array;
    }

    public int randomInt() {
        Random r = new Random();
        int value = r.nextInt((int) 1e6);
        System.out.println(value);
        return value;
    }

    public int[] randomInt(int N) {
        int[] array = new int[N];
        Random r = new Random();
        for (int i = 0; i < N; i++) {
            array[i] = r.nextInt((int) 1e6);
        }
        System.out.println(Arrays.toString(array));
        return array;
    }

}

class My {

  public static long lower(long arr[],long key){
        int low = 0;
        int high = arr.length-1;
        while(low < high){
            int mid = low + (high - low)/2;
            if(arr[mid] >= key){
                high = mid;
            }
            else{
                low = mid+1;
            }
        }
        return low;
    }
public static int upper(int arr[],int key){
    int low = 0;
    int high = arr.length-1;
    while(low < high){
        int mid = low + (high - low+1)/2;
        if(arr[mid] <= key){
            low = mid;
        }
        else{
            high = mid-1;
        }
    }
    return low;
}
    static void ans(boolean b) {
        System.out.println(b ? "Yes" : "No");
    }

    static void ANS(boolean b) {
        System.out.println(b ? "YES" : "NO");
    }

    static String sort(String s) {
        char[] ch = s.toCharArray();
        Arrays.sort(ch);
        return String.valueOf(ch);
    }

    static String reverse(String s) {
        return new StringBuilder(s).reverse().toString();
    }

    static int[] reverse(int[] array) {
        for (int i = 0; i < array.length / 2; i++) {
            int temp = array[i];
            array[i] = array[array.length - 1 - i];
            array[array.length - 1 - i] = temp;
        }
        return array;
    }

    static long[] reverse(long[] array) {
        for (int i = 0; i < array.length / 2; i++) {
            long temp = array[i];
            array[i] = array[array.length - 1 - i];
            array[array.length - 1 - i] = temp;
        }
        return array;
    }

    static double[] reverse(double[] array) {
        for (int i = 0; i < array.length / 2; i++) {
            double temp = array[i];
            array[i] = array[array.length - 1 - i];
            array[array.length - 1 - i] = temp;
        }
        return array;
    }

    static String[] reverse(String[] array) {
        for (int i = 0; i < array.length / 2; i++) {
            String temp = array[i];
            array[i] = array[array.length - 1 - i];
            array[array.length - 1 - i] = temp;
        }
        return array;
    }

    static char[] reverse(char[] array) {
        for (int i = 0; i < array.length / 2; i++) {
            char temp = array[i];
            array[i] = array[array.length - 1 - i];
            array[array.length - 1 - i] = temp;
        }
        return array;
    }

    static long min(long... numbers) {
        Arrays.sort(numbers);
        return numbers[0];
    }

    static int min(int... numbers) {
        Arrays.sort(numbers);
        return numbers[0];
    }

    static double min(double... numbers) {
        Arrays.sort(numbers);
        return numbers[0];
    }

    static long max(long... numbers) {
        Arrays.sort(numbers);
        return numbers[numbers.length - 1];
    }

    static int max(int... numbers) {
        Arrays.sort(numbers);
        return numbers[numbers.length - 1];
    }

    static double max(double... numbers) {
        Arrays.sort(numbers);
        return numbers[numbers.length - 1];
    }

    static int sum(long number) {
        int sum = 0;
        while (number > 0) {
            sum += number % 10;
            number /= 10;
        }
        return sum;
    }

}


import java.io.*; // for handling input/output
import java.util.*; // contains Collections framework

public class Solution {
    public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
        int t = in.nextInt();
        while(t-->0){
            int n = in.nextInt();
            Map<Character, Integer> mp= new HashMap<>();
            for(int i=0; i<n; i++){
                String s = in.next();
                for(int j=0; j<s.length(); j++){
                    char c = s.charAt(j);
                    mp.put(c, mp.getOrDefault(c, 0)+1);
                }
            }
            boolean b = true;
            for(int i : mp.values()){
                if(i%2 != 0){
                    b = false;
                    break;
                }
            }
            if(b)   System.out.println("YES");
            else    System.out.println("NO");
        }
	}
}


import java.io.*; // for handling input/output
import java.util.*; // contains Collections framework

public class Solution {
    public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
        int t = in.nextInt();
        while(t-->0){
            int n = in.nextInt();
            Map<Character, Integer> mp= new HashMap<>();
            for(int i=0; i<n; i++){
                String s = in.next();
                for(int j=0; j<s.length(); j++){
                    char c = s.charAt(j);
                    mp.put(c, mp.getOrDefault(c, 0)+1);
                }
            }
            boolean b = true;
            for(int i : mp.values()){
                if(i%n != 0){
                    b = false;
                    break;
                }
            }
            if(b)   System.out.println("YES");
            else    System.out.println("NO");
        }
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class CF_A_1397
{
    public static void main(String[] args) throws IOException
    {
        long t = readLong();
        TestLoop:
        for (int __ = 0; __ < t; __++)
        {
            long n = readLong();
            if (n == 0)
            {
                System.out.println("YES");
                continue;
            }
            int[] chCounts = new int[26];

            for (int i = 0; i < n; i++)
            {
                char[] str = br.readLine().toCharArray();
                for (char c: str)
                {
                    chCounts[c - 'a']++;
                }
            }

            for (int count: chCounts)
            {
                if (count != 0 && count % n != 0)
                {
                    System.out.println("NO");
                    continue TestLoop;
                }
            }
            System.out.println("YES");
        }
    }

    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static StringTokenizer st;

    static long readLong() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
        {
            st = new StringTokenizer(br.readLine());
        }
        return Long.parseLong(st.nextToken());
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class CF_A_1397
{
    public static void main(String[] args) throws IOException
    {
        long t = readLong();
        TestLoop:
        for (int i = 0; i < t; i++)
        {
            long n = readLong();
            char[] characters = new char[24];

            for (int j = 0; j < n; j++)
            {
                char[] str = br.readLine().toCharArray();
                for (char c: str)
                {
                    characters[c - 'a']++;
                }
            }

            for (int j = 1; j < n; j++)
            {
                if (characters[j] % n != 0)
                {
                    System.out.println("NO");
                    continue TestLoop;
                }
            }
            System.out.println("YES");
        }
    }

    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static StringTokenizer st;

    static long readLong() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
        {
            st = new StringTokenizer(br.readLine());
        }
        return Long.parseLong(st.nextToken());
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class CF_A_1397
{
    public static void main(String[] args) throws IOException
    {
        long t = readLong();
        TestLoop:
        for (int __ = 0; __ < t; __++)
        {
            long n = readLong();
            if (n == 0)
            {
                System.out.println("YES");
                continue;
            }
            int[] chCounts = new int[24];

            for (int i = 0; i < n; i++)
            {
                char[] str = br.readLine().toCharArray();
                for (char c: str)
                {
                    chCounts[c - 'a']++;
                }
            }

            for (int count: chCounts)
            {
                if (count != 0 && count % n != 0)
                {
                    System.out.println("NO");
                    continue TestLoop;
                }
            }
            System.out.println("YES");
        }
    }

    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static StringTokenizer st;

    static long readLong() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
        {
            st = new StringTokenizer(br.readLine());
        }
        return Long.parseLong(st.nextToken());
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class CF_A_1397
{
    public static void main(String[] args) throws IOException
    {
        long t = readLong();
        TestLoop:
        for (int __ = 0; __ < t; __++)
        {
            long n = readLong();
            int[] characters = new int[24];

            for (int i = 0; i < n; i++)
            {
                char[] str = br.readLine().toCharArray();
                for (char c: str)
                {
                    characters[c - 'a']++;
                }
            }

            for (int i = 0; i < 24; i++)
            {
                if (characters[i] != 0 && characters[i] % n != 0)
                {
                    System.out.println("NO");
                    continue TestLoop;
                }
            }
            System.out.println("YES");
        }
    }

    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static StringTokenizer st;

    static long readLong() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
        {
            st = new StringTokenizer(br.readLine());
        }
        return Long.parseLong(st.nextToken());
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class CF_A_1397
{
    public static void main(String[] args) throws IOException
    {
        long t = readLong();
        TestLoop:
        for (int __ = 0; __ < t; __++)
        {
            long n = readLong();
            char[] characters = new char[24];

            for (int i = 0; i < n; i++)
            {
                char[] str = br.readLine().toCharArray();
                for (char c: str)
                {
                    characters[c - 'a']++;
                }
            }

            for (int i = 0; i < 24; i++)
            {
                if (characters[i] != 0 && characters[i] % n != 0)
                {
                    System.out.println("NO");
                    continue TestLoop;
                }
            }
            System.out.println("YES");
        }
    }

    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static StringTokenizer st;

    static long readLong() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
        {
            st = new StringTokenizer(br.readLine());
        }
        return Long.parseLong(st.nextToken());
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class CF_A_1397
{
    public static void main(String[] args) throws IOException
    {
        long t = readLong();
        TestLoop:
        for (int i = 0; i < t; i++)
        {
            long n = readLong();
            char[] characters = new char[24];

            for (int j = 0; j < n; j++)
            {
                char[] str = br.readLine().toCharArray();
                for (char c: str)
                {
                    characters[c - 'a']++;
                }
            }

            for (int j = 0; j < 24; j++)
            {
                if (characters[j] % n != 0)
                {
                    System.out.println("NO");
                    continue TestLoop;
                }
            }
            System.out.println("YES");
        }
    }

    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static StringTokenizer st;

    static long readLong() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
        {
            st = new StringTokenizer(br.readLine());
        }
        return Long.parseLong(st.nextToken());
    }
}


//Codeforces 1397A
import java.util.Scanner;

public class CF1397A {
    static final Scanner SC = new Scanner(System.in);
    public static void main(String[] args) {
        int tests = SC.nextInt();
        for (int t = 0; t < tests; ++t) {
            int numStrings = SC.nextInt();
            String[] strings = new String[numStrings];
            for (int i = 0; i < numStrings; ++i)
                strings[i] = SC.next();
            boolean canEqualize = isEqualizingPossible(strings);
            out(canEqualize);
        }
    }

    // Checks and returns whether or not all the strings passed are composed of the same characters(same count as well)
    static boolean isEqualizingPossible(String[] strings) {
        int[] totalOccurrences = new int[26];
        for (int i = 0; i < strings.length; ++i) {
            int[] charOccurrences = characterCount(strings[i]);
            for (int j = 0; j < totalOccurrences.length; ++j)
                totalOccurrences[j] += charOccurrences[j];
        }
        for (int i = 0; i < totalOccurrences.length; ++i)
            if (totalOccurrences[i] % strings.length != 0)
                return false;
        return true; // Can share characters equally among all strings
    }

    // Returns an array with count of character occurrences in the string
    static int[] characterCount(String s) {
        int[] charCount = new int[26];
        for (int i = 0; i < s.length(); ++i)
            charCount[s.charAt(i)-'a'] += 1;
        return charCount;
    }

    // Prints output corresponding to condition
    static void out(boolean condition) {
        if (condition)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}


import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int t = sc.nextInt();
        while (t-- > 0) {
            int n = sc.nextInt();
            int[] arr = new int[30];
            for (int j = 0; j < n; j++) {
                String s = sc.next();
                for (int i = 0; i < s.length(); i++) {
                    int index = s.charAt(i) - 97;
                    arr[index]++;
                }
            }
            int flag = 0;
            for (int i = 0; i < 27; i++) {
                if (arr[i] != 0) {
                    if (arr[i] % n != 0) {
                        flag = 1;
                        break;
                    }
                }
            }
            if (flag == 1) {
                System.out.println("NO");
            } else {
                System.out.println("YES");
            }
        }
    }
}


import java.util.*;
import java.io.*;

public class juggling {
	public static void main(String[] args) throws Exception {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out);
		int t = Integer.parseInt(in.readLine());
		for(int i = 0; i < t; i++) {
			int n = Integer.parseInt(in.readLine());
			HashMap<Character, Integer> freqs = new HashMap<Character, Integer>();
			for(int j = 0; j < n; j++) {
				String s = in.readLine();
				for(int k = 0; k < s.length(); k++) {
					char c = s.charAt(k);
					Integer oldcount = freqs.get(c);
					if(oldcount == null) {
						oldcount = 0;
					}
					freqs.put(c, oldcount + 1);
				}
			}
			boolean res = true;
			for(char c : freqs.keySet()) {
				int count = freqs.get(c);
				if(count % n != 0) {
					res = false;
					break;
				}
			}
			out.println(res);
		}
		in.close();
		out.close();
	}
}


import java.util.*;
import java.io.*;

public class juggling {
	public static void main(String[] args) throws Exception {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out);
		int t = Integer.parseInt(in.readLine());
		for(int i = 0; i < t; i++) {
			int n = Integer.parseInt(in.readLine());
			HashMap<Character, Integer> freqs = new HashMap<Character, Integer>();
			for(int j = 0; j < n; j++) {
				String s = in.readLine();
				for(int k = 0; k < s.length(); k++) {
					char c = s.charAt(k);
					Integer oldcount = freqs.get(c);
					if(oldcount == null) {
						oldcount = 0;
					}
					freqs.put(c, oldcount + 1);
				}
			}
			boolean res = true;
			for(char c : freqs.keySet()) {
				int count = freqs.get(c);
				if(count % n != 0) {
					res = false;
					break;
				}
			}
			out.println(res ? "YES":"NO");
		}
		in.close();
		out.close();
	}
}


import java.util.Scanner;

public class Codeforcse {

public static void main(String[] args) {
	Scanner o=new Scanner(System.in);
	int t=o.nextInt();
	while(t>0) {
		int n=o.nextInt();
		int ar[]=new int[26];
		boolean done=false;

		for(int i=0;i<n;i++) {
			String s=o.next();
			for(int j=0;j<a.length;j++) {
				ar[s.charAt(j)-'a']++;
			}
		}

		boolean ans =true;
		for(int i=0;i<ar.length;i++) {
			if(ar[i]%2!=0) {
				ans=false;
				break;
			}
		}
		if(ans) {
			System.out.println("YES");
		}
		else {
			System.out.println("NO");
		}
		t--;
	}
}
}


import java.util.Scanner;

public class Codeforcse {

public static void main(String[] args) {
	Scanner o=new Scanner(System.in);
	int t=o.nextInt();
	while(t>0) {
		int n=o.nextInt();
		int ar[]=new int[26];
		for(int i=0;i<n;i++) {
			String s=o.next();
			if(n==1&&s.length()==1){
				System.out.println("YES");
				t--;
				continue;
				}

			char a[]=s.toCharArray();
			for(int j=0;j<a.length;j++) {
				ar[s.charAt(j)-'a']++;
			}
		}
		boolean ans =true;
		for(int i=0;i<ar.length;i++) {
			if(ar[i]%2!=0) {
				ans=false;
				break;
			}
		}
		if(ans) {
			System.out.println("YES");
		}
		else {
			System.out.println("NO");
		}
		t--;
	}
}
}


package com.Java;

import java.util.Scanner;

public class Codeforcse {

public static void main(String[] args) {
	Scanner o=new Scanner(System.in);
	int t=o.nextInt();
	while(t>0) {
		int n=o.nextInt();
		int ar[]=new int[26];
		boolean done=false;

		for(int i=0;i<n;i++) {
			String s=o.next();
			for(int j=0;j<s.length();j++) {
				ar[s.charAt(j)-'a']++;
			}
		}

		boolean ans =true;
		for(int i=0;i<26;i++) {
			if(ar[i]%n!=0) {
				ans=false;
				break;
			}
		}
		if(ans) {
			System.out.println("YES");
		}
		else {
			System.out.println("NO");
		}
		t--;
	}
}
}


package com.Java;

import java.util.Scanner;

public class Codeforcse {

public static void main(String[] args) {
	Scanner o=new Scanner(System.in);
	int t=o.nextInt();
	while(t>0) {
		int n=o.nextInt();
		int ar[]=new int[26];
		for(int i=0;i<n;i++) {
			String s=o.next();
if(n==1&&s.length()==1){
System.out.println("YES");
t--;
continue;
}
			char a[]=s.toCharArray();
			for(int j=0;j<a.length;j++) {
				ar[s.charAt(j)-'a']++;
			}
		}
		boolean ans =true;
		for(int i=0;i<ar.length;i++) {
			if(ar[i]%2!=0) {
				ans=false;
				break;
			}
		}
		if(ans) {
			System.out.println("YES");
		}
		else {
			System.out.println("NO");
		}
		t--;
	}
}
}


import java.util.Scanner;

public class Codeforcse {

public static void main(String[] args) {
	Scanner o=new Scanner(System.in);
	int t=o.nextInt();
	while(t>0) {
		int n=o.nextInt();
		int ar[]=new int[26];
		boolean done=false;

		for(int i=0;i<n;i++) {
			String s=o.next();
			for(int j=0;j<s.length();j++) {
				ar[s.charAt(j)-'a']++;
			}
		}

		boolean ans =true;
		for(int i=0;i<ar.length;i++) {
			if(ar[i]%2!=0) {
				ans=false;
				break;
			}
		}
		if(ans) {
			System.out.println("YES");
		}
		else {
			System.out.println("NO");
		}
		t--;
	}
}
}


import java.util.*;

 public class Codeforcse {

public static void main(String[] args) {
	Scanner o=new Scanner(System.in);
	int t=o.nextInt();
	while(t>0) {
		int n=o.nextInt();
		int ar[]=new int[26];
		for(int i=0;i<n;i++) {
			String s=o.next();
			char a[]=s.toCharArray();
			for(int j=0;j<a.length;j++) {
				ar[s.charAt(j)-'a']++;
			}
		}
		boolean ans =true;
		for(int i=0;i<ar.length;i++) {
			if(ar[i]%2!=0) {
				ans=false;
				break;
			}
		}
		if(ans) {
			System.out.println("YES");
		}
		else {
			System.out.println("NO");
		}
		t--;
	}
}
}


import java.util.Scanner;

public class Codeforcse {

public static void main(String[] args) {
	Scanner o=new Scanner(System.in);
	int t=o.nextInt();
	while(t>0) {
		int n=o.nextInt();
		int ar[]=new int[26];
		boolean done=false;

		for(int i=0;i<n;i++) {
			String s=o.next();
			if(n==1&&s.length()==1){
				System.out.println("YES");
				t--;
				done =true;
				break;
				}

			char a[]=s.toCharArray();
			for(int j=0;j<a.length;j++) {
				ar[s.charAt(j)-'a']++;
			}
		}
		if(done)
			continue;
		boolean ans =true;
		for(int i=0;i<ar.length;i++) {
			if(ar[i]%2!=0) {
				ans=false;
				break;
			}
		}
		if(ans) {
			System.out.println("YES");
		}
		else {
			System.out.println("NO");
		}
		t--;
	}
}
}


package com.Java;

import java.util.Scanner;

public class Codeforcse {

public static void main(String[] args) {
	Scanner o=new Scanner(System.in);
	int t=o.nextInt();
	while(t>0) {
		int n=o.nextInt();
		int ar[]=new int[26];
int cf=0;
		for(int i=0;i<n;i++) {
			String s=o.next();
if(s.length()==1)
cf=1;
			char a[]=s.toCharArray();
			for(int j=0;j<a.length;j++) {
				ar[s.charAt(j)-'a']++;
			}
		}
		boolean ans =true;
		for(int i=0;i<ar.length;i++) {
			if(ar[i]%2!=0) {
				ans=false;
				break;
			}
		}
		if(ans||cf==1) {
			System.out.println("YES");
		}
		else {
			System.out.println("NO");
		}
		t--;
	}
}
}


import java.util.Scanner;

public class Codeforcse {

public static void main(String[] args) {
	Scanner o=new Scanner(System.in);
	int t=o.nextInt();
	while(t>0) {
		int n=o.nextInt();
		int ar[]=new int[26];
		boolean done=false;

		for(int i=0;i<n;i++) {
			String s=o.next();
			for(int j=0;j<s.length();j++) {
				ar[s.charAt(j)-'a']++;
			}
		}

		boolean ans =true;
		for(int i=0;i<26;i++) {
			if(ar[i]%4!=0) {
				ans=false;
				break;
			}
		}
		if(ans) {
			System.out.println("YES");
		}
		else {
			System.out.println("NO");
		}
		t--;
	}
}
}


import java.util.Scanner;

public class Codeforcse {

public static void main(String[] args) {
	Scanner o=new Scanner(System.in);
	int t=o.nextInt();
	while(t>0) {
		int n=o.nextInt();
		int ar[]=new int[26];
		boolean done=false;

		for(int i=0;i<n;i++) {
			String s=o.next();
			for(int j=0;j<s.length();j++) {
				ar[s.charAt(j)-'a']++;
			}
		}

		boolean ans =true;
		for(int i=0;i<26;i++) {
			if(ar[i]%n!=0) {
				ans=false;
				break;
			}
		}
		if(ans) {
			System.out.println("YES");
		}
		else {
			System.out.println("NO");
		}
		t--;
	}
}
}


package com.Java;

import java.util.Scanner;

public class Codeforcse {

public static void main(String[] args) {
	Scanner o=new Scanner(System.in);
	int t=o.nextInt();
	while(t>0) {
		int n=o.nextInt();
		int ar[]=new int[26];
		for(int i=0;i<n;i++) {
			String s=o.next();
			char a[]=s.toCharArray();
			for(int j=0;j<a.length;j++) {
				ar[s.charAt(j)-'a']++;
			}
		}
		boolean ans =true;
		for(int i=0;i<ar.length;i++) {
			if(ar[i]%2!=0) {
				ans=false;
				break;
			}
		}
		if(ans||s.length()==1) {
			System.out.println("YES");
		}
		else {
			System.out.println("NO");
		}
		t--;
	}
}
}


import java.util.*;
import java.io.*;

public class Main{
    static class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    /** call this method to initialize reader for InputStream */
    static void init(InputStream input) {
        reader = new BufferedReader(
                     new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }

    /** get next word */
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                   reader.readLine() );
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }
    static long nextLong() throws IOException {
        return Long.parseLong( next() );
    }

}
    public static void main(String[] args)throws IOException{

        Reader.init(System.in);
        int t=Reader.nextInt();
        while(t-->0){
            int n=Reader.nextInt();
            String[] arr=new String[n];
            String s="";

            for(int i=0;i<n;i++){
                arr[i]=Reader.next();
                s+=arr[i];
            }

            char[] arri=s.toCharArray();

            Arrays.sort(arri);

            int c=0;

            ArrayList<Integer> anss=new ArrayList<>();

            for(int i=1;i<arri.length;i++){

                if(arri[i]==arri[i-1]){
                    c++;
                }
                else{
                    anss.add(c+1);
                    c=0;
                }
            }
            if(arri.length!=1){
            if(arri[n-1]==arri[n-2]){
                anss.add(c+1);
            }
            }
          //  System.out.println(anss.get(anss.size()-1));
            int k=0;

            for(int i=0;i<anss.size();i++){

                if(anss.get(i)%n!=0){
                    k=1;
                }
            }
            System.out.println((k==1)?"NO":"YES");
        }

    }
}


import java.util.*;
import java.io.*;

public class Main{
    static class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    /** call this method to initialize reader for InputStream */
    static void init(InputStream input) {
        reader = new BufferedReader(
                     new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }

    /** get next word */
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                   reader.readLine() );
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }
    static long nextLong() throws IOException {
        return Long.parseLong( next() );
    }

}
    public static void main(String[] args)throws IOException{

        Reader.init(System.in);
        int t=Reader.nextInt();
        while(t-->0){
            int n=Reader.nextInt();
            String[] arr=new String[n];
            String s="";

            for(int i=0;i<n;i++){
                arr[i]=Reader.next();
                s+=arr[i];
            }

            char[] arri=s.toCharArray();

            Arrays.sort(arri);

            int c=0;

            ArrayList<Integer> anss=new ArrayList<>();

            for(int i=1;i<arri.length;i++){

                if(arri[i]==arri[i-1]){
                    c++;
                }
                else{
                    anss.add(c+1);
                    c=0;
                }
            }
            if(arri[n-1]==arri[n-2]){
                anss.add(c+1);
            }
          //  System.out.println(anss.get(anss.size()-1));
            int k=0;

            for(int i=0;i<anss.size();i++){

                if(anss.get(i)%n!=0){
                    k=1;
                }
            }
            System.out.println((k==1)?"NO":"YES");
        }

    }
}


import java.util.*;
import java.io.*;

public class Main{
    static class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    /** call this method to initialize reader for InputStream */
    static void init(InputStream input) {
        reader = new BufferedReader(
                     new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }

    /** get next word */
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                   reader.readLine() );
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }
    static long nextLong() throws IOException {
        return Long.parseLong( next() );
    }

}
    public static void main(String[] args)throws IOException{

        Reader.init(System.in);
        int t=Reader.nextInt();
        while(t-->0){
            int n=Reader.nextInt();
            String[] arr=new String[n];
            String s="";

            for(int i=0;i<n;i++){
                arr[i]=Reader.next();
                s+=arr[i];
            }

            char[] arri=s.toCharArray();

            Arrays.sort(arri);

            int c=0;

            ArrayList<Integer> anss=new ArrayList<>();

            for(int i=1;i<arri.length;i++){

                if(arri[i]==arri[i-1]){
                    c++;
                }
                else{
                    anss.add(c+1);
                    c=0;
                }
            }
            if(arri.length!=1)
            if(arri[n-1]==arri[n-2]){
                anss.add(c+1);
            }
          //  System.out.println(anss.get(anss.size()-1));
            int k=0;

            for(int i=0;i<anss.size();i++){

                if(anss.get(i)%n!=0){
                    k=1;
                }
            }
            System.out.println((k==1)?"NO":"YES");
        }

    }
}


import java.util.*;
import java.io.*;

public class Main{
    static class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    /** call this method to initialize reader for InputStream */
    static void init(InputStream input) {
        reader = new BufferedReader(
                     new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }

    /** get next word */
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                   reader.readLine() );
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }
    static long nextLong() throws IOException {
        return Long.parseLong( next() );
    }

}
    public static void main(String[] args)throws IOException{

        Reader.init(System.in);
        int t=Reader.nextInt();
        while(t-->0){
            int n=Reader.nextInt();
            String[] arr=new String[n];
            String s="";

            for(int i=0;i<n;i++){
                arr[i]=Reader.next();
                s+=arr[i];
            }

            char[] arri=s.toCharArray();

            Arrays.sort(arri);

            int c=0;

            ArrayList<Integer> anss=new ArrayList<>();

            for(int i=1;i<arri.length;i++){

                if(arri[i]==arri[i-1]){
                    c++;
                }
                else{
                    anss.add(c+1);
                    c=0;
                }
            }
            if(arri.length!=1){
            if(arri[arri.length-1]==arri[arr.length-2]){
                anss.add(c+1);
            }
            }
          //  System.out.println(anss.get(anss.size()-1));
            int k=0;

            for(int i=0;i<anss.size();i++){

                if(anss.get(i)%n!=0){
                    k=1;
                }
            }
            System.out.println((k==1)?"NO":"YES");
        }

    }
}


import java.util.*;
import java.io.*;

public class Main{
    static class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    /** call this method to initialize reader for InputStream */
    static void init(InputStream input) {
        reader = new BufferedReader(
                     new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }

    /** get next word */
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                   reader.readLine() );
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }
    static long nextLong() throws IOException {
        return Long.parseLong( next() );
    }

}
    public static void main(String[] args)throws IOException{

        Reader.init(System.in);
        int t=Reader.nextInt();
        while(t-->0){
            int n=Reader.nextInt();
            String[] arr=new String[n];
            String s="";

            for(int i=0;i<n;i++){
                arr[i]=Reader.next();
                s+=arr[i];
            }

            char[] arri=s.toCharArray();

            Arrays.sort(arri);

            int c=0;

            ArrayList<Integer> anss=new ArrayList<>();

            for(int i=1;i<arri.length;i++){

                if(arri[i]==arri[i-1]){
                    c++;
                }
                else{
                    anss.add(c+1);
                    c=0;
                }
            }
            if(arri.length!=1){
            if(arri[arri.length-1]==arri[arri.length-2]){
                anss.add(c+1);
            }
            {
          //  System.out.println(anss.get(anss.size()-1));
            int k=0;

            for(int i=0;i<anss.size();i++){

                if(anss.get(i)%n!=0){
                    k=1;
                }
            }
            System.out.println((k==1)?"NO":"YES");
        }

    }
}


import java.util.*;
import java.io.*;

public class Main{
    static class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    /** call this method to initialize reader for InputStream */
    static void init(InputStream input) {
        reader = new BufferedReader(
                     new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }

    /** get next word */
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                   reader.readLine() );
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }
    static long nextLong() throws IOException {
        return Long.parseLong( next() );
    }

}
    public static void main(String[] args)throws IOException{

        Reader.init(System.in);
        int t=Reader.nextInt();
        while(t-->0){
            int n=Reader.nextInt();
            String[] arr=new String[n];
            String s="";

            for(int i=0;i<n;i++){
                arr[i]=Reader.next();
                s+=arr[i];
            }

            char[] arri=s.toCharArray();

            Arrays.sort(arri);

            int c=0;

            ArrayList<Integer> anss=new ArrayList<>();

            for(int i=1;i<arri.length;i++){

                if(arri[i]==arri[i-1]){
                    c++;
                }
                else{
                    anss.add(c+1);
                    c=0;
                }
            }
            if(arri.length!=1){
            if(arri[arri.length-1]==arri[arri.length-2]){
                anss.add(c+1);
            }
            }
          //  System.out.println(anss.get(anss.size()-1));
            int k=0;

            for(int i=0;i<anss.size();i++){

                if(anss.get(i)%n!=0){
                    k=1;
                }
            }
            System.out.println((k==1)?"NO":"YES");
        }

    }
}


import java.util.*;
import java.io.*;

public class Main{
    static class Reader {
    static BufferedReader reader;
    static StringTokenizer tokenizer;

    /** call this method to initialize reader for InputStream */
    static void init(InputStream input) {
        reader = new BufferedReader(
                     new InputStreamReader(input) );
        tokenizer = new StringTokenizer("");
    }

    /** get next word */
    static String next() throws IOException {
        while ( ! tokenizer.hasMoreTokens() ) {
            //TODO add check for eof if necessary
            tokenizer = new StringTokenizer(
                   reader.readLine() );
        }
        return tokenizer.nextToken();
    }

    static int nextInt() throws IOException {
        return Integer.parseInt( next() );
    }

    static double nextDouble() throws IOException {
        return Double.parseDouble( next() );
    }
    static long nextLong() throws IOException {
        return Long.parseLong( next() );
    }

}
    public static void main(String[] args)throws IOException{

        Reader.init(System.in);
        int t=Reader.nextInt();
        while(t-->0){
            int n=Reader.nextInt();
            String[] arr=new String[n];
            String s="";

            for(int i=0;i<n;i++){
                arr[i]=Reader.next();
                s+=arr[i];
            }

            char[] arri=s.toCharArray();

            Arrays.sort(arri);

            int c=0;

            ArrayList<Integer> anss=new ArrayList<>();

            for(int i=1;i<arri.length;i++){

                if(arri[i]==arri[i-1]){
                    c++;
                }
                else{
                    anss.add(c+1);
                    c=0;
                }
            }
            if(arri.length!=1){
            if(arri[arri.length-1]==arri[arri.length-2]){
                anss.add(c+1);
            }
            else{
                anss.add(1);
            }
            }
          //  System.out.println(anss.get(anss.size()-1));
            int k=0;

            for(int i=0;i<anss.size();i++){

                if(anss.get(i)%n!=0){
                    k=1;
                }
            }
            System.out.println((k==1)?"NO":"YES");
        }

    }
}


import java.io.*;
import java.util.*;
import java.math.*;
import java.lang.*;

public class Cf131 implements Runnable
{
    static class InputReader
    {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;
        private BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        public InputReader(InputStream stream)
        {
            this.stream = stream;
        }

        public int read()
        {
            if (numChars==-1)
                throw new InputMismatchException();

            if (curChar >= numChars)
            {
                curChar = 0;
                try
                {
                    numChars = stream.read(buf);
                }
                catch (IOException e)
                {
                    throw new InputMismatchException();
                }

                if(numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
        public int nextInt()
        {
            int c = read();

            while(isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-')
            {
                sgn = -1;
                c = read();
            }

            int res = 0;
            do
            {
                if(c<'0'||c>'9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public long nextLong()
        {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-')
            {
                sgn = -1;
                c = read();
            }
            long res = 0;

            do
            {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));
                return res * sgn;
        }

        public double nextDouble()
        {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-')
            {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.')
            {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, nextInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.')
            {
                c = read();
                double m = 1;
                while (!isSpaceChar(c))
                {
                    if (c == 'e' || c == 'E')
                        return res * Math.pow(10, nextInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }

        public String readString()
        {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do
            {
                res.appendCodePoint(c);
                c = read();
            }
            while (!isSpaceChar(c));

            return res.toString();
        }

        public boolean isSpaceChar(int c)
        {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public String next()
        {
            return readString();
        }

        public interface SpaceCharFilter
        {
            public boolean isSpaceChar(int ch);
        }
    }
    public static void main(String args[]) throws Exception
    {
        new Thread(null, new Cf131(),"Main",1<<27).start();
    }

    static class Pair{
        int nod;
        int ucn;

        Pair(int nod,int ucn){
            this.nod=nod;
            this.ucn=ucn;

        }

        public static Comparator<Pair> wc = new Comparator<Pair>(){
            public int compare(Pair e1,Pair e2){

                //reverse order
                if(e1.ucn < e2.ucn)
                    return 1;  // 1 for swaping.
                else if (e1.ucn > e2.ucn)
                    return -1;
                else{
                    // if(e1.siz>e2.siz)
                    //     return 1;
                    // else
                    //     return -1;
                    return 0;
                }
            }
        };
    }

    public static long gcd(long a,long b){
        if(b==0)return a;
        else return gcd(b,a%b);
    }

    ////recursive BFS
    public static int bfsr(int s,ArrayList<Integer>[] a,int[] dist,boolean[] b,int[] pre){
        b[s]=true;
        int p = 0;
        int t = a[s].size();
        for(int i=0;i<t;i++){
            int x = a[s].get(i);
            if(!b[x]){
                dist[x] = dist[s] + 1;
                p+= (bfsr(x,a,dist,b,pre)+1);
            }
        }
        pre[s] = p;
        return p;
    }

//// iterative BFS
    public static int bfs(int s,ArrayList<Integer>[] a,int[] dist,boolean[] b,PrintWriter w){
        b[s]=true;
        int siz = 0;

        Queue<Integer> q = new LinkedList<>();
        q.add(s);
        while(q.size()!=0){
            int i=q.poll();
            Iterator<Integer> it = a[i].listIterator();
            int z=0;
            while(it.hasNext()){
                z=it.next();
                if(!b[z]){
                    b[z]=true;
                    dist[z] = dist[i] + 1;
                    siz++;
                    q.add(z);
                }
            }

        }
        return siz;
    }

//////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////

    public void run()
    {
        InputReader sc = new InputReader(System.in);
        PrintWriter w = new PrintWriter(System.out);
        int defaultValue=0;

        int tc = sc.nextInt();

        while(tc-->0){

            int n = sc.nextInt();
            String[] s = new String[n];
            int[] h = new int[201];
            for(int i=0;i<n;i++){
                s[i] = sc.next();
            }
            for(int i=0;i<n;i++){
                for(int j=0;j<s[i].length();j++){
                    h[(int)s[i].charAt(j)]++;
                }
            }
            boolean f = true;
            for(int i=0;i<201;i++){
                if(h[i]%n!=0){
                    f = false;
                    break;
                }
            }

            if(f)w.println("YES");
            else w.println("NO");

       }
        w.flush();
        w.close();
    }

}