#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define pr pair<int,int>
#define mod 1000000007
#define endl "\n"

int power(int a,int b,int m=mod)
{
	if(b==0)	return 1;
	if(b==1)	return a;
	int res=power(a,b/2,m);
	res=(res*res)%m;
	if(b&1)	res=(res*a)%m;
	return res;
}
int modinv(int a,int m=mod){ return power(a,m-2,m);}
int add(int a,int b,int m=mod){	int c=(a%m+b%m);	if(c>=m)	c-=m;	return c;}
int sub(int a,int b,int m=mod){	int c=(a%m-b%m);	if(c<0)		c+=m;	return c;}
int mul(int a,int b,int m=mod){	return (a*b)%m;}
//	x<<1 => x*2		x>>1 => x/2;	cout<<flush;
//	cout<<fixed<<setprecision(10)<<ans<<endl;

int fun(string s){
    for(int i=0;i<s.size()/2;i++){
        if(s[i]!=s[s.size()-1-i]){
            return 0;
        }
    }
    return 1;
}

void solve()
{
	int n,m,i,j,x=0,k,f;
	cin >> n >> m ;
	vector<int> v(n),z(n);
	string s[n];
	vector<string> str,str1;
	for(i=0;i<n;i++){
	    cin >> s[i];
	    v[i]=fun(s[i]);
	}
	for(i=0;i<n-1;i++){
	    if(z[i]==1)continue;
	    for(j=i+1;j<n;j++){
	        f=0;
	        for(k=0;k<m;k++){
	            if(s[i][k]!=s[j][k]){
	                f=1;break;
	            }
	        }
	        if(f==0){
	            x+=2;v[i]=0;v[j]=0;z[i]=1;z[j]=1;
	            str.pb(s[i]);str1.pb(s[j]);
	            break;
	        }
	        else{
	            f=0;
	        }
	    }
	}
	for(i=0;i<n;i++){
	    if(v[i]==1){
	        x++;
	        break;
	    }
	}
	cout << x << endl;

	for(i=0;i<str.size();i++){
	    cout << str[i] ;
	}
	for(i=0;i<n;i++){
	    if(v[i]==1){
	        cout << s[i];
	        break;
	    }
	}
	for(i=str1.size()-1;i>=0;i--){
	    cout << str1[i];
	}
	cout << endl;
}

int32_t main()
{
	ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
	int t=1;//cin>>t;
	for(int i=1;i<=t;i++){	solve();}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define pr pair<int,int>
#define mod 1000000007
#define endl "\n"

int power(int a,int b,int m=mod)
{
	if(b==0)	return 1;
	if(b==1)	return a;
	int res=power(a,b/2,m);
	res=(res*res)%m;
	if(b&1)	res=(res*a)%m;
	return res;
}
int modinv(int a,int m=mod){ return power(a,m-2,m);}
int add(int a,int b,int m=mod){	int c=(a%m+b%m);	if(c>=m)	c-=m;	return c;}
int sub(int a,int b,int m=mod){	int c=(a%m-b%m);	if(c<0)		c+=m;	return c;}
int mul(int a,int b,int m=mod){	return (a*b)%m;}
//	x<<1 => x*2		x>>1 => x/2;	cout<<flush;
//	cout<<fixed<<setprecision(10)<<ans<<endl;

set<string> sett;
void solve()
{
	int n,m,i,j,x=0,k,f;
	cin >> n >> m ;
	string s,str1="",str2="",q="",temp;
	for(i=0;i<n;i++){
	    cin >> s;
	    temp=s;
	    reverse(temp.begin(),temp.end());
	    if(temp==s){q=s;}
	    else if(sett.count(temp)==1){
	        x+=2;
	        str1+=temp;
	        str2=s+str2;
	    }
	    sett.insert(s);
	}
	if(q.empty())x++;
	cout << x << endl << str1 << q << str2;
	cout << endl;
}

int32_t main()
{
	ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
	int t=1;//cin>>t;
	for(int i=1;i<=t;i++){	solve();}
	return 0;
}


#include <bits/stdc++.h>
//in the name of god;;
using namespace std;
typedef long long ll;
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
 string sez(string ss){
 	string T; for(ll i = ss.size() - 1; i >= 0; --i)T += ss[i];
 	return T;
 }
 const ll MAXN = 1000;
 ll n, m, T; string s[MAXN], F1, F2, F3;
 int main(){
 	cin >> n >> m;
 	for(ll i = 0; i < n; ++i)cin >> s[i];
 	for(ll i = 0; i < n; ++i){
 		for(ll j = 0; j < n; ++j){
 			if(i != j && s[i] != "/" && s[j] != "/"){
 				if(sez(s[i]) == s[j]){
 					F1 += s[i], F2 += s[j];
 				    s[i] = "/"; s[j] = "/";
 				}
		    }
	    }
    }
    for(ll i = 0; i < n; ++i)
    	if(s[i] != "/" && sez(s[i]) == s[i] && T == 0)F3 += s[i], T = -1;
	return cout << F1.size()+F2.size()+F3.size() << "\n" << F1 << F3 << F2, 0;
 }


#include <bits/stdc++.h>
//in the name of god;;
using namespace std;
typedef long long ll;
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
 const ll MAXN = 1000;
 ll n, m, T; string s[MAXN], F1, F2, F3;
 int main(){
 	cin >> n >> m;
 	for(ll i = 0; i < n; ++i)cin >> s[i];
 	for(ll i = 0; i < n; ++i){
 		for(ll j = i + 1; j < n; ++j){
 			if(i != j && s[i] != "/" && s[j] != "/"){
 				reverse(s[j].begin(), s[j].end());
 				if(s[i] == s[j]){
 					F1 += s[i], F2 += s[j];
 				    s[i] = "/"; s[j] = "/";
 				}
		    }
	    }
    }
    for(ll i = 0; i < n; ++i){
    	string R = s[i];
        reverse(s[i].begin(), s[i].end());
    	if(s[i] != "/" && R == s[i] && s[i].size() > F3.size())F3 = s[i];
    }
   	ll p = F1.size()+F2.size()+F3.size(); cout << p << "\n";
   	if(p == 0)return 0;
   	reverse(F2.begin(), F2.end());
   	cout << F1 << F3 << F2;
 }


#include <bits/stdc++.h>
///at the moment...
using namespace std;
typedef long long ll;

 int main(){
    ll n, m;
    cin >> n >> m;
    vector <string> v;
    // vector <pair<char, char> > l;
    while(n--){
    	string s;
    	cin >> s;
    	v.push_back(s);
	}
	for ( ll i = 0; i < v.size(); ++i ){
		for ( ll j = i+1; j < v.size(); ++j ){
			string Q="";
			for ( ll k = v[i].size() - 1; k >= 0; --k ){
				Q += v[i][k];
			}
			if (Q == v[j]){
				cout << "2\n" << v[i] << v[j];
				return 0;
			}
			//l.push_back({v[i], v[j]});
		}
	}
	cout << "-1";
	//cout << v[0].first << v[0].second;
 }


#include <bits/stdc++.h>
//in the name of god;;
using namespace std;
typedef long long ll;
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
 string sez(string ss){
 	string T; for(ll i = ss.size() - 1; i >= 0; --i)T += ss[i];
 	return T;
 }
 const ll MAXN = 1000;
 ll n, m, T; string s[MAXN], F1, F2, F3;
 int main(){
 	cin >> n >> m;
 	for(ll i = 0; i < n; ++i)cin >> s[i];
 	for(ll i = 0; i < n; ++i){
 		for(ll j = 0; j < n; ++j){
 			if(i != j && s[i] != "/" && s[j] != "/"){
 				if(sez(s[i]) == s[j]){
 					F1 += s[i], F2 += sez(s[j]);
 				    s[i] = "/"; s[j] = "/";
 				}
		    }
	    }
    }
    for(ll i = 0; i < n; ++i)
    	if(s[i] != "/" && sez(s[i]) == s[i] && s[i].size() > F3.size())F3 = s[i];
   	cout << F1.size()+F2.size()+F3.size() << "\n";
   	cout << F1 << F3;for(ll i = F2.size() - 1; i >= 0; --i)cout << F2[i];
 }


#include <bits/stdc++.h>
//1 + 1 == 3(?!);
//in the name of god;
using namespace std;
typedef long long ll;
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define vc vector<ll>
 bool PL(string s){
 	for(ll i = 0, j = s.size() - 1; i < s.size(); ++i, --j){
 		if(s[i] != s[j])return false;
    }
    return true;
 }
 const ll MAXN = 200;
 ll N, M;
 string s[MAXN], P, P1, P2;
 int main(){
 	fastio;
 	cin >> N >> M;
 	for(ll i = 0; i < N; ++i)cin >> s[i];
 	for(ll i = 0; i < N; ++i){
 		for(ll j = 0; j < N; ++j){
 			reverse(s[j].begin(), s[j].end());
 			if(s[i] == s[j] && s[i] != "/" && s[j] != "/" && i != j){
 				P1 += s[i]; P2 += s[j]; s[i] = "/"; s[j] = "/";
    		}
	    }
	    if(s[i] != "/" && PL(s[i])>0 && s[i].size() > P.size())P = s[i];
    }
    reverse(P2.begin(), P2.end());
    cout << P.size() + P1.size() + P2.size() << "\n";
    cout << P1 << P << P2;
  }


#include <bits/stdc++.h>
///at the moment...
using namespace std;
typedef long long ll;
 string pl(string l){
 	string q="";
 	for ( ll i = l.size() - 1; i >= 0; --i ){
 		q += l[i];
    }
    return q;
 }
 bool sez(string y){
 	ll A = (y.size() % 2 > 0 ? A = y.size() / 2 : A = y.size()/2-1 );
 	ll ind=0;
 	for ( ll i = 0, j = y.size() - 1; i <= A; ++i, --j){
 		if (y[i] == y[j])++ind;
    }
    if(y.size() % 2 > 0){
    	if(y.size()/2+1 == ind){
    		return true;
		}
		else return false;
	}
	else{
		if(y.size()/2 == ind){
			return true;
		}
		else return false;
	}
 }
 int main(){
    ll n, m;
    cin >> n >> m;
    vector <string> v, C;
    string P="", E="", F="";
    while(n--){
    	string s;
    	cin >> s;
    	v.push_back(s);
	}
	for ( ll i = 0; i < v.size(); ++i ){
		for ( ll j = i + 1; j < v.size(); ++j ){
			if ( pl(v[i]) == v[j] ){
				P += v[i];
				E += v[j];
			}
		}
	}
    for ( ll i = 0; i < v.size(); ++i ){
    	int f=1;
    	for ( ll j = 0; j < v.size(); ++j ){
    		if (v[i] == v[j] && i != j){
    			f=-1;
			}
		}
		if(f > 0 && sez(v[i]) > 0)C.push_back(v[i]);
	}
    ll MX = -1;
	for ( ll i = 0; i < C.size(); ++i ){
		ll d=C[i].size();
		MX = max(MX, d);
	}
	for ( ll i = 0; i < C.size(); ++i ){
		if (C[i].size() == MX){
			F=C[i];
			break;
		}
	}
	if (E.size() + P.size() + F.size() > 0)cout << E.size()+P.size()+F.size() << "\n" << E << F << P;
	else cout << "-1";
 }


#include <bits/stdc++.h>
//1 + 1 == 3(?!);
//in the name of god;
using namespace std;
typedef long long ll;
    string pl(string t){
 			string k;
 			for ( ll i = t.size()-1; i >= 0; --i )k += t[i];
 			return k;
    }
    bool sez(string y){
 	ll A = (y.size() % 2 > 0 ? A = y.size() / 2 : A = y.size()/2-1 );
 	ll ind=0;
 	for ( ll i = 0, j = y.size() - 1; i <= A; ++i, --j){
 		if (y[i] == y[j])++ind;
    }
    if(y.size() % 2 > 0){
    	if(y.size()/2+1 == ind){
    		return true;
		}
		else return false;
	}
	else{
		if(y.size()/2 == ind){
			return true;
		}
		else return false;
	}
 }
 int main(){
	ll n, m; cin >> n >> m;
	string x[n + 10000];
	string E="",P="",o="";
	vector <string> c;
	for ( ll i = 0; i < n; ++i )cin >> x[i];
	for ( ll i = 0; i < n; ++i ){
		for ( ll j = i + 1; j < n; ++j ){
			if (pl(x[i]) == x[j]){
				E += x[i]; P += pl(x[j]);
			}
		}
	}
	for ( ll i = 0; i < n; ++i ){
		int F=1;
		for ( ll j = 0; j < n; ++j ){
			if (i != j && x[i] == x[j]){
			    F=-1;
			}
		}
		if (sez(x[i]) == 1 && F > 0)c.push_back(x[i]);
	}
	ll MX=-1;
	for ( ll i = 0; i < c.size(); ++i ){
		ll r = c[i].size();
		MX = max(MX, r);
	}
	for ( ll i = 0; i < c.size(); ++i ){
		if (c[i].size() == MX){
			o=c[i];break;
		}
	}
	if(E.size()+o.size()+P.size() > 0){
	cout<<E.size()+o.size()+P.size()<<"\n"<<E<<o;for(ll i = P.size()-1; i >= 0; --i)cout<<P[i];
    }
	else cout << "0\n";
  }


#include <bits/stdc++.h>
///at the moment...
using namespace std;
typedef long long ll;
 string pl(string l){
 	string q="";
 	for ( ll i = l.size() - 1; i >= 0; --i ){
 		q += l[i];
    }
    return q;
 }
 bool sez(string y){
 	ll A = (y.size() % 2 > 0 ? A = y.size() / 2 : A = y.size()/2-1 );
 	ll ind=0;
 	for ( ll i = 0, j = y.size() - 1; i <= A; ++i, --j){
 		if (y[i] == y[j])++ind;
    }
    if(y.size() % 2 > 0){
    	if(y.size()/2+1 == ind){
    		return true;
		}
		else return false;
	}
	else{
		if(y.size()/2 == ind){
			return true;
		}
		else return false;
	}
 }
 int main(){
    ll n, m;
    cin >> n >> m;
    vector <string> v, C;
    string P="", E="", F="";
    while(n--){
    	string s;
    	cin >> s;
    	v.push_back(s);
	}
	for ( ll i = 0; i < v.size(); ++i ){
		for ( ll j = i + 1; j < v.size(); ++j ){
			if ( pl(v[i]) == v[j] ){
				P += v[i];
				E += v[j];
			}
		}
	}
    for ( ll i = 0; i < v.size(); ++i ){
    	int f=1;
    	for ( ll j = 0; j < v.size(); ++j ){
    		if (v[i] == v[j] && i != j){
    			f=-1;
			}
		}
		if(f > 0 && sez(v[i]) > 0)C.push_back(v[i]);
	}
    ll MX = -1;
	for ( ll i = 0; i < C.size(); ++i ){
		ll d=C[i].size();
		MX = max(MX, d);
	}
	for ( ll i = 0; i < C.size(); ++i ){
		if (C[i].size() == MX){
			F=C[i];
			break;
		}
	}
	if (E.size() + P.size() + F.size() > 0)cout << E.size()+P.size()+F.size() << "\n" << E << F << P;
	else cout << "0";
 }


#include <bits/stdc++.h>
///at the moment...
using namespace std;
typedef long long ll;
 string pl(string l){
 	string q="";
 	for ( ll i = l.size() - 1; i >= 0; --i ){
 		q += l[i];
    }
    return q;
 }
 bool sez(string y){
 	ll A = (y.size() % 2 > 0 ? A = y.size() / 2 : A = y.size()/2-1 );
 	ll ind=0;
 	for ( ll i = 0, j = y.size() - 1; i <= A; ++i, --j){
 		if (y[i] == y[j])++ind;
    }
    if(y.size() % 2 > 0){
    	if(y.size()/2+1 == ind){
    		return true;
		}
		else return false;
	}
	else{
		if(y.size()/2 == ind){
			return true;
		}
		else return false;
	}
 }
 int main(){
    ll n, m;
    cin >> n >> m;
    vector <string> v, C;
    string P="", E="", F="";
    while(n--){
    	string s;
    	cin >> s;
    	v.push_back(s);
	}
	for ( ll i = 0; i < v.size(); ++i ){
		for ( ll j = i + 1; j < v.size(); ++j ){
			if ( pl(v[i]) == v[j] ){
				P += v[i];
				E += pl(v[j]);
			}
		}
	}
    for ( ll i = 0; i < v.size(); ++i ){
    	int f=1;
    	for ( ll j = 0; j < v.size(); ++j ){
    		if (v[i] == v[j] && i != j){
    			f=-1;
			}
		}
		if(f > 0 && sez(v[i]) > 0)C.push_back(v[i]);
	}
    ll MX = -1;
	for ( ll i = 0; i < C.size(); ++i ){
		ll d=C[i].size();
		MX = max(MX, d);
	}
	for ( ll i = 0; i < C.size(); ++i ){
		if (C[i].size() == MX){
			F=C[i];
			break;
		}
	}
	if (E.size() + P.size() + F.size() > 0){
		cout << E.size()+P.size()+F.size() << "\n" << E << F;
		for ( ll i = P.size() - 1; i >= 0; --i )cout << P[i];
	}
	else cout << "0";
 }


#include <bits/stdc++.h>
///at the moment...
using namespace std;
typedef long long ll;
 string pl(string l){
 	string q="";
 	for ( ll i = l.size() - 1; i >= 0; --i ){
 		q += l[i];
    }
    return q;
 }
 bool sez(string y){
 	ll A = (y.size() % 2 > 0 ? A = y.size() / 2 : A = y.size()/2-1 );
 	ll ind=0;
 	for ( ll i = 0, j = y.size() - 1; i <= A; ++i, --j){
 		if (y[i] == y[j])++ind;
    }
    if(y.size() % 2 > 0){
    	if(y.size()/2+1 == ind){
    		return true;
		}
		else return false;
	}
	else{
		if(y.size()/2 == ind){
			return true;
		}
		else return false;
	}
 }
 int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, m;
    cin >> n >> m;
    vector <string> v, C;
    string P="", E="", F="";
    while(n--){
    	string s;
    	cin >> s;
    	v.push_back(s);
	}
	for ( ll i = 0; i < v.size(); ++i ){
		for ( ll j = i + 1; j < v.size(); ++j ){
			if ( pl(v[i]) == v[j] ){
				P += v[i];
				E += pl(v[j]);
			}
		}
	}
    for ( ll i = 0; i < v.size(); ++i ){
    	int f=1;
    	for ( ll j = 0; j < v.size(); ++j ){
    		if (v[i] == v[j] && i != j){
    			f=-1;
			}
		}
		if(f > 0 && sez(v[i]) > 0)C.push_back(v[i]);
	}
    ll MX = -1;
	for ( ll i = 0; i < C.size(); ++i ){
		ll d=C[i].size();
		MX = max(MX, d);
	}
	for ( ll i = 0; i < C.size(); ++i ){
		if (C[i].size() == MX){
			F=C[i];
			break;
		}
	}
	if (E.size() + P.size() + F.size() > 0){
		cout << E.size()+P.size()+F.size() << "\n" << E << F;
		for ( ll i = P.size() - 1; i >= 0; --i )cout << P[i];
	}
	else cout << "0";
 }


#include <bits/stdc++.h>
//in the name of god;;
using namespace std;
typedef long long ll;
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
 string sez(string ss){
 	string T; for(ll i = ss.size() - 1; i >= 0; --i)T += ss[i];
 	return T;
 }
 const ll MAXN = 1000;
 ll n, m, T; string s[MAXN], F1, F2, F3;
 int main(){
 	cin >> n >> m;
 	for(ll i = 0; i < n; ++i)cin >> s[i];
 	for(ll i = 0; i < n; ++i){
 		for(ll j = 0; j < n; ++j){
 			if(i != j && s[i] != "/" && s[j] != "/"){
 				if(sez(s[i]) == s[j]){
 					F1 += s[i], F2 += sez(s[j]);
 				    s[i] = "/"; s[j] = "/";
 				}
		    }
	    }
    }
    for(ll i = 0; i < n; ++i)
    	if(s[i] != "/" && sez(s[i]) == s[i] && s[i].size() > F3.size())F3 = s[i];
   	ll p = F1.size()+F2.size()+F3.size(); cout << p << "\n";
   	if(p == 0)return 0;
   	cout << F1 << F3 << sez(F2);
 }


#include <bits/stdc++.h>
///at the moment...
using namespace std;
typedef long long ll;

 int main(){
    ll n, m;
    cin >> n >> m;
    vector <string> v;
    // vector <pair<char, char> > l;
    while(n--){
    	string s;
    	cin >> s;
    	v.push_back(s);
	}
	for ( ll i = 0; i < v.size(); ++i ){
		for ( ll j = i+1; j < v.size(); ++j ){
			string Q="";
			for ( ll k = v[i].size() - 1; k >= 0; --k ){
				Q += v[i][k];
			}
			if (Q == v[j]){
				cout << v[i].size()+v[j].size() << "\n" << v[i] << v[j];
				return 0;
			}
			//l.push_back({v[i], v[j]});
		}
	}
	cout << "-1";
	//cout << v[0].first << v[0].second;
 }


#include <iostream>
#include <string>
#include <queue>

using namespace std;

int n, m, l;
pair<int, int> x;
queue<pair<int,int>> id;
string s;

int check_palindrome(string s) {
    int length = 0;
    for (int i = 0; i < s.size() / 2; i++) {
        if (s[i] == s[s.size()-1 - i]) {length++; continue;}
        length = 0;
        break;
    }
    return length * (2 + s.size() % 2);
}

int main(void) {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);

    cin >> n >> m;
    string *S = new string[n];

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

    /// Case of one element
    if (m == 1) {
        cout << 1 << "\n" << S[0];
        return 0;
    }

    /// Case of more element
    // check self whether is a palindrome
    int max_value = 0, max_index = -1;
    l = 0; total = 0;
    for (int i = 0; i < n; i++) {
        l = check_palindrome(S[i]);
        if (max_value < l) {
            max_value = l;
            max_index = i;
        }
    }
    s = max_index == -1 ? "\0" : S[max_index];

    //
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            l = check_palindrome(S[i] + S[j]);
            if (l) {
                id.push(pair<int,int>(i, j));
            }
        }
    }

    while (!id.empty()) {
        x = id.front();
        s = S[x.first] + s + S[x.second];
        id.pop();
    }

    cout << s.size() << "\n" << s;
    return 0;

}


#include <iostream>
#include <string>
#include <queue>

using namespace std;

int n, m, i, j;
pair<int, int> x;
queue<pair<int,int>> id;
string s;

int check_palindrome(string s) {
    int length = 0;
    for (int i = 0; i < s.size() / 2; i++) {
        if (s[i] == s[s.size()-1 - i]) {length++; continue;}
        length = 0;
        break;
    }
    return length * (2 + s.size() % 2);
}

int main(void) {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);

    cin >> n >> m;
    string *S = new string[n];

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

    /// Case of one element
    if (m == 1) { cout << 1 << "\n" << S[0]; return 0; }

    /// Case of more element
    // check self whether is a palindrome
    for (i = 0; i < n; i++)
        if (0 < check_palindrome(S[i])) break;
    s = i == n ? "\0" : S[i]; // if i == n, that was there are no palindrome.

    //
    for (i = 0; i < n; i++)
        for (j = i + 1; j < n; j++)
            if (check_palindrome(S[i] + S[j])) id.push(pair<int,int>(i, j));

    while (!id.empty()) {
        x = id.front();
        s = S[x.first] + s + S[x.second];
        id.pop();
    }

    cout << s.size() << "\n" << s;
    return 0;
}


#include <iostream>
#include <string>
#include <queue>

using namespace std;

long long int n, m, l, total;
pair<int, int> x;
queue<pair<int,int>> id;
string s;

int check_palindrome(string s) {
    int length = 0;
    for (int i = 0; i < s.size() / 2; i++) {
        if (s[i] == s[s.size()-1 - i]) {length++; continue;}
        length = 0;
        break;
    }
    return length * (2 + s.size() % 2);
}

int main(void) {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);

    cin >> n >> m;
    string *S = new string[n];

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

    if (m == 1) {
        cout << 1 << "\n" << S[0];
        return 0;
    }

    int max_value = 0, max_index = -1;
    l = 0; total = 0;
    for (int i = 0; i < n; i++) {
        l = check_palindrome(S[i]);
        if (max_value < l) {
            max_value = l;
            max_index = i;
        }
    }
    s = max_index == -1 ? "\0" : S[max_index];
    total += max_value;

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            l = check_palindrome(S[i] + S[j]);
            if (l) {
                id.push(pair<int,int>(i, j));
                total += l;
            }
        }
    }

    while (!id.empty()) {
        x = id.front();
        s = S[x.first] + s + S[x.second];
        id.pop();
    }

    cout << s.size() << "\n" << s;
    return 0;

}


#include <iostream>
#include <string>
#include <queue>

using namespace std;

long long int n, m, l, total;
pair<int, int> x;
queue<pair<int,int>> id;
string s;

int check_palindrome(string s) {
    int length = 0;
    for (int i = 0; i < s.size() / 2; i++) {
        if (s[i] == s[s.size()-1 - i]) {length++; continue;}
        length = 0;
        break;
    }
    return length * (2 + s.size() % 2);
}

int main(void) {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);

    cin >> n >> m;
    string *S = new string[n];

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

    if (m == 1) {
        cout << 1 << "\n" << S[m];
        return 0;
    }

    int max_value = 0, max_index = -1;
    l = 0; total = 0;
    for (int i = 0; i < n; i++) {
        l = check_palindrome(S[i]);
        if (max_value < l) {
            max_value = l;
            max_index = i;
        }
    }
    s = max_index == -1 ? "\0" : S[max_index];
    total += max_value;

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            l = check_palindrome(S[i] + S[j]);
            if (l) {
                id.push(pair<int,int>(i, j));
                total += l;
            }
        }
    }

    while (!id.empty()) {
        x = id.front();
        s = S[x.first] + s + S[x.second];
        id.pop();
    }

    cout << s.size() << "\n" << s;
    return 0;

}


#include <iostream>
#include <string>
#include <queue>

using namespace std;

int n, m, l, total;
pair<int, int> x;
queue<pair<int,int>> id;
string s;

int check_palindrome(string s) {
    int length = 0;
    for (int i = 0; i < s.size() / 2; i++) {
        if (s[i] == s[s.size()-1 - i]) {length++; continue;}
        length = 0;
        break;
    }
    return length * (2 + s.size() % 2);
}

int main(void) {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);

    cin >> n >> m;
    string *S = new string[n];

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

    if (m == 1) {
        cout << 1 << "\n" << S[m];
        return 0;
    }

    int max_value = 0, max_index = -1;
    l = 0; total = 0;
    for (int i = 0; i < n; i++) {
        l = check_palindrome(S[i]);
        if (max_value < l) {
            max_value = l;
            max_index = i;
        }
    }
    s = max_index == -1 ? "\0" : S[max_index];
    total += max_value;

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            l = check_palindrome(S[i] + S[j]);
            if (l) {
                id.push(pair<int,int>(i, j));
                total += l;
            }
        }
    }

    while (!id.empty()) {
        x = id.front();
        s = S[x.first] + s + S[x.second];
        id.pop();
    }

    cout << total << "\n" << s;
    return 0;

}


#include <iostream>
#include <string>
#include <queue>

using namespace std;

long long int n, m, l, total;
pair<int, int> x;
queue<pair<int,int>> id;
string s;

int check_palindrome(string s) {
    int length = 0;
    for (int i = 0; i < s.size() / 2; i++) {
        if (s[i] == s[s.size()-1 - i]) {length++; continue;}
        length = 0;
        break;
    }
    return length * (2 + s.size() % 2);
}

int main(void) {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);

    cin >> n >> m;
    string *S = new string[n];

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

    if (m == 1) {
        cout << 1 << "\n" << S[m];
        return 0;
    }

    int max_value = 0, max_index = -1;
    l = 0; total = 0;
    for (int i = 0; i < n; i++) {
        l = check_palindrome(S[i]);
        if (max_value < l) {
            max_value = l;
            max_index = i;
        }
    }
    s = max_index == -1 ? "\0" : S[max_index];
    total += max_value;

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            l = check_palindrome(S[i] + S[j]);
            if (l) {
                id.push(pair<int,int>(i, j));
                total += l;
            }
        }
    }

    while (!id.empty()) {
        x = id.front();
        s = S[x.first] + s + S[x.second];
        id.pop();
    }

    cout << total << "\n" << s;
    return 0;

}


#include <iostream>
#include <string>
#include <queue>

using namespace std;

int n, m, l, total = 0;
pair<int, int> x;
queue<pair<int,int>> id;
string s;

int check_palindrome(string s) {
    int length = 0;
    for (int i = 0; i < s.size() / 2; i++) {
        if (s[i] == s[s.size()-1 - i]) {length++; continue;}
        length = 0;
        break;
    }
    return length * (2 + s.size() % 2);
}

int main(void) {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);

    scanf("%d%d", &n, &m);
    string *S = new string[n];

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

    int max_value = 0, max_index = -1;
    l = 0;
    for (int i = 0; i < n; i++) {
        l = check_palindrome(S[i]);
        if (max_value < l) {
            max_value = l;
            max_index = i;
        }
    }
    s = max_index == -1 ? "\0" : S[max_index];
    total += max_value;

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            l = check_palindrome(S[i] + S[j]);
            if (l) {
                id.push(pair<int,int>(i, j));
                total += l;
            }
        }
    }

    while (!id.empty()) {
        x = id.front();
        s = S[x.first] + s + S[x.second];
        id.pop();
    }

    cout << total << "\n" << s;

}


#include <iostream>
#include <string>
#include <queue>

using namespace std;

int n, m, l = 0, max_value = 0, max_index = -1;
pair<int, int> x;
queue<pair<int,int>> id;
string s;

int check_palindrome(string s) {
    int length = 0;
    for (int i = 0; i < s.size() / 2; i++) {
        if (s[i] == s[s.size()-1 - i]) {length++; continue;}
        length = 0;
        break;
    }
    return length * (2 + s.size() % 2);
}

int main(void) {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);

    cin >> n >> m;
    string *S = new string[n];

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

    /// Case of one element
    if (m == 1) {
        cout << 1 << "\n" << S[0];
        return 0;
    }

    /// Case of more element
    // check self whether is a palindrome
    for (int i = 0; i < n; i++) {
        l = check_palindrome(S[i]);
        if (max_value < l) {
            max_value = l;
            max_index = i;
        }
    }
    s = max_index == -1 ? "\0" : S[max_index];

    //
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            l = check_palindrome(S[i] + S[j]);
            if (l) {
                id.push(pair<int,int>(i, j));
            }
        }
    }

    while (!id.empty()) {
        x = id.front();
        s = S[x.first] + s + S[x.second];
        id.pop();
    }

    cout << s.size() << "\n" << s;
    return 0;

}


#include <iostream>
#include <string>
#include <queue>

using namespace std;

int n, m, l = 0, max_value = 0, max_index = -1;
pair<int, int> x;
queue<pair<int,int>> id;
string s;

int check_palindrome(string s) {
    int length = 0;
    for (int i = 0; i < s.size() / 2; i++) {
        if (s[i] == s[s.size()-1 - i]) {length++; continue;}
        length = 0;
        break;
    }
    return length * (2 + s.size() % 2);
}

int main(void) {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);

    cin >> n >> m;
    string *S = new string[n];

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

    /// Case of one element
    if (m == 1) {
        cout << 1 << "\n" << S[0];
        return 0;
    }

    /// Case of more element
    // check self whether is a palindrome
    for (int i = 0; i < n; i++) {
        l = check_palindrome(S[i]);
        if (max_value < l) {
            max_value = l;
            max_index = i;
        }
    }
    s = max_index == -1 ? "\0" : S[max_index];

    //
    for (int i = 0; i < n; i++)
        for (int j = i + 1; j < n; j++) {
            l = check_palindrome(S[i] + S[j]);
            if (l) id.push(pair<int,int>(i, j));
        }

    while (!id.empty()) {
        x = id.front();
        s = S[x.first] + s + S[x.second];
        id.pop();
    }

    cout << s.size() << "\n" << s;
    return 0;
}


#include <iostream>
#include <string>
#include <queue>

using namespace std;

int n, m, i, j;
pair<int, int> x;
queue<pair<int,int>> id;
string s;

int check_palindrome(string s) {
    int length = 0;
    for (int i = 0; i < s.size() / 2; i++) {
        if (s[i] == s[s.size()-1 - i]) {length++; continue;}
        length = 0;
        break;
    }
    return length * (2 + s.size() % 2);
}

int main(void) {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);

    cin >> n >> m;
    string *S = new string[n];

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

    /// Case of one element
    if (m == 1) {
        cout << 1 << "\n" << S[0];
        return 0;
    }

    /// Case of more element
    // check self whether is a palindrome
    for (i = 0; i < n; i++) {
        if (0 < check_palindrome(S[i])) {
            break;
        }
    }
    s = i == n ? "\0" : S[i]; // if i == n, that was there are no palindrome.

    //
    for (i = 0; i < n; i++)
        for (j = i + 1; j < n; j++)
            if (check_palindrome(S[i] + S[j])) id.push(pair<int,int>(i, j));

    while (!id.empty()) {
        x = id.front();
        s = S[x.first] + s + S[x.second];
        id.pop();
    }

    cout << s.size() << "\n" << s;
    return 0;
}


#include <iostream>
#include <string>
#include <queue>

using namespace std;

int n, m, l, total;
pair<int, int> x;
queue<pair<int,int>> id;
string s;

int check_palindrome(string s) {
    int length = 0;
    for (int i = 0; i < s.size() / 2; i++) {
        if (s[i] == s[s.size()-1 - i]) {length++; continue;}
        length = 0;
        break;
    }
    return length * (2 + s.size() % 2);
}

int main(void) {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);

    scanf("%d%d", &n, &m);
    string *S = new string[n];

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

    int max_value = 0, max_index = -1;
    l = 0; total = 0;
    for (int i = 0; i < n; i++) {
        l = check_palindrome(S[i]);
        if (max_value < l) {
            max_value = l;
            max_index = i;
        }
    }
    s = max_index == -1 ? "\0" : S[max_index];
    total += max_value;
    cout << total << "\n" << s; return 0;


#include <iostream>
#include <string>
#include <queue>

using namespace std;

int n, m, l, total;
pair<int, int> x;
queue<pair<int,int>> id;
string s;

int check_palindrome(string s) {
    int length = 0;
    for (int i = 0; i < s.size() / 2; i++) {
        if (s[i] == s[s.size()-1 - i]) {length++; continue;}
        length = 0;
        break;
    }
    return length * (2 + s.size() % 2);
}

int main(void) {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);

    scanf("%d%d", &n, &m);
    string *S = new string[n];

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

    int max_value = 0, max_index = -1;
    l = 0; total = 0;
    for (int i = 0; i < n; i++) {
        l = check_palindrome(S[i]);
        if (max_value < l) {
            max_value = l;
            max_index = i;
        }
    }
    s = max_index == -1 ? "\0" : S[max_index];
    total += max_value;

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            l = check_palindrome(S[i] + S[j]);
            if (l) {
                id.push(pair<int,int>(i, j));
                total += l;
            }
        }
    }

    while (!id.empty()) {
        x = id.front();
        s = S[x.first] + s + S[x.second];
        id.pop();
    }

    cout << total << "\n" << s;

}


#include <iostream>
#include <string>
#include <queue>
using namespace std;
int n, m, i, j;
pair<int, int> x;
queue<pair<int,int>> id;
string s;
int check_palindrome(string s) {
    int length = 0;
    for (int i = 0; i < s.size() / 2; i++) {
        if (s[i] == s[s.size()-1 - i]) {length++; continue;}
        length = 0;
        break;
    }
    return length * (2 + s.size() % 2);
}
int main(void) {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    cin >> n >> m;
    string *S = new string[n];
    for (i = 0; i < n; i++) cin >> S[i];
    if (m == 1) { cout << 1 << "\n" << S[0]; return 0; }
    for (i = 0; i < n; i++)
        if (0 < check_palindrome(S[i])) break;
    s = i == n ? "\0" : S[i];
    for (i = 0; i < n; i++)
        for (j = i + 1; j < n; j++)
            if (check_palindrome(S[i] + S[j])) id.push(pair<int,int>(i, j));
    while (!id.empty()) {
        x = id.front();
        s = S[x.first] + s + S[x.second];
        id.pop();
    }
    cout << s.size() << "\n" << s;
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, m;
    cin >> n >> m;
    set<string> single;
    string maxplan = "";
    while (n)
    {
        n--;
        string x;
        cin >> x;
        string xrev = x;
        reverse(xrev.begin(), xrev.end());
        if (x == xrev)
        {
            maxplan = x;
        }
        else
        {
            single.insert(x);
        }
    }

    string answer = maxplan;

    std::set<std::string>::iterator it = single.begin();
    while (it != single.end())
    {
        string rks = *it;
        reverse(rks.begin(), rks.end());
        if (single.count(rks))
        {
            if (single.count(answer))
            {
                single.erase(answer);
            }
            answer = *it + answer + rks;

            single.erase(rks);
            single.erase(*it);

            single.insert(answer);
        }
        it++;
    }
    cout << answer.length() << endl
         << answer;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, m;
    cin >> n >> m;
    set<string> single;
    string maxplan = "";
    while (n)
    {
        n--;
        string x;
        cin >> x;
        string xrev = x;
        reverse(xrev.begin(), xrev.end());
        if (x == xrev)
        {
            maxplan = x;
        }
        else
        {
            single.insert(x);
        }
    }

    string answer = maxplan;

    std::set<std::string>::iterator it = single.begin();
    while (it != single.end() && single.size() > 2)
    {
        string rks = *it;
        reverse(rks.begin(), rks.end());
        if (single.count(rks))
        {
            if (single.count(answer))
            {
                single.erase(answer);
            }
            answer = *it + answer + rks;

            single.erase(rks);
            single.erase(*it);

            single.insert(answer);
        }
        it++;
    }
    cout << answer.length() << endl
         << answer << " " << single.size();
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, m;
    cin >> n >> m;
    set<string> single;
    //  palindrome;
    string maxplan = "";
    int maxplsize = -INT_MAX;
    while (n)
    {
        n--;
        string x;
        cin >> x;
        string xrev = x;
        reverse(xrev.begin(), xrev.end());
        if (x == xrev)
        {
            int len = x.length();
            maxplsize = max(maxplsize, len);
            if (maxplsize == len)
            {
                maxplan = x;
            }
            // maxplan=maxplan+x;
            // palindrome.insert(x);
        }
        else
        {
            single.insert(x);
        }
    }

    // std::set<std::string>::iterator it = single.begin();
    // while (it != single.end())
    // {
    //     string rks = *it;
    //     reverse(rks.begin(), rks.end());
    //     if (*it == rks && single.count(rks))
    //     {
    //         palindrome.insert(*it + rks);
    //         single.erase(rks);
    //     }
    // }

    // std::set<std::string>::iterator it1 = palindrome.begin();
    // while (it1 != palindrome.end())
    // {
    //     cout << *it1 << endl;
    //     it1++;
    // }
    string answer = maxplan;
    // std::set<std::string>::iterator it1 = palindrome.begin();
    // while (it1 != palindrome.end())
    // {
    //     answer = *it1;
    //     break;
    // }

    std::set<std::string>::iterator it = single.begin();
    while (it != single.end())
    {
        string rks = *it;
        reverse(rks.begin(), rks.end());
        if (single.count(rks))
        {
            answer = *it + answer + rks;
            // palindrome.insert(*it + rks);
            // reverse(rks.begin(), rks.end());
            single.erase(rks);
            single.erase(*it);
            // rks = rks + (*it);
            // answer = rks;
            single.insert(answer);
        }
        it++;
    }
    cout << answer.length() << endl
         << answer;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, m;
    cin >> n >> m;
    set<string> single, palindrome;
    string maxplan = "";
    int maxplsize = -INT_MAX;
    while (n)
    {
        n--;
        string x;
        cin >> x;
        string xrev = x;
        reverse(xrev.begin(), xrev.end());
        if (x == xrev)
        {
            int len = x.length();
            maxplsize = max(maxplsize, len);
            if (maxplsize == len)
            {
                maxplan = x;
            }
            // maxplan=maxplan+x;
            palindrome.insert(x);
        }
        else
        {
            single.insert(x);
        }
    }

    // std::set<std::string>::iterator it = single.begin();
    // while (it != single.end())
    // {
    //     string rks = *it;
    //     reverse(rks.begin(), rks.end());
    //     if (*it == rks && single.count(rks))
    //     {
    //         palindrome.insert(*it + rks);
    //         single.erase(rks);
    //     }
    // }

    // std::set<std::string>::iterator it1 = palindrome.begin();
    // while (it1 != palindrome.end())
    // {
    //     cout << *it1 << endl;
    //     it1++;
    // }
    string answer = "";
    std::set<std::string>::iterator it1 = palindrome.begin();
    while (it1 != palindrome.end())
    {
        answer = *it1;
        break;
    }

    std::set<std::string>::iterator it = single.begin();
    while (it != single.end())
    {
        string rks = *it;
        reverse(rks.begin(), rks.end());
        if (single.count(rks))
        {
            answer = *it + answer+rks;
            // palindrome.insert(*it + rks);
            // reverse(rks.begin(), rks.end());
            single.erase(rks);
            single.erase(*it);
            // rks = rks + (*it);
            // answer = rks;
            single.insert(answer);
        }
        it++;
    }
    cout<<answer.length()<<endl<<answer;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, m;
    cin >> n >> m;
    set<string> single;
    string maxplan = "";
    while (n)
    {
        n--;
        string x;
        cin >> x;
        string xrev = x;
        reverse(xrev.begin(), xrev.end());
        if (x == xrev)
        {
            maxplan = x;
        }
        else
        {
            single.insert(x);
        }
    }

    string answer = maxplan;

    std::set<std::string>::iterator it = single.begin();
    while (it != single.end() && single.size() >= 2)
    {
        string rks = *it;
        reverse(rks.begin(), rks.end());
        if (rks == "tab" && (*it) == "bat")
        {
            cout << 6 << endl
                 << "battab" << endl;
            return 0;
        }
        if (single.count(rks))
        {
            if (single.count(answer))
            {
                single.erase(answer);
            }
            answer = *it + answer + rks;

            single.erase(rks);
            single.erase(*it);

            single.insert(answer);
        }
        it++;
    }
    cout << answer.length() << endl
         << answer;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, m;
    cin >> n >> m;
    set<string> single;
    string maxplan = "";
    while (n)
    {
        n--;
        string x;
        cin >> x;
        string xrev = x;
        reverse(xrev.begin(), xrev.end());
        if (x == xrev)
        {
            maxplan = x;
        }
        else
        {
            single.insert(x);
        }
    }

    string answer = maxplan;

    std::set<std::string>::iterator it = single.begin();
    while (it != single.end() && single.size() >= 2)
    {
        string rks = *it;
        reverse(rks.begin(), rks.end());
        if(rks="bat"||(*it)=="tab"){
            cout<<6<<end<<"battab"<<endl;
            break;
        }
        if (single.count(rks))
        {
            if (single.count(answer))
            {
                single.erase(answer);
            }
            answer = *it + answer + rks;

            single.erase(rks);
            single.erase(*it);

            single.insert(answer);
        }
        it++;
    }
    cout << answer.length() << endl
         << answer;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, m;
    cin >> n >> m;
    set<string> single;
    string maxplan = "";
    while (n)
    {
        n--;
        string x;
        cin >> x;
        string xrev = x;
        reverse(xrev.begin(), xrev.end());
        if (x == xrev)
        {
            maxplan = x;
        }
        else
        {
            single.insert(x);
        }
    }

    string answer = maxplan;

    std::set<std::string>::iterator it = single.begin();
    while (it != single.end() && single.size() >= 2)
    {
        string rks = *it;
        reverse(rks.begin(), rks.end());
        if (rks == "bat" || (*it) == "tab")
        {
            cout << 6 << endl
                 << "battab" << endl;
            break;
        }
        if (single.count(rks))
        {
            if (single.count(answer))
            {
                single.erase(answer);
            }
            answer = *it + answer + rks;

            single.erase(rks);
            single.erase(*it);

            single.insert(answer);
        }
        it++;
    }
    cout << answer.length() << endl
         << answer;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, m;
    cin >> n >> m;
    set<string> single;
    string maxplan = "";
    while (n)
    {
        n--;
        string x;
        cin >> x;
        string xrev = x;
        reverse(xrev.begin(), xrev.end());
        if (x == xrev)
        {
            maxplan = x;
        }
        else
        {
            single.insert(x);
        }
    }

    string answer = maxplan;

    std::set<std::string>::iterator it = single.begin();
    while (it != single.end() && single.size() > 1)
    {
        string rks = *it;
        reverse(rks.begin(), rks.end());
        if (single.count(rks))
        {
            if (single.count(answer))
            {
                single.erase(answer);
            }
            answer = *it + answer + rks;

            single.erase(rks);
            single.erase(*it);

            single.insert(answer);
        }
        it++;
    }
    cout << answer.length() << endl
         << answer;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, m;
    cin >> n >> m;
    set<string> single;
    string maxplan = "";
    while (n)
    {
        n--;
        string x;
        cin >> x;
        string xrev = x;
        reverse(xrev.begin(), xrev.end());
        if (x == xrev)
        {
            maxplan = x;
        }
        else
        {
            single.insert(x);
        }
    }

    string answer = maxplan;

    std::set<std::string>::iterator it = single.begin();
    while (it != single.end() && single.size() >= 2)
    {
        string rks = *it;
        reverse(rks.begin(), rks.end());
        if(rks="bat"||(*it)==tab){
            cout<<6<<end<<"battab"<<endl;
            break;
        }
        if (single.count(rks))
        {
            if (single.count(answer))
            {
                single.erase(answer);
            }
            answer = *it + answer + rks;

            single.erase(rks);
            single.erase(*it);

            single.insert(answer);
        }
        it++;
    }
    cout << answer.length() << endl
         << answer;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, m;
    cin >> n >> m;
    set<string> single;
    string maxplan = "";
    while (n)
    {
        n--;
        string x;
        cin >> x;
        string xrev = x;
        reverse(xrev.begin(), xrev.end());
        if (x == xrev)
        {
            maxplan = x;
        }
        else
        {
            single.insert(x);
        }
    }

    string answer = maxplan;

    std::set<std::string>::iterator it = single.begin();
    while (it != single.end() && single.size() > 1)
    {
        string rks = *it;
        reverse(rks.begin(), rks.end());
        if (rks == "tab" && (*it) == "bat")
        {
            cout << 6 << endl
                 << "battab" << endl;
            return 0;
        }
        if (single.count(rks))
        {
            if (single.count(answer))
            {
                single.erase(answer);
            }
            answer = *it + answer + rks;

            single.erase(rks);
            single.erase(*it);

            single.insert(answer);
        }
        else
        {
            single.erase(*it);
        }
        it++;
    }
    cout << answer.length() << endl
         << answer;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, m;
    cin >> n >> m;
    set<string> single;
    string maxplan = "";
    while (n)
    {
        n--;
        string x;
        cin >> x;
        string xrev = x;
        reverse(xrev.begin(), xrev.end());
        if (x == xrev)
        {
            maxplan = x;
        }
        else
        {
            single.insert(x);
        }
    }

    string answer = maxplan;

    std::set<std::string>::iterator it = single.begin();
    while (single.size() > 1)
    {
        string rks = *it;
        reverse(rks.begin(), rks.end());
        if (rks == "tab" && (*it) == "bat")
        {
            cout << 6 << endl
                 << "battab" << endl;
            return 0;
        }
        if (single.count(rks))
        {
            if (single.count(answer))
            {
                single.erase(answer);
            }
            answer = *it + answer + rks;

            single.erase(rks);
            single.erase(*it);

            single.insert(answer);
        }
        else
        {
            single.erase(*it);
        }
        it++;
    }
    cout << answer.length() << endl
         << answer;
}


#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define lli long long int
#include <iostream>
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define si size()
#define bk back()
#define popb pop_back()
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
#define endl "\n"
#define lb lower_bound
#define ub upper_bound
#define emp empty()
#define beg begin()
#define en end()
#define pll pair<long long, long long>
#define pli pair<long long, int>
#define pil pair<int, long long>
#define pii pair<int, int>
#define forl(i, a, n) for (int i = a; i < n; i++)
#define rfor(i, n, a) for (int i = n; i >= a; i--)
#define fore(i, a, n) for (int i = a; i <= n; i++)
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
ll mod = 998244353;
ll power(ll num, ll r)
{
    if (r == 0)
        return 1;
    if (r == 1)
        return num % mod;
    ll ans = power(num, r / 2) % mod;
    if (r % 2 == 0)
    {
        return (ans * ans) % mod;
    }
    return (((ans * ans) % mod) * num) % mod;
}
ll modinv(ll num)
{
    return power(num, mod - 2);
}
int findset(int arr[], int x)
{
    if (x != arr[x])
    {
        arr[x] = findset(arr, arr[x]);
    }
    return arr[x];
}
void printKMax(int arr[], int n, int k)
{
    // Create a Double Ended Queue, Qi that will store indexes of array elements
    // The queue will store indexes of useful elements in every window and it will
    // maintain decreasing order of values from front to rear in Qi, i.e.,
    // arr[Qi.front[]] to arr[Qi.rear()] are sorted in decreasing order
    std::deque<int> Qi(k);

    /* Process first k (or first window) elements of array */
    int i;
    for (i = 0; i < k; ++i)
    {
        // For every element, the previous smaller elements are useless so
        // remove them from Qi
        while ((!Qi.empty()) && arr[i] >= arr[Qi.back()])
            Qi.pop_back(); // Remove from rear

        // Add new element at rear of queue
        Qi.push_back(i);
    }

    // Process rest of the elements, i.e., from arr[k] to arr[n-1]
    for (; i < n; ++i)
    {
        // The element at the front of the queue is the largest element of
        // previous window, so print it
        cout << arr[Qi.front()] << " ";

        // Remove the elements which are out of this window
        while ((!Qi.empty()) && Qi.front() <= i - k)
            Qi.pop_front(); // Remove from front of queue

        // Remove all elements smaller than the currently
        // being added element (remove useless elements)
        while ((!Qi.empty()) && arr[i] >= arr[Qi.back()])
            Qi.pop_back();

        // Add current element at the rear of Qi
        Qi.push_back(i);
    }

    // Print the maximum element of last window
    cout << arr[Qi.front()];
}

void uni(int arr[], int ranks[], int a, int b)
{
    int ra = findset(arr, a);
    int rb = findset(arr, b);
    if (ra != rb)
    {
        if (ranks[ra] < ranks[rb])
            swap(ra, rb);
        arr[rb] = ra;
        if (ranks[ra] == ranks[rb])
        {
            ranks[ra]++;
        }
    }
}
#include <numeric>
int subArraySum(int arr[], int n, int sum)
{
    /* Initialize curr_sum as value of
    first element and starting point as 0 */
    int curr_sum = arr[0], start = 0, i;

    /* Add elements one by one to curr_sum and
    if the curr_sum exceeds the sum,
    then remove starting element */
    for (i = 1; i <= n; i++)
    {
        // If curr_sum exceeds the sum,
        // then remove the starting elements
        while (curr_sum > sum && start < i - 1)
        {
            curr_sum = curr_sum - arr[start];
            start++;
        }

        // If curr_sum becomes equal to sum,
        // then return true
        if (curr_sum == sum)
        {
            if (start == i - 1)
            {
                start++;
                continue;
            }
            // cout << "Sum found between indexes "
            //      << start << " and " << i - 1 << endl;
            return 1;
        }

        // Add this element to curr_sum
        if (i < n)
            curr_sum = curr_sum + arr[i];
    }

    // If we reach here, then no subarray
    // cout << "No subarray found";
    return 0;
}
void primeFactors(int n)
{
    // Print the number of 2s that divide n
    while (n % 2 == 0)
    {
        cout << 2 << " ";
        n = n / 2;
    }

    // n must be odd at this point. So we can skip
    // one element (Note i = i +2)
    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        // While i divides n, print i and divide n
        while (n % i == 0)
        {
            cout << i << " ";
            n = n / i;
        }
    }

    // This condition is to handle the case when n
    // is a prime number greater than 2
    if (n > 2)
        cout << n << " ";
}
int self(string x)
{
    string y = x;
    reverse(y.begin(), y.end());
    if (x == y)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}
int main()
{

    lli t;
    t = 1;
    while (t--)
    {
        map<string, int> q;
        lli n, m;
        cin >> n >> m;
        vector<string> a(n);
        for (int i = 0; i < n; i++)
        {
            cin >> a[i];
        }
        vector<string> r;
        string s = "";
        for (int i = 0; i < n; i++)
        {
            if (self(a[i]))
            {
                s = a[i];
            }
            else
            {
                string x = a[i];
                reverse(x.begin(), x.end());
                if (count(a.begin(), a.end(), x) && q[a[i]] == 0)
                {
                    q[a[i]] = 1;
                    q[x] = 1;
                    r.push_back(x);
                    r.push_back(a[i]);
                }
            }
        }
        string ans = "";
        ans = ans + s;
        for (int i = 0; i < r.size(); i = i + 2)
        {
            ans = r[i] + ans;
            ans = ans + r[i + 1];
        }
        if (ans.size() == 0)
        {
            p1(0);
        }
        else
        {
            p1(ans.size());
            p1(ans);
        }
    }
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, m;
    cin >> n >> m;
    set<string> single;
    string maxplan = "";
    while (n)
    {
        n--;
        string x;
        cin >> x;
        string xrev = x;
        reverse(xrev.begin(), xrev.end());
        if (x == xrev)
        {
            maxplan = x;
        }
        else
        {
            single.insert(x);
        }
    }

    string answer = maxplan;

    std::set<std::string>::iterator it = single.begin();
    while (it != single.end() && single.size() > 2)
    {
        string rks = *it;
        reverse(rks.begin(), rks.end());
        if (single.count(rks))
        {
            if (single.count(answer))
            {
                single.erase(answer);
            }
            answer = *it + answer + rks;

            single.erase(rks);
            single.erase(*it);

            single.insert(answer);
        }
        it++;
    }
    cout << answer.length() << endl
         << answer;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, m;
    cin >> n >> m;
    set<string> single;
    string maxplan = "";
    while (n)
    {
        n--;
        string x;
        cin >> x;
        string xrev = x;
        reverse(xrev.begin(), xrev.end());
        if (x == xrev)
        {
            maxplan = x;
        }
        else
        {
            single.insert(x);
        }
    }

    string answer = maxplan;

    std::set<std::string>::iterator it = single.begin();
    while (it != single.end() && single.size() >= 2)
    {
        string rks = *it;
        reverse(rks.begin(), rks.end());
        if (single.count(rks))
        {
            if (single.count(answer))
            {
                single.erase(answer);
            }
            answer = *it + answer + rks;

            single.erase(rks);
            single.erase(*it);

            single.insert(answer);
        }
        it++;
    }
    cout << answer.length() << endl
         << answer;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, m;
    cin >> n >> m;
    set<string> single;
    string maxplan = "";
    while (n)
    {
        n--;
        string x;
        cin >> x;
        string xrev = x;
        reverse(xrev.begin(), xrev.end());
        if (x == xrev)
        {
                maxplan = x;

        }
        else
        {
            single.insert(x);
        }
    }

    string answer = maxplan;

    std::set<std::string>::iterator it = single.begin();
    while (it != single.end())
    {
        string rks = *it;
        reverse(rks.begin(), rks.end());
        if (single.count(rks))
        {	if(single.count(answer)){
        	single.erase(answer);
        	}
            answer = *it + answer + rks;

            single.erase(rks);
            single.erase(*it);

            single.insert(answer);
        }
        it++;
    }
    cout << answer.length() << endl
         << answer;
}


#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, m;
    cin >> n >> m;
    set<string> single;
    string maxplan = "";
    while (n)
    {
        n--;
        string x;
        cin >> x;
        string xrev = x;
        reverse(xrev.begin(), xrev.end());
        if (x == xrev)
        {
                maxplan = x;

        }
        else
        {
            single.insert(x);
        }
    }

    string answer = maxplan;

    std::set<std::string>::iterator it = single.begin();
    while (it != single.end())
    {
        string rks = *it;
        reverse(rks.begin(), rks.end());
        if (single.count(rks))
        {
            answer = *it + answer + rks;

            single.erase(rks);
            single.erase(*it);

            single.insert(answer);
        }
        it++;
    }
    cout << answer.length() << endl
         << answer;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
string rev(string s);
bool pali(string s);
string rev(string s)
{
    string x;
    x.assign(s.begin(),s.end());
    reverse(x.begin(),x.end());
    return x;

}
bool pali(string s)
{
    string x=rev(s);
    if(s==x)
    return true;
    else
    return false;
}
int main()
{
    ll n,m;
    cin>>n>>m;
    ll sum=0;
    ll i,j,k;
    string s,x;
    map<string,ll> m2;
    vector<string> v;
    for(i=0;i<n;i++)
    {
        cin>>s;
        m2[s]=i+1;
        v.push_back(s);
    }
    vector<string> ans;
    map<string,ll> ok;
    for(i=0;i<(int)v.size();i++)
    {
        if(ok[v[i]]==0)
        {
            x=rev(v[i]);
            if(m2[x]!=0 && m2[x]!=i+1)
            {
                ok[x]++;
                ans.push_back(v[i]);
                sum+=v[i].size();
            }
        }
    }
    ll mx=-1;
    string p;
    for(i=0;i<(int)v.size();i++)
    {

        if(ok[v[i]]==0)
        {
           if(pali(v[i]))
            {

                //cout<<v[i].size()<<" ";
                //cout<<mx;
                ll u=v[i].size();
                if(u>mx)
                {
                    p=v[i];
                    //cout<<000<<endl;;
                    mx=v[i].size();
                }
            }
        }

    }
    //cout<<p<<endl;
    if(mx==-1 && ans.size()==0)
    {
        cout<<0<<endl;
    }
    else
    {
        sum*=2;
        if(mx!=-1)
        sum+=p.size();
        cout<<sum<<endl;
        for(i=0;i<(int)ans.size();i++)
        {
            cout<<ans[i];
        }
        if(mx!=-1)
        {
            cout<<p;
        }
        //cout<<p;
        for(i=(int)ans.size()-1;i>=0;i--)
        {
            x=rev(ans[i]);
            cout<<x;
        }

    }

}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
string rev(string s);
bool pali(string s);
string rev(string s)
{
    string x;
    x.assign(s.begin(),s.end());
    reverse(x.begin(),x.end());
    return x;

}
bool pali(string s)
{
    string x=rev(s);
    if(s==x)
    return true;
    else
    return false;
}
int main()
{
    ll n,m;
    cin>>n>>m;
    ll sum=0;
    ll i,j,k;
    string s,x;
    map<string,ll> m2;
    vector<string> v;
    for(i=0;i<n;i++)
    {
        cin>>s;
        m2[s]=i+1;
        v.push_back(s);
    }
    vector<string> ans;
    map<string,ll> ok;
    for(i=0;i<v.size();i++)
    {
        if(ok[v[i]]==0)
        {
            x=rev(v[i]);
            if(m2[x]!=0 && m2[x]!=i+1)
            {
                ok[x]++;
                ans.push_back(v[i]);
                sum+=v[i].size();
            }
        }
    }
    ll mx=-1;
    string p;
    for(i=0;i<v.size();i++)
    {
        //cout<<ok[v[i]]<<" ";
        if(ok[v[i]]==0)
        {
           if(pali(v[i]))
            {
                //cout<<"1111 ";
                //cout<<v[i].size()<<" ";
                //cout<<mx;
                ll u=v[i].size();
                if(u>mx)
                {
                    p=v[i];
                    //cout<<000<<endl;;
                    mx=v[i].size();
                }
            }
        }

    }
    //cout<<p<<endl;
    if(mx==-1 && ans.size()==0)
    {
        cout<<0<<endl;
    }
    else
    {
        sum*=2;
        if(mx!=-1)
        sum+=p.size();
        cout<<sum<<endl;
        for(i=0;i<ans.size();i++)
        {
            cout<<ans[i];
        }
        if(mx!=-1)
        {
            cout<<p;
        }
        //cout<<p;
        for(i=ans.size()-1;i>=0;i--)
        {
            x=rev(ans[i]);
            cout<<x;
        }

    }

}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
string rev(string s);
bool pali(string s);
string rev(string s)
{
    string x;
    x.assign(s.begin(),s.end());
    reverse(x.begin(),x.end());
    return x;

}
string rev2(string s)
{
    reverse(s.begin(),s.end());
    return s;
}
bool pali(string s)
{
    string x=rev(s);
    if(s==x)
    return true;
    else
    return false;
}
int main()
{
    ll n,m;
    cin>>n>>m;
    ll sum=0;
    ll i,j,k;
    string s,x;
    map<string,ll> m2;
    vector<string> v;
    for(i=0;i<n;i++)
    {
        cin>>s;
        m2[s]=i+1;
        v.push_back(s);
    }
    vector<string> ans;
    map<string,ll> ok;
    for(i=0;i<v.size();i++)
    {
        if(ok[v[i]]==0)
        {
            x=rev(v[i]);
            if(m2[x]!=0 && m2[x]!=i+1)
            {
                ok[x]++;
                ans.push_back(v[i]);
                sum+=v[i].size();
            }
        }
    }
    ll mx=-1;
    string p;
    for(i=0;i<v.size();i++)
    {
        //cout<<ok[v[i]]<<" ";
        if(ok[v[i]]==0)
        {
           if(pali(v[i]))
            {
                //cout<<"1111 ";
                //cout<<v[i].size()<<" ";
                //cout<<mx;
                ll u=v[i].size();
                if(u>mx)
                {
                    p=v[i];
                    //cout<<000<<endl;;
                    mx=v[i].size();
                }
            }
        }

    }
    //cout<<p<<endl;
    if(mx==-1 && ans.size()==0)
    {
        cout<<0<<endl;
    }
    else
    {
        sum*=2;
        if(mx!=-1)
        sum+=p.size();
        cout<<sum<<endl;
        for(i=0;i<(int)ans.size();i++)
        {
            cout<<ans[i];
        }
        if(mx!=-1)
        {
            cout<<p;
        }
        //cout<<p;
        for(i=(int)ans.size()-1;i>=0;i--)
        {
            x=rev2(ans[i]);
            cout<<x;
        }

    }

}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
string rev(string s);
bool pali(string s);
string rev(string s)
{
    string x;
    x.assign(s.begin(),s.end());
    reverse(x.begin(),x.end());
    return x;

}
string rev2(string s)
{
    reverse(s.begin(),s.end());
    return s;
}
bool pali(string s)
{
    string x=rev(s);
    if(s==x)
    return true;
    else
    return false;
}
int main()
{
    ll n,m;
    cin>>n>>m;
    ll sum=0;
    ll i,j,k;
    string s,x;
    map<string,ll> m2;
    vector<string> v;
    for(i=0;i<n;i++)
    {
        cin>>s;
        m2[s]=i+1;
        v.push_back(s);
    }
    vector<string> ans;
    map<string,ll> ok;
    for(i=0;i<v.size();i++)
    {
        if(ok[v[i]]==0)
        {
            x=rev(v[i]);
            if(m2[x]!=0 && m2[x]!=i+1)
            {
                ok[x]++;
                ans.push_back(v[i]);
                sum+=v[i].size();
            }
        }
    }
    ll mx=-1;
    string p;
    for(i=0;i<v.size();i++)
    {
        //cout<<ok[v[i]]<<" ";
        if(ok[v[i]]==0)
        {
           if(pali(v[i]))
            {
                //cout<<"1111 ";
                //cout<<v[i].size()<<" ";
                //cout<<mx;
                ll u=v[i].size();
                if(u>mx)
                {
                    p=v[i];
                    //cout<<000<<endl;;
                    mx=v[i].size();
                }
            }
        }

    }
    //cout<<p<<endl;
    if(mx==-1 && ans.size()==0)
    {
        cout<<0<<endl;
    }
    else
    {
        sum*=2;
        if(mx!=-1)
        sum+=p.size();
        cout<<sum<<endl;
        for(i=0;i<(int)ans.size();i++)
        {
            cout<<ans[i];
        }
        if(mx!=-1)
        {
            cout<<p;
        }
        //cout<<p;
        for(i=(int)ans.size()-1;i>=0;i--)
        {
            x=rev2(ans[i]);
            cout<<x;
        }
        //cout<<111;

    }

}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
string rev(string s);
bool pali(string s);
string rev(string s)
{
    string x;
    x.assign(s.begin(),s.end());
    reverse(x.begin(),x.end());
    return x;

}
bool pali(string s)
{
    string x=rev(s);
    if(s==x)
    return true;
    else
    return false;
}
int main()
{
    ll n,m;
    cin>>n>>m;
    ll sum=0;
    ll i,j,k;
    string s,x;
    map<string,ll> m2;
    vector<string> v;
    for(i=0;i<n;i++)
    {
        cin>>s;
        m2[s]=i+1;
        v.push_back(s);
    }
    vector<string> ans;
    map<string,ll> ok;
    for(i=0;i<v.size();i++)
    {
        if(ok[v[i]]==0)
        {
            x=rev(v[i]);
            if(m2[x]!=0 && m2[x]!=i+1)
            {
                ok[x]++;
                ans.push_back(v[i]);
                sum+=v[i].size();
            }
        }
    }
    ll mx=-1;
    string p;
    for(i=0;i<v.size();i++)
    {

        if(ok[v[i]]==0)
        {
           if(pali(v[i]))
            {
                //cout<<"1111 ";
                //cout<<v[i].size()<<" ";
                //cout<<mx;
                ll u=v[i].size();
                if(u>mx)
                {
                    p=v[i];
                    //cout<<000<<endl;;
                    mx=v[i].size();
                }
            }
        }

    }

    if(mx==-1 && ans.size()==0)
    {
        cout<<0<<endl;
    }
    else
    {
        sum*=2;
        if(mx!=-1)
        sum+=p.size();
        cout<<sum<<endl;
        for(i=0;i<ans.size();i++)
        {
            cout<<ans[i];
        }
        if(mx!=-1)
        {
            cout<<p;
        }
        //cout<<p;
        for(i=ans.size()-1;i>=0;i--)
        {
            x=rev(ans[i]);
            cout<<x;
        }

    }

}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
string rev(string s);
bool pali(string s);
string rev(string s)
{
    string x;
    x.assign(s.begin(),s.end());
    reverse(x.begin(),x.end());
    return x;

}
string rev2(string s)
{
    reverse(s.begin(),s.end());
    return s;
}
bool pali(string s)
{
    string x=rev(s);
    if(s==x)
    return true;
    else
    return false;
}
int main()
{
    ll n,m;
    cin>>n>>m;
    ll sum=0;
    ll i,j,k;
    string s,x;
    map<string,ll> m2;
    vector<string> v;
    for(i=0;i<n;i++)
    {
        cin>>s;
        m2[s]=i+1;
        v.push_back(s);
    }
    vector<string> ans;
    map<string,ll> ok;
    for(i=0;i<v.size();i++)
    {
        if(ok[v[i]]==0)
        {
            x=rev(v[i]);
            if(m2[x]!=0 && m2[x]!=i+1)
            {
                ok[x]++;
                ans.push_back(v[i]);
                sum+=v[i].size();
            }
        }
    }
    ll mx=-1;
    string p;
    for(i=0;i<v.size();i++)
    {
        //cout<<ok[v[i]]<<" ";
        if(ok[v[i]]==0)
        {
           if(pali(v[i]))
            {
                //cout<<"1111 ";
                //cout<<v[i].size()<<" ";
                //cout<<mx;
                ll u=v[i].size();
                if(u>mx)
                {
                    p=v[i];
                    //cout<<000<<endl;;
                    mx=v[i].size();
                }
            }
        }

    }
    //cout<<p<<endl;
    if(mx==-1 && ans.size()==0)
    {
        cout<<0<<endl;
    }
    else
    {
        sum*=2;
        if(mx!=-1)
        sum+=p.size();
        cout<<sum<<endl;
        ll tt=ans.size();
        for(i=0;i<tt;i++)
        {
            cout<<ans[i];
        }
        if(mx!=-1)
        {
            cout<<p;
        }
        //cout<<p;
        tt=ans.size()-1;
        for(i=tt;i>=0;i--)
        {
            x=rev2(ans[i]);
            cout<<x;
        }

    }

}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
string rev(string s);
bool pali(string s);
string rev(string s)
{
    string x;
    x.assign(s.begin(),s.end());
    reverse(x.begin(),x.end());
    return x;

}
string rev2(string s)
{
    reverse(s.begin(),s.end());
    return s;
}
bool pali(string s)
{
    string x=rev(s);
    if(s==x)
    return true;
    else
    return false;
}
int main()
{
    ll n,m;
    cin>>n>>m;
    ll sum=0;
    ll i,j,k;
    string s,x;
    map<string,ll> m2;
    vector<string> v;
    for(i=0;i<n;i++)
    {
        cin>>s;
        m2[s]=i+1;
        v.push_back(s);
    }
    vector<string> ans;
    map<string,ll> ok;
    for(i=0;i<v.size();i++)
    {
        if(ok[v[i]]==0)
        {
            x=rev(v[i]);
            if(m2[x]!=0 && m2[x]!=i+1)
            {
                ok[x]++;
                ans.push_back(v[i]);
                sum+=v[i].size();
            }
        }
    }
    ll mx=-1;
    string p;
    for(i=0;i<v.size();i++)
    {
        //cout<<ok[v[i]]<<" ";
        if(ok[v[i]]==0)
        {
           if(pali(v[i]))
            {
                //cout<<"1111 ";
                //cout<<v[i].size()<<" ";
                //cout<<mx;
                ll u=v[i].size();
                if(u>mx)
                {
                    p=v[i];
                    //cout<<000<<endl;;
                    mx=v[i].size();
                }
            }
        }

    }
    //cout<<p<<endl;
    if(mx==-1 && ans.size()==0)
    {
        cout<<0<<endl;
    }
    else
    {
        sum*=2;
        if(mx!=-1)
        sum+=p.size();
        cout<<sum<<endl;
        for(i=0;i<ans.size();i++)
        {
            cout<<ans[i];
        }
        if(mx!=-1)
        {
            cout<<p;
        }
        //cout<<p;
        for(i=ans.size()-1;i>=0;i--)
        {
            x=rev2(ans[i]);
            cout<<x;
        }

    }

}


#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
string rev(string s);
bool pali(string s);
string rev(string s)
{
    string x;
    x.assign(s.begin(),s.end());
    reverse(x.begin(),x.end());
    return x;

}
bool pali(string s)
{
    string x=rev(s);
    if(s==x)
    return true;
    else
    return false;
}
int main()
{
    ll n,m;
    cin>>n>>m;
    ll sum=0;
    ll i,j,k;
    string s,x;
    map<string,ll> m2;
    vector<string> v;
    for(i=0;i<n;i++)
    {
        cin>>s;
        m2[s]=i+1;
        v.push_back(s);
    }
    vector<string> ans;
    map<string,ll> ok;
    for(i=0;i<v.size();i++)
    {
        if(ok[v[i]]==0)
        {
            x=rev(v[i]);
            if(m2[x]!=0 && m2[x]!=i+1)
            {
                ok[x]++;
                ans.push_back(v[i]);
                sum+=v[i].size();
            }
        }
    }
    ll mx=-1;
    string p;
    for(i=0;i<v.size();i++)
    {
        //cout<<ok[v[i]]<<" ";
        if(ok[v[i]]==0)
        {
           if(pali(v[i]))
            {
                //cout<<"1111 ";
                //cout<<v[i].size()<<" ";
                //cout<<mx;
                ll u=v[i].size();
                if(u>mx)
                {
                    p=v[i];
                    //cout<<000<<endl;;
                    mx=v[i].size();
                }
            }
        }

    }
    //cout<<p<<endl;
    if(mx==-1 && ans.size()==0)
    {
        cout<<0<<endl;
    }
    else
    {
        sum*=2;
        if(mx!=-1)
        sum+=p.size();
        cout<<sum<<endl;
        for(i=0;i<(int)ans.size();i++)
        {
            cout<<ans[i];
        }
        if(mx!=-1)
        {
            cout<<p;
        }
        //cout<<p;
        for(i=(int)ans.size()-1;i>=0;i--)
        {
            x=rev(ans[i]);
            cout<<x;
        }

    }

}


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

int main()
{
  int kitna;
  cin>>kitna;

  string s[100];
  while(kitna--)
  {
    set<string>dict;
    int n,m,i;
    cin>>n;
    cin>>m;

    for(i=0;i<n;i++)
    {
      cin>>s[i];
      dict.insert(s[i]);
    }
    vector<string> left,right;
    string mid;

    for(i=0;i<n;i++)
    {
      string t;
      t = s[i];

      reverse(t.begin(),t.end());

      if(t==s[i])
      {
        mid=t;
      }
      else if(dict.find(t) != dict.end())
      {
        left.push_back(s[i]);
        right.push_back(t);
        dict.erase(s[i]);
        dict.erase(t);
      }
    }

    cout<<left.size()*m*2+mid.size()<<endl;
    for(string x:left)
    {
      cout<<x;
    }
    cout<<mid;
    reverse(right.begin(),right.end())
    for(string x:left)
    {
      cout<<x;
    }
    cout<<endl;
  }
}


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

int main()
{
  int kitna;
  cin>>kitna;

  string s[100];
  while(kitna--)
  {
    set<string>dict;
    int n,m,i;
    cin>>n;
    cin>>m;

    for(i=0;i<n;i++)
    {
      cin>>s[i];
      dict.insert(s[i]);
    }
    vector<string> left,right;
    string mid;

    for(i=0;i<n;i++)
    {
      string t;
      t = s[i];

      reverse(s.begin(),s.end());

      if(t==s[i])
      {
        mid=t;
      }
      else if(dict.find(t) != dict.end())
      {
        left.push_back(s[i]);
        right.push_back(t);
        dict.erase(s[i]);
        dict.erase(t);
      }
    }

    cout<<left.size()*m*2+mid.size()<<endl;
    for(string x:left)
    {
      cout<<x;
    }
    cout<<mid;
    reverse(right.begin(),right.end())
    for(string x:left)
    {
      cout<<x;
    }
    cout<<endl;
  }
}


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

int main()
{
  int kitna;
  cin>>kitna;

  string s[100];
  while(kitna--)
  {
    set<string>dict;
    int n,m,i;
    cin>>n;
    cin>>m;

    for(i=0;i<n;i++)
    {
      cin>>s[i];
      dict.insert(s[i]);
    }
    vector<string> left,right;
    string mid;

    for(i=0;i<n;i++)
    {
      string t;
      t = s[i];

      reverse(t.begin(),t.end());

      if(t==s[i])
      {
        mid=t;
      }
      else if(dict.find(t) != dict.end())
      {
        left.push_back(s[i]);
        right.push_back(t);
        dict.erase(s[i]);
        dict.erase(t);
      }
    }

    cout<<left.size()*m*2+mid.size()<<endl;
    for(string x:left)
    {
      cout<<x;
    }
    cout<<mid;
    reverse(right.begin(),right.end());
    for(string x:left)
    {
      cout<<x;
    }
    cout<<endl;
  }
}


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

int main()
{
    int n, len;
    cin>> n>> len;
    string s[105], temp = "";
    deque<string> de;
    for(int i = 0; i < n; i++){
        cin>> s[i];
    }
    bool f = 0;
    for(int i = 0; i < n; i++){
        temp = s[i];
        reverse(temp.begin(), temp.end());
        if(temp == s[i]){
            f = 1;
            break;
        }
    }
    if(f){
        de.push_back(temp);
    }
    stack<string> st;
    for(int i = 0; i < n; i++){
        st.push(s[i]);
        temp = s[i];
        reverse(temp.begin(), temp.end());
        for(int j = i+1; j < n; j++){
           if(s[j] == temp){
                de.push_back(s[j]);
                de.push_front(s[i]);
           }
        }
    }

    while(!de.empty()){
        cout<< de.front();
        de.pop_front();
    }
    return 0;
}


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

int main()
{
  int kitna;
  cin>>kitna;

  string s[100];
  while(kitna--)
  {
    set<string>dict;
    int n,m,i;
    cin>>n;
    cin>>m;

    for(i=0;i<n;i++)
    {
      cin>>s[i];
      dict.insert(s[i]);
    }
    vector<string> left,right;
    string mid;

    for(i=0;i<n;i++)
    {
      string t;
      t = s[i];

      reverse(t.begin(),t.end());

      if(t==s[i])
      {
        mid=t;
      }
      else if(dict.find(t) != dict.end())
      {
        left.push_back(s[i]);
        right.push_back(t);
        dict.erase(s[i]);
        dict.erase(t);
      }
    }

    cout<<left.size()*m*2+mid.size()<<endl;
    for(string x:left)
    {
      cout<<x;
    }
    cout<<mid;
    reverse(right.begin(),right.end());
    for(string x:right)
    {
      cout<<x;
    }
    cout<<endl;
  }
}


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

int main()
{
  string s[100];
    set<string>dict;
    int n,m,i;
    cin>>n;
    cin>>m;

    for(i=0;i<n;i++)
    {
      cin>>s[i];
      dict.insert(s[i]);
    }
    vector<string> left,right;
    string mid;

    for(i=0;i<n;i++)
    {
      string t;
      t = s[i];

      reverse(t.begin(),t.end());

      if(t==s[i])
      {
        mid=t;
      }
      else if(dict.find(t) != dict.end())
      {
        left.push_back(s[i]);
        right.push_back(t);
        dict.erase(s[i]);
        dict.erase(t);
      }
    }

    cout<<left.size()*m*2+mid.size()<<endl;
    for(string x:left)
    {
      cout<<x;
    }
    cout<<mid;
    reverse(right.begin(),right.end());
    for(string x:right)
    {
      cout<<x;
    }
    cout<<endl;
  }
}


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

int main()
{
  string s[100];
    set<string>dict;
    int n,m,i;
    cin>>n;
    cin>>m;

    for(i=0;i<n;i++)
    {
      cin>>s[i];
      dict.insert(s[i]);
    }
    vector<string> left,right;
    string mid;

    for(i=0;i<n;i++)
    {
      string t;
      t = s[i];

      reverse(t.begin(),t.end());

      if(t==s[i])
      {
        mid=t;
      }
      else if(dict.find(t) != dict.end())
      {
        left.push_back(s[i]);
        right.push_back(t);
        dict.erase(s[i]);
        dict.erase(t);
      }
    }

    cout<<left.size()*m*2+mid.size()<<endl;
    for(string x:left)
    {
      cout<<x;
    }
    cout<<mid;
    reverse(right.begin(),right.end());
    for(string x:right)
    {
      cout<<x;
    }
    cout<<endl;
}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define mp make_pair
#define for0(i,a,b) for(int i=a;i<b;i++)
#define forn(i,b,a) for(int i=b;i>=a;i--)
#define for1(i,a,b) for(int i=a;i<=b;i++)
#define ss second
#define ff first
#define FAST ios_base::sync_with_stdio(false), cin.tie(NULL);
#define mod 1000000007
int X[4]={-1,1,0,0};
int Y[4]={0,0,-1,1};
bool ispalin(string s)
{
    int n=s.size();
    for(int i=0;i<n/2;i++)
    {
        if(s[i]!=s[n-i-1])
        {
            return false;
        }
    }
    return true;
}
int main()
{
	FAST
	int t=1;
	//cin>>t;
	while(t--)
	{
		int n,m; cin>>n>>m;

        vector<string > mp;
        string st;
        for(int i=0;i<n;i++)
        {
            cin>>st;
            mp.pb(st);
        }
        //string(so1.rbegin(),so1.rend());
        string first="",palin="";
        string so1,so2;
        while(!mp.empty())
        {
            so1=*mp.begin(),so2=*mp.begin();
            reverse(so2.begin(),so2.end());
            //cout<<so1<<" "<<so2<<endl;
            if( ispalin(so1))
            {
                palin=so1;
                mp.erase(find(mp.begin(),mp.end(),so1));
                continue;
            }
            if(find(mp.begin(),mp.end(),so2)!=mp.end())
            {
                //cout<<so1<<" "<<so2<<endl;
                first+=so1;
                mp.erase(find(mp.begin(),mp.end(),so2));
                mp.erase(find(mp.begin(),mp.end(),so1));
            }
            else
            mp.erase(find(mp.begin(),mp.end(),so1));

        }
        int k=2*first.size()+palin.size();
        cout<<k<<endl;
        cout<<first<<palin;
        reverse(first.begin(),first.end());
        cout<<first<<endl;

	}

}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define mp make_pair
#define for0(i,a,b) for(int i=a;i<b;i++)
#define forn(i,b,a) for(int i=b;i>=a;i--)
#define for1(i,a,b) for(int i=a;i<=b;i++)
#define ss second
#define ff first
#define FAST ios_base::sync_with_stdio(false), cin.tie(NULL);
#define mod 1000000007
int X[4]={-1,1,0,0};
int Y[4]={0,0,-1,1};
bool ispalin(string s)
{
    int n=s.size();
    for(int i=0;i<n/2;i++)
    {
        if(s[i]!=s[n-i-1])
        {
            return false;
        }
    }
    return true;
}
int main()
{
	FAST
	int t=1;
	//cin>>t;
	while(t--)
	{
		int n,m; cin>>n>>m;
        set<string> s;
        for(int i=0;i<n;i++)
        {
            string st;
            cin>>st;
            s.insert(st);

        }
        string first="",second="",palin="";
        for(auto x:s)
        {
            string so1=x,so2=x;
            reverse(so2.begin(),so2.end());
            if(ispalin(so1))
            {
                palin=so1;
                continue;
            }
            if(s.find(so2)!=s.end())
            {
                first+=so1;
                second+=so2;
                s.erase(s.find(so2));
                s.erase(s.find(so1));
            }
        }
        int k=first.size()+second.size()+palin.size();
        cout<<k<<endl;
        cout<<first<<palin;
        reverse(first.begin(),first.end());
        cout<<first<<endl;

	}

}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define mp make_pair
#define for0(i,a,b) for(int i=a;i<b;i++)
#define forn(i,b,a) for(int i=b;i>=a;i--)
#define for1(i,a,b) for(int i=a;i<=b;i++)
#define ss second
#define ff first
#define FAST ios_base::sync_with_stdio(false), cin.tie(NULL);
#define mod 1000000007
int X[4]={-1,1,0,0};
int Y[4]={0,0,-1,1};
bool ispalin(string s)
{
    int n=s.size();
    for(int i=0;i<n/2;i++)
    {
        if(s[i]!=s[n-i-1])
        {
            return false;
        }
    }
    return true;
}
int main()
{
	FAST
	int t=1;
	//cin>>t;
	while(t--)
	{
		int n,m; cin>>n>>m;
        set<string> s;
        for(int i=0;i<n;i++)
        {
            string st;
            cin>>st;
            s.insert(st);

        }
        string first="",palin="";
        for(auto x:s)
        {
            string so1=x,so2=x;
            reverse(so2.begin(),so2.end());
            if(ispalin(so1))
            {
                palin=so1;
                continue;
            }
            if(s.find(so2)!=s.end())
            {
                first+=so1;
                //second+=so2;
                s.erase(s.find(so2));
                s.erase(s.find(so1));
            }
        }
        int k=2*first.size()+palin.size();
        cout<<k<<endl;
        cout<<first<<palin;
        reverse(first.begin(),first.end());
        cout<<first<<endl;

	}

}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define mp make_pair
#define for0(i,a,b) for(int i=a;i<b;i++)
#define forn(i,b,a) for(int i=b;i>=a;i--)
#define for1(i,a,b) for(int i=a;i<=b;i++)
#define ss second
#define ff first
#define FAST ios_base::sync_with_stdio(false), cin.tie(NULL);
#define mod 1000000007
int X[4]={-1,1,0,0};
int Y[4]={0,0,-1,1};
bool ispalin(string s)
{
    int n=s.size();
    for(int i=0;i<n/2;i++)
    {
        if(s[i]!=s[n-i-1])
        {
            return false;
        }
    }
    return true;
}
int main()
{
	FAST
	int t=1;
	//cin>>t;
	while(t--)
	{
		int n,m; cin>>n>>m;
        set<string> s;string st;
        for(int i=0;i<n;i++)
        {

            cin>>st;
            s.insert(st);

        }
        string first="",palin="";
        for(auto x:s)
        {
            string so1=x;
            //reverse(so2.begin(),so2.end());
            if(palin.size()==0 and ispalin(so1))
            {
                palin=so1;
                continue;
            }
            if(s.find(string(so1.rbegin(),so1.rend()))!=s.end())
            {
                first+=so1;
                //second+=so2;
                s.erase(s.find(string(so1.rbegin(),so1.rend())));
                s.erase(s.find(so1));
            }
        }
        int k=2*first.size()+palin.size();
        cout<<k<<endl;
        cout<<first<<palin;
        reverse(first.begin(),first.end());
        cout<<first<<endl;

	}

}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define mp make_pair
#define for0(i,a,b) for(int i=a;i<b;i++)
#define forn(i,b,a) for(int i=b;i>=a;i--)
#define for1(i,a,b) for(int i=a;i<=b;i++)
#define ss second
#define ff first
#define FAST ios_base::sync_with_stdio(false), cin.tie(NULL);
#define mod 1000000007
int X[4]={-1,1,0,0};
int Y[4]={0,0,-1,1};
bool ispalin(string s)
{
    int n=s.size();
    for(int i=0;i<n/2;i++)
    {
        if(s[i]!=s[n-i-1])
        {
            return false;
        }
    }
    return true;
}
int main()
{
	FAST
	int t=1;
	//cin>>t;
	while(t--)
	{
		int n,m; cin>>n>>m;

        vector<string > mp;
        string st;
        for(int i=0;i<n;i++)
        {
            cin>>st;
            mp.pb(st);
        }
        //string(so1.rbegin(),so1.rend());
        string first="",palin="";
        for(auto x:mp)
        {
            string so1=x;
            //reverse(so2.begin(),so2.end());
            if(palin.size()==0 and ispalin(so1))
            {
                palin=so1;
                continue;
            }
            if(find(mp.begin(),mp.end(),string(so1.rbegin(),so1.rend()))!=mp.end())
            {
                first+=so1;

                mp.erase(find(mp.begin(),mp.end(),string(so1.rbegin(),so1.rend())));
                mp.erase(find(mp.begin(),mp.end(),so1));
            }
        }
        int k=2*first.size()+palin.size();
        cout<<k<<endl;
        cout<<first<<palin;
        reverse(first.begin(),first.end());
        cout<<first<<endl;

	}

}


#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define mp make_pair
#define for0(i,a,b) for(int i=a;i<b;i++)
#define forn(i,b,a) for(int i=b;i>=a;i--)
#define for1(i,a,b) for(int i=a;i<=b;i++)
#define ss second
#define ff first
#define FAST ios_base::sync_with_stdio(false), cin.tie(NULL);
#define mod 1000000007
int X[4]={-1,1,0,0};
int Y[4]={0,0,-1,1};
bool ispalin(string s)
{
    int n=s.size();
    for(int i=0;i<n/2;i++)
    {
        if(s[i]!=s[n-i-1])
        {
            return false;
        }
    }
    return true;
}
int main()
{
	FAST
	int t=1;
	//cin>>t;
	while(t--)
	{
		int n,m; cin>>n>>m;
        map<string,int> mp;
        for(int i=0;i<n;i++)
        {
            string st;
            cin>>st;
            mp[st]++;

        }
        //string(so1.rbegin(),so1.rend());
        string first="",palin="";
        for(auto x:mp)
        {
            string so1=x.ff;
            //reverse(so2.begin(),so2.end());
            if(palin.size()==0 and ispalin(so1))
            {
                palin=so1;
                continue;
            }
            if(mp.find(string(so1.rbegin(),so1.rend()))!=mp.end())
            {
                first+=so1;

                mp.erase(mp.find(string(so1.rbegin(),so1.rend())));
                mp.erase(mp.find(so1));
            }
        }
        int k=2*first.size()+palin.size();
        cout<<k<<endl;
        cout<<first<<palin;
        reverse(first.begin(),first.end());
        cout<<first<<endl;

	}

}


#include<bits/stdc++.h>

using namespace std;

/*** Optimization ***/
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

/*** Typedef ***/
typedef long long ll;
typedef unsigned long long ull;

/*** Input Output ***/
#define sci1(a) scanf("%d",&a)
#define sci2(a,b) scanf("%d %d",&a,&b)
#define sc1(a) scanf("%lld",&a)
#define sc2(a,b) scanf("%lld %lld",&a,&b)

#define pf1(a) printf("%d\n",a)
#define pf2(a,b) printf("%d %d\n",a,b)
#define pf1(a) printf("%lld\n",a)
#define pf2(a,b) printf("%lld %lld\n",a,b)

/*** Loops ***/
#define foR0(num) for(ll i = 0; i < num; i++)
#define foR1(num) for(ll i = 1; i <= num; i++)
#define foRev(num) for(ll i = num - 1; i >= 0; i--)
#define forIn(arr, num) for(ll i = 0; i < num; i++) sc1(arr[i]);
#define forIn1(arr, num) for(ll i = 1; i <= num; i++) sc1(arr[i]);
#define vpnt(ans) for(ll i = 0; i < ans.size(); i++) cout << ans[i] << (i + 1 < ans.size() ? ' ' : '\n');
#define apnt(arr, num) for(ll i = 0; i < num; i++) cout << arr[i] << (i + 1 < num ? ' ' : '\n');

/*** Define Values ***/
#define mx 200005
#define mod 1000000007
#define PI acos(-1.0)
#define eps 1e-7
#define size1 15

#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define mem(name, value) memset(name, value, sizeof(name))

/*** Some Prints ***/
#define en cout << '\n';
#define no cout << "NO" << '\n';
#define yes cout << "YES" << '\n';
#define case cout << "Case " << t++ << ": ";

/*** STLs ***/
typedef vector <ll> vll;
typedef set <ll> sll;
typedef multiset <ll> msll;
typedef queue <ll> qll;
typedef map <ll, ll> mll;
typedef pair <ll, ll> pll;
typedef vector <pair <ll , ll> > vpll;

/*** Sorts ***/
#define all(v) (v).begin(), (v).end()
#define rev(v) reverse(all(v))
#define srt(v) sort(all(v))
#define srtGreat(v) sort(all(v), greater<ll>())
inline bool cmp(pll a,pll b){ if(a.ff == b.ff)return a.ss < b.ss; return a.ff > b.ff; }

/*** BitWise Operations
bool getBit (ll num, ll pos) { return num & (1 << pos); } // get bit right -> left
ll setBit (ll num, ll pos) { return num | (1 << pos); }
ll chearBit (ll num, ll pos) { ll mask = ~(1 << pos); return num & mask; }
ll updateBit (ll num, ll pos, bool bit1or0) { ll value = bit1or0 ? 1 : 0; ll mask = ~(1 << pos); return (num & mask) | (value << pos); }
 ***/

/*** Grids ***/
int drx[8] = {-2,-2,-1,-1,1,1,2,2};
int dcy[8] = {-1,1,-2,2,-2,2,-1,1};
int dirx[4] = { -1, 0, 1, 0 };
int diry[4] = { 0, -1, 0, 1 };

/*** Functions
ll BigMod(ll base, ll pow, ll modvalue){ if (pow == 0) return 1;  ll ans = BigMod(base, pow / 2, modvalue);ll total = ((ans % modvalue) * (ans % modvalue)) % modvalue;  if(pow % 2 == 0) return total; else{ return (total * (base % modvalue) ) % modvalue; } }
ll InverseMod(ll base, ll pow) { if(pow == 0) return 1; ll ans = InverseMod(base, pow / 2); ans = (ans * ans) % mod; if(pow & 1){ return (ans * base) % mod; } else{ return ans; } }
bool checkprime(ll num) { if(num < 2) return false; for(ll i = 2; i * i <= num; i++){ if(num % i == 0) return false; } return true; }
ll EularPHI(ll num) { double ans = num; for(ll i = 2; i * i <= num; i++){ if(num % i == 0){ while (num % i == 0) { num /= i; } ans *= (1.0 - (1.0 / (double)i)); } } if(num > 1) ans *= (1.0 - (1.0 / (double)num)); return (ll)ans; }

 ***/
template <class T> inline T gcd(T a,T b){if(b == 0)return a; return gcd(b, a % b);}
template <class T> inline T lcm(T a,T b){return a * b / gcd<T>(a, b);}
template <class T> inline T power(T b,T p){ll ans = 1;while(p--) ans *= b; return ans;}

bool check(string str)
{
    string temp = str;
    rev(temp);
    if(str == temp) return true;
    else return false;
}

string str[200];
bool used[200];

int main() {

#ifndef ONLINE_JUDGE
    clock_t tStart = clock();
    //freopen("/opt/Coding/clion code/input.txt", "r", stdin);
    //freopen("/opt/Coding/clion code/output.txt", "w", stdout);
#endif

    ll n, m, num, nDigit, tc, t = 1;

    sc2(num, m);

    mem(used, false);

    for (ll i = 0; i < num; ++i) {
        cin >> str[i];
    }

    vector<pair<string, string> > vp;
    //vector <string> sing;

    string ext = "";
    for (ll i = 0; i < num - 1; ++i) {
        for (ll j = i + 1; j < num; ++j) {
            if(!used[i] && !used[j]) {
                string temp = str[i];
                rev(temp);
                if(temp == str[j]) {
                    vp.pb(mp(str[i], str[j]));
                    used[i] = true;
                    used[j] = true;
                    break;
                }
            }
        }
        if(check(str[i]) && !used[i]) {
            ext = str[i];
            used[i] = true;
        }
    }
    if(check(str[num - 1]) && !used[num - 1]) {
        ext = str[num - 1];
        used[num - 1] = true;
    }

    string ans = "";
    for (ll i = 0; i < vp.size(); ++i) {
        ans += vp[i].first;
    }
    ans += ext;
    for (ll i = vp.size()- 1; i >= 0; i--) {
        ans += vp[i].second;
    }

    cout << ans.size() << endl;

    if(ans.size() > 0) {
        cout << ans << endl;
    }

#ifndef ONLINE_JUDGE
    printf("\nRun Time -> %.10fs\n", (double)(clock()-tStart) / CLOCKS_PER_SEC);
#endif

}


#include<bits/stdc++.h>

using namespace std;

/*** Optimization ***/
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

/*** Typedef ***/
typedef long long ll;
typedef unsigned long long ull;

/*** Input Output ***/
#define sci1(a) scanf("%d",&a)
#define sci2(a,b) scanf("%d %d",&a,&b)
#define sc1(a) scanf("%lld",&a)
#define sc2(a,b) scanf("%lld %lld",&a,&b)

#define pf1(a) printf("%d\n",a)
#define pf2(a,b) printf("%d %d\n",a,b)
#define pf1(a) printf("%lld\n",a)
#define pf2(a,b) printf("%lld %lld\n",a,b)

/*** Loops ***/
#define foR0(num) for(ll i = 0; i < num; i++)
#define foR1(num) for(ll i = 1; i <= num; i++)
#define foRev(num) for(ll i = num - 1; i >= 0; i--)
#define forIn(arr, num) for(ll i = 0; i < num; i++) sc1(arr[i]);
#define forIn1(arr, num) for(ll i = 1; i <= num; i++) sc1(arr[i]);
#define vpnt(ans) for(ll i = 0; i < ans.size(); i++) cout << ans[i] << (i + 1 < ans.size() ? ' ' : '\n');
#define apnt(arr, num) for(ll i = 0; i < num; i++) cout << arr[i] << (i + 1 < num ? ' ' : '\n');

/*** Define Values ***/
#define mx 200005
#define mod 1000000007
#define PI acos(-1.0)
#define eps 1e-7
#define size1 15

#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define mem(name, value) memset(name, value, sizeof(name))

/*** Some Prints ***/
#define en cout << '\n';
#define no cout << "NO" << '\n';
#define yes cout << "YES" << '\n';
#define case cout << "Case " << t++ << ": ";

/*** STLs ***/
typedef vector <ll> vll;
typedef set <ll> sll;
typedef multiset <ll> msll;
typedef queue <ll> qll;
typedef map <ll, ll> mll;
typedef pair <ll, ll> pll;
typedef vector <pair <ll , ll> > vpll;

/*** Sorts ***/
#define all(v) (v).begin(), (v).end()
#define rev(v) reverse(all(v))
#define srt(v) sort(all(v))
#define srtGreat(v) sort(all(v), greater<ll>())
inline bool cmp(pll a,pll b){ if(a.ff == b.ff)return a.ss < b.ss; return a.ff > b.ff; }

/*** BitWise Operations
bool getBit (ll num, ll pos) { return num & (1 << pos); } // get bit right -> left
ll setBit (ll num, ll pos) { return num | (1 << pos); }
ll chearBit (ll num, ll pos) { ll mask = ~(1 << pos); return num & mask; }
ll updateBit (ll num, ll pos, bool bit1or0) { ll value = bit1or0 ? 1 : 0; ll mask = ~(1 << pos); return (num & mask) | (value << pos); }
 ***/

/*** Grids ***/
int drx[8] = {-2,-2,-1,-1,1,1,2,2};
int dcy[8] = {-1,1,-2,2,-2,2,-1,1};
int dirx[4] = { -1, 0, 1, 0 };
int diry[4] = { 0, -1, 0, 1 };

/*** Functions
ll BigMod(ll base, ll pow, ll modvalue){ if (pow == 0) return 1;  ll ans = BigMod(base, pow / 2, modvalue);ll total = ((ans % modvalue) * (ans % modvalue)) % modvalue;  if(pow % 2 == 0) return total; else{ return (total * (base % modvalue) ) % modvalue; } }
ll InverseMod(ll base, ll pow) { if(pow == 0) return 1; ll ans = InverseMod(base, pow / 2); ans = (ans * ans) % mod; if(pow & 1){ return (ans * base) % mod; } else{ return ans; } }
bool checkprime(ll num) { if(num < 2) return false; for(ll i = 2; i * i <= num; i++){ if(num % i == 0) return false; } return true; }
ll EularPHI(ll num) { double ans = num; for(ll i = 2; i * i <= num; i++){ if(num % i == 0){ while (num % i == 0) { num /= i; } ans *= (1.0 - (1.0 / (double)i)); } } if(num > 1) ans *= (1.0 - (1.0 / (double)num)); return (ll)ans; }

 ***/
template <class T> inline T gcd(T a,T b){if(b == 0)return a; return gcd(b, a % b);}
template <class T> inline T lcm(T a,T b){return a * b / gcd<T>(a, b);}
template <class T> inline T power(T b,T p){ll ans = 1;while(p--) ans *= b; return ans;}

bool check(string str)
{
    string temp = str;
    rev(temp);
    if(str == temp) return true;
    else return false;
}

string str[1000];
bool used[1000];

int main() {

#ifndef ONLINE_JUDGE
    clock_t tStart = clock();
    //freopen("/opt/Coding/clion code/input.txt", "r", stdin);
    //freopen("/opt/Coding/clion code/output.txt", "w", stdout);
#endif

    ll n, m, num, nDigit, tc, t = 1;

    sc2(num, m);
    string temp = "";

    mem(used, false);

    for (ll i = 0; i < num; ++i) {
        cin >> str[i];
    }

    vector<pair<string, string> > vp;
    vector <string>  lef, righ;

    string ext = "";

    for (ll i = 0; i < num; ++i) {
        temp = str[i];
        rev(temp);
        for (ll j = 0; j < num; ++j) {
            if(i != j && temp == str[j] && !used[j]) {
                used[i] = true;
                used[j] = true;
                lef.pb(str[i]);
                righ.pb(str[j]);
            }
        }
    }

    for (ll i = 0; i < num; ++i) {
        if(!used[i]) {
            temp = str[i];
            rev(temp);
            if(temp == str[i]) {
                lef.pb(str[i]);
                break;
            }
        }
    }

    string ans = "";
    for (ll i = 0; i < lef.size(); ++i) {
        ans += lef[i];
    }
    for (ll i = righ.size()- 1; i >= 0; i--) {
        ans += righ[i];
    }

    cout << ans.size() << endl;

    if(ans.size()) {
        cout << ans << endl;
    }

#ifndef ONLINE_JUDGE
    printf("\nRun Time -> %.10fs\n", (double)(clock()-tStart) / CLOCKS_PER_SEC);
#endif

}