/*
* @Author: XiaoBanni
* @Email:  xjc5069@gmail.com
* @Date:   2019-05-01 23:53:56
* @Last Modified by:   Y
* @Last Modified time: 2019-05-01 23:53:56
*/

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef priority_queue<int> maxpque;
typedef priority_queue<int,vector<int>,greater<int> > minpque;
const int MAXN = 1e5+5;
const int INF=INT_MAX/2;
const ll LLINF=9223372036854775807/2;
#define in(a) scanf("%d",&a)
#define inll(a) scanf("%lld",&a)
#define out(a) printf("%d",a)
#define outll(a) printf("%lld",a)
#define outln(a) printf("%d\n",a)
#define outllln(a) printf("%lld\n",a)
#define fin(i,st,n) for(int i=st;i<n;i++)
#define fin2(i,st,n) for(int i=st;i<=n;i++)
#define mk make_pair
#define maxpque(type) priority_queue<type>
#define minpque(type) priority_queue<type,vector<type>,greater<type> > //pay attention that no ',' in type
#define gcd __gcd
#define IOS ios::sync_with_stdio(false);cin.tie(0); cout.tie(0);

int alp[30];

int main(){
	int t;
	in(t);
	while(t--){
		int cnt=0;
		memset(alp,0,sizeof(alp));
		string s;
		cin>>s;
		int n=s.size();
		for(int i=0;i<n;i++){
			alp[s[i]-'a'+1]++;
		}

		fin2(i,1,26){
			if(alp[i]) cnt++;
		}

		if(cnt>=4||cnt==1){
			int f=1;
			for(int i=1;i<=26;i++){
				if(alp[i]&&f%2==0){
					fin2(j,1,alp[i]) printf("%c",'a'+i-1);
				}
			}
			f=1;
			for(int i=1;i<=26;i++){
				if(alp[i]&&f%2==1){
					fin2(j,1,alp[i]) printf("%c",'a'+i-1);
				}
			}
			printf("\n");
		}

		else if(cnt==2){
			int pos1=0,pos2=0;
			fin2(i,1,26){
				if(alp[i]&&!pos1) pos1=i;
				if(alp[i]&&pos1) pos2=i;
			}
			if(pos2-pos1==1){
				 printf("No answer\n");
			}
			else{
				fin2(j,1,alp[pos1]) printf("%c",'a'+pos1-1);
				fin2(j,1,alp[pos2]) printf("%c",'a'+pos2-1);
			}
			printf("\n");
		}

		else if(cnt==3){
			int pos1=0,pos2=0,pos3=0;
			fin2(i,1,26){
				if(alp[i]&&!pos1) pos1=i;
				else if(alp[i]&&!pos2) pos2=i;
				else if(alp[i]&&!pos3) { pos3=i;
				}
			}
			if(pos3-pos2==1&&pos2-pos1==1){
				printf("No answer\n");
			}
			else{
				fin2(j,1,alp[pos1]) printf("%c",'a'+pos1-1);
				fin2(j,1,alp[pos3]) printf("%c",'a'+pos3-1);
				fin2(j,1,alp[pos2]) printf("%c",'a'+pos2-1);
			}
			printf("\n");
		}
	}
	return 0;
}


/*
* @Author: XiaoBanni
* @Email:  xjc5069@gmail.com
* @Date:   2019-05-01 23:53:56
* @Last Modified by:   Y
* @Last Modified time: 2019-05-01 23:53:56
*/

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef priority_queue<int> maxpque;
typedef priority_queue<int,vector<int>,greater<int> > minpque;
const int MAXN = 1e5+5;
const int INF=INT_MAX/2;
const ll LLINF=9223372036854775807/2;
#define in(a) scanf("%d",&a)
#define inll(a) scanf("%lld",&a)
#define out(a) printf("%d",a)
#define outll(a) printf("%lld",a)
#define outln(a) printf("%d\n",a)
#define outllln(a) printf("%lld\n",a)
#define fin(i,st,n) for(int i=st;i<n;i++)
#define fin2(i,st,n) for(int i=st;i<=n;i++)
#define mk make_pair
#define maxpque(type) priority_queue<type>
#define minpque(type) priority_queue<type,vector<type>,greater<type> > //pay attention that no ',' in type
#define gcd __gcd
#define IOS ios::sync_with_stdio(false);cin.tie(0); cout.tie(0);

int alp[30];

int main(){
	int t;
	in(t);
	while(t--){
		int cnt=0;
		memset(alp,0,sizeof(alp));
		string s;
		cin>>s;
		int n=s.size();
		for(int i=0;i<n;i++){
			alp[s[i]-'a'+1]++;
		}

		fin2(i,1,26){
			if(alp[i]) cnt++;
		}

		if(cnt>=4||cnt==1){
			for(int i=1;i<=26;i+=2){
				if(alp[i]){
					fin2(j,1,alp[i]) printf("%c",'a'+i-1);
				}
			}
			for(int i=2;i<=26;i+=2){
				if(alp[i]){
					fin2(j,1,alp[i]) printf("%c",'a'+i-1);
				}
			}
			printf("\n");
		}

		else if(cnt==2){
			int pos1=0,pos2=0;
			fin2(i,1,26){
				if(alp[i]&&!pos1) pos1=i;
				if(alp[i]&&pos1) pos2=i;
			}
			if(pos2-pos1==1){
				 printf("No answer\n");
			}
			else{
				fin2(j,1,alp[pos1]) printf("%c",'a'+pos1-1);
				fin2(j,1,alp[pos2]) printf("%c",'a'+pos2-1);
			}
			printf("\n");
		}

		else if(cnt==3){
			int pos1=0,pos2=0,pos3=0;
			fin2(i,1,26){
				if(alp[i]&&!pos1) pos1=i;
				else if(alp[i]&&!pos2) pos2=i;
				else if(alp[i]&&!pos3) { pos3=i;
				}
			}
			if(pos3-pos2==1&&pos2-pos1==1){
				printf("No answer\n");
			}
			else{
				fin2(j,1,alp[pos1]) printf("%c",'a'+pos1-1);
				fin2(j,1,alp[pos3]) printf("%c",'a'+pos3-1);
				fin2(j,1,alp[pos2]) printf("%c",'a'+pos2-1);
			}
			printf("\n");
		}
	}
	return 0;
}


/*
* @Author: XiaoBanni
* @Email:  xjc5069@gmail.com
* @Date:   2019-05-01 23:53:56
* @Last Modified by:   Y
* @Last Modified time: 2019-05-01 23:53:56
*/

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef priority_queue<int> maxpque;
typedef priority_queue<int,vector<int>,greater<int> > minpque;
const int MAXN = 1e5+5;
const int INF=INT_MAX/2;
const ll LLINF=9223372036854775807/2;
#define in(a) scanf("%d",&a)
#define inll(a) scanf("%lld",&a)
#define out(a) printf("%d",a)
#define outll(a) printf("%lld",a)
#define outln(a) printf("%d\n",a)
#define outllln(a) printf("%lld\n",a)
#define fin(i,st,n) for(int i=st;i<n;i++)
#define fin2(i,st,n) for(int i=st;i<=n;i++)
#define mk make_pair
#define maxpque(type) priority_queue<type>
#define minpque(type) priority_queue<type,vector<type>,greater<type> > //pay attention that no ',' in type
#define gcd __gcd
#define IOS ios::sync_with_stdio(false);cin.tie(0); cout.tie(0);

int alp[30];

int main(){
	int t;
	in(t);
	while(t--){
		int cnt=0;
		memset(alp,0,sizeof(alp));
		string s;
		cin>>s;
		int n=s.size();
		for(int i=0;i<n;i++){
			alp[s[i]-'a'+1]++;
		}

		fin2(i,1,26){
			if(alp[i]) cnt++;
		}

		if(cnt>=4||cnt==1){
			int f=1;
			for(int i=1;i<=26;i++){
				if(alp[i]&&f%2==0){
					f++;
					fin2(j,1,alp[i]) printf("%c",'a'+i-1);
				}
			}
			f=1;
			for(int i=1;i<=26;i++){
				f++;
				if(alp[i]&&f%2==1){
					fin2(j,1,alp[i]) printf("%c",'a'+i-1);
				}
			}
			printf("\n");
		}

		else if(cnt==2){
			int pos1=0,pos2=0;
			fin2(i,1,26){
				if(alp[i]&&!pos1) pos1=i;
				if(alp[i]&&pos1) pos2=i;
			}
			if(pos2-pos1==1){
				 printf("No answer\n");
			}
			else{
				fin2(j,1,alp[pos1]) printf("%c",'a'+pos1-1);
				fin2(j,1,alp[pos2]) printf("%c",'a'+pos2-1);
			}
			printf("\n");
		}

		else if(cnt==3){
			int pos1=0,pos2=0,pos3=0;
			fin2(i,1,26){
				if(alp[i]&&!pos1) pos1=i;
				else if(alp[i]&&!pos2) pos2=i;
				else if(alp[i]&&!pos3) { pos3=i;
				}
			}
			if(pos3-pos2==1&&pos2-pos1==1){
				printf("No answer\n");
			}
			else{
				fin2(j,1,alp[pos1]) printf("%c",'a'+pos1-1);
				fin2(j,1,alp[pos3]) printf("%c",'a'+pos3-1);
				fin2(j,1,alp[pos2]) printf("%c",'a'+pos2-1);
			}
			printf("\n");
		}
	}
	return 0;
}


/*
* @Author: XiaoBanni
* @Email:  xjc5069@gmail.com
* @Date:   2019-05-01 23:53:56
* @Last Modified by:   Y
* @Last Modified time: 2019-05-01 23:53:56
*/

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef priority_queue<int> maxpque;
typedef priority_queue<int,vector<int>,greater<int> > minpque;
const int MAXN = 1e5+5;
const int INF=INT_MAX/2;
const ll LLINF=9223372036854775807/2;
#define in(a) scanf("%d",&a)
#define inll(a) scanf("%lld",&a)
#define out(a) printf("%d",a)
#define outll(a) printf("%lld",a)
#define outln(a) printf("%d\n",a)
#define outllln(a) printf("%lld\n",a)
#define fin(i,st,n) for(int i=st;i<n;i++)
#define fin2(i,st,n) for(int i=st;i<=n;i++)
#define mk make_pair
#define maxpque(type) priority_queue<type>
#define minpque(type) priority_queue<type,vector<type>,greater<type> > //pay attention that no ',' in type
#define gcd __gcd
#define IOS ios::sync_with_stdio(false);cin.tie(0); cout.tie(0);

int alp[30];

int main(){
	int t;
	in(t);
	while(t--){
		int cnt=0;
		memset(alp,0,sizeof(alp));
		string s;
		cin>>s;
		int n=s.size();
		for(int i=0;i<n;i++){
			alp[s[i]-'a'+1]++;
		}

		fin2(i,1,26){
			if(alp[i]) cnt++;
		}

		if(cnt>=4||cnt==1){
			int f=1;
			for(int i=1;i<=26;i++){
				if(alp[i]&&f%2==0){
					fin2(j,1,alp[i]) printf("%c",'a'+i-1);
				}
				if(alp[i]) f++;
			}
			f=1;
			for(int i=1;i<=26;i++){
				if(alp[i]&&f%2==1){
					fin2(j,1,alp[i]) printf("%c",'a'+i-1);
				}
				if(alp[i]) f++;
			}
			printf("\n");
		}

		else if(cnt==2){
			int pos1=0,pos2=0;
			fin2(i,1,26){
				if(alp[i]&&!pos1) pos1=i;
				if(alp[i]&&pos1) pos2=i;
			}
			if(pos2-pos1==1){
				 printf("No answer\n");
			}
			else{
				fin2(j,1,alp[pos1]) printf("%c",'a'+pos1-1);
				fin2(j,1,alp[pos2]) printf("%c",'a'+pos2-1);
			}
			printf("\n");
		}

		else if(cnt==3){
			int pos1=0,pos2=0,pos3=0;
			fin2(i,1,26){
				if(alp[i]&&!pos1) pos1=i;
				else if(alp[i]&&!pos2) pos2=i;
				else if(alp[i]&&!pos3) { pos3=i;
				}
			}
			if(pos3-pos2==1&&pos2-pos1==1){
				printf("No answer\n");
			}
			else{
				fin2(j,1,alp[pos1]) printf("%c",'a'+pos1-1);
				fin2(j,1,alp[pos3]) printf("%c",'a'+pos3-1);
				fin2(j,1,alp[pos2]) printf("%c",'a'+pos2-1);
			}
			printf("\n");
		}
	}
	return 0;
}


/*
* @Author: XiaoBanni
* @Email:  xjc5069@gmail.com
* @Date:   2019-05-01 23:53:56
* @Last Modified by:   Y
* @Last Modified time: 2019-05-01 23:53:56
*/

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef priority_queue<int> maxpque;
typedef priority_queue<int,vector<int>,greater<int> > minpque;
const int MAXN = 1e5+5;
const int INF=INT_MAX/2;
const ll LLINF=9223372036854775807/2;
#define in(a) scanf("%d",&a)
#define inll(a) scanf("%lld",&a)
#define out(a) printf("%d",a)
#define outll(a) printf("%lld",a)
#define outln(a) printf("%d\n",a)
#define outllln(a) printf("%lld\n",a)
#define fin(i,st,n) for(int i=st;i<n;i++)
#define fin2(i,st,n) for(int i=st;i<=n;i++)
#define mk make_pair
#define maxpque(type) priority_queue<type>
#define minpque(type) priority_queue<type,vector<type>,greater<type> > //pay attention that no ',' in type
#define gcd __gcd
#define IOS ios::sync_with_stdio(false);cin.tie(0); cout.tie(0);

int alp[30];

int main(){
	int t;
	in(t);
	while(t--){
		int cnt=0;
		memset(alp,0,sizeof(alp));
		string s;
		cin>>s;
		int n=s.size();
		for(int i=0;i<n;i++){
			alp[s[i]-'a'+1]++;
		}

		fin2(i,1,26){
			if(alp[i]) cnt++;
		}

		if(cnt>=4||cnt==1){
			int f=1;
			for(int i=1;i<=26;i++){
				if(alp[i]&&f%2==0){
					fin2(j,1,alp[i]) printf("%c",'a'+i-1);
				}
				if(alp[i]) f++;
			}
			f=1;
			for(int i=1;i<=26;i++){
				if(alp[i]&&f%2==1){
					fin2(j,1,alp[i]) printf("%c",'a'+i-1);
				}
				if(alp[i]) f++;
			}
			printf("\n");
		}

		else if(cnt==2){
			int pos1=0,pos2=0;
			fin2(i,1,26){
				if(alp[i]&&!pos1) pos1=i;
				if(alp[i]&&pos1) pos2=i;
			}
			if(pos2-pos1==1){
				 printf("No answer");
			}
			else{
				fin2(j,1,alp[pos1]) printf("%c",'a'+pos1-1);
				fin2(j,1,alp[pos2]) printf("%c",'a'+pos2-1);
			}
			printf("\n");
		}

		else if(cnt==3){
			int pos1=0,pos2=0,pos3=0;
			fin2(i,1,26){
				if(alp[i]&&!pos1) pos1=i;
				else if(alp[i]&&!pos2) pos2=i;
				else if(alp[i]&&!pos3) { pos3=i;
				}
			}
			if(pos3-pos2==1&&pos2-pos1==1){
				printf("No answer");
			}
			else{
				fin2(j,1,alp[pos1]) printf("%c",'a'+pos1-1);
				fin2(j,1,alp[pos3]) printf("%c",'a'+pos3-1);
				fin2(j,1,alp[pos2]) printf("%c",'a'+pos2-1);
			}
			printf("\n");
		}
	}
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
char s[1005],par[1005],imp[1005];
int main()
{
    //freopen("1.in","r",stdin);
   // freopen("1.out","w",stdout);
    int test;
    scanf("%d\n",&test);
    while(test--)
    {
        int n,n1=0,n2=0,ok=0,i1,i2;
        gets(s);
        n=strlen(s);
        for(int i=0;i<n;++i)
            if(s[i]%2==0)
                par[n1++]=s[i];
            else
                imp[n2++]=s[i];
        for(int i=0;i<n1 && !ok;++i)
            for(int j=0;j<n2 && !ok;++j)
                if((par[i]-1)!=imp[j] && (par[i]+1)!=imp[j])
                    ok=1,i1=i,i2=j;
        if(n1==0 || n2==0)
            i1=0,i2=1;
        if(ok)
        {
            char aux=par[0];
            par[0]=par[i1];
            par[i1]=aux;
            aux=imp[n2-1];
            imp[n2-1]=imp[i2];
            imp[i2]=aux;
            for(int i=0;i<n2;++i)
                printf("%c",imp[i]);
            for(int i=0;i<n1;++i)
                printf("%c",par[i]);
            printf("\n");
        }
        else
            printf("No answer\n");
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
bool viz[105];
char s[105],out[105];
vector<int>adc[105];
struct mm
{
    int x,viz[105];
};
queue<mm>q;
void dfs(int nod)
{
    viz[nod]=1;
    for(int i=0; i<adc[nod].size(); ++i)
        if(!viz[adc[nod][i]])
            dfs(adc[nod][i]);
}
int main()
{
    freopen("1.in","r",stdin);
    freopen("1.out","w",stdout);
    int test;
    scanf("%d\n",&test);
    while(test--)
    {
        int n,ok=1,k;
        gets(s);
        n=strlen(s);
        for(int i=0; i<n; ++i)
            for(int j=i+1; j<n; ++j)
                if(i!=j && (s[i]+1)!=s[j] && (s[i]-1)!=s[j])
                {
                    adc[i].push_back(j);
                    adc[j].push_back(i);
                }
        dfs(1);
        for(int i=0; i<n; ++i)
        {
            if(viz[i]==0)
                ok=0;
            viz[i]=0;
        }
        if(!ok)
            printf("No answer\n");
        else
        {
            for(k=0; k<n; ++k)
                if(adc[k].size()==1)
                    break;
            mm t;
            for(int i=0;i<n;++i)
                t.viz[i]=0;
            k=k%n;
            t.viz[k]=1;
            t.x=k;
            q.push(t);
            while(!q.empty())
            {
                t=q.front();
                if(t.viz[t.x]==n)
                {
                    for(int i=0;i<n;++i)
                        out[t.viz[i]-1]=s[i];
                    for(int i=0;i<n;++i)
                        printf("%c",out[i]);
                    printf("\n");
                    break;
                }
                q.pop();
                for(int i=0;i<adc[t.x].size();++i)
                    if(!t.viz[adc[t.x][i]])
                    {
                        mm p=t;
                        p.viz[adc[t.x][i]]=p.viz[t.x]+1;
                        p.x=adc[t.x][i];
                        q.push(p);
                    }
            }
            while(!q.empty())
                q.pop();
        }
        for(int i=0; i<n; ++i)
            adc[i].clear(),viz[i]=0;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
bool viz[105];
char s[105],out[105];
vector<int>adc[105];
struct mm
{
    int x,viz[105];
};
queue<mm>q;
void dfs(int nod)
{
    viz[nod]=1;
    for(int i=0; i<adc[nod].size(); ++i)
        if(!viz[adc[nod][i]])
            dfs(adc[nod][i]);
}
int main()
{
    //freopen("1.in","r",stdin);
   // freopen("1.out","w",stdout);
    int test;
    scanf("%d\n",&test);
    while(test--)
    {
        int n,ok=1,k;
        gets(s);
        n=strlen(s);
        for(int i=0; i<n; ++i)
            for(int j=i+1; j<n; ++j)
                if(i!=j && (s[i]+1)!=s[j] && (s[i]-1)!=s[j])
                {
                    adc[i].push_back(j);
                    adc[j].push_back(i);
                }
        dfs(1);
        for(int i=0; i<n; ++i)
        {
            if(viz[i]==0)
                ok=0;
            viz[i]=0;
        }
        if(!ok)
            {
                if(n==1)
                    printf("%c\n",s[0]);
                else
                    printf("No answer\n");
            }
        else
        {
            for(k=0; k<n; ++k)
                if(adc[k].size()==1)
                    break;
            mm t;
            for(int i=0;i<n;++i)
                t.viz[i]=0;
            k=k%n;
            t.viz[k]=1;
            t.x=k;
            q.push(t);
            while(!q.empty())
            {
                t=q.front();
                if(t.viz[t.x]==n)
                {
                    for(int i=0;i<n;++i)
                        out[t.viz[i]-1]=s[i];
                    for(int i=0;i<n;++i)
                        printf("%c",out[i]);
                    printf("\n");
                    break;
                }
                q.pop();
                for(int i=0;i<adc[t.x].size();++i)
                    if(!t.viz[adc[t.x][i]])
                    {
                        mm p=t;
                        p.viz[adc[t.x][i]]=p.viz[t.x]+1;
                        p.x=adc[t.x][i];
                        q.push(p);
                    }
            }
            while(!q.empty())
                q.pop();
        }
        for(int i=0; i<n; ++i)
            adc[i].clear(),viz[i]=0;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
char s[105],par[105],imp[105];
int main()
{
    //freopen("1.in","r",stdin);
   // freopen("1.out","w",stdout);
    int test;
    scanf("%d\n",&test);
    while(test--)
    {
        int n,n1=0,n2=0,ok=0,i1,i2;
        gets(s);
        n=strlen(s);
        for(int i=0;i<n;++i)
            if(s[i]%2==0)
                par[n1++]=s[i];
            else
                imp[n2++]=s[i];
        for(int i=0;i<n1 && !ok;++i)
            for(int j=0;j<n2 && !ok;++j)
                if((par[i]-1)!=imp[j] && (par[i]+1)!=imp[j])
                    ok=1,i1=i,i2=j;
        if(n1==0 || n2==0)
            ok=1;
        if(ok)
        {
            char aux=par[0];
            par[0]=par[i1];
            par[i1]=aux;
             aux=imp[n2-1];
            imp[n2-1]=imp[i2];
            imp[i2]=aux;
            for(int i=0;i<n2;++i)
                printf("%c",imp[i]);
            for(int i=0;i<n1;++i)
                printf("%c",par[i]);
            printf("\n");
        }
        else
            printf("No answer\n");
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
char s[1005],par[1005],imp[1005];
int main()
{
    //freopen("1.in","r",stdin);
   // freopen("1.out","w",stdout);
    int test;
    scanf("%d\n",&test);
    while(test--)
    {
        int n,n1=0,n2=0,ok=0,i1,i2;
        gets(s);
        n=strlen(s);
        for(int i=0;i<n;++i)
            if(s[i]%2==0)
                par[n1++]=s[i];
            else
                imp[n2++]=s[i];
        for(int i=0;i<n1 && !ok;++i)
            for(int j=0;j<n2 && !ok;++j)
                if((par[i]-1)!=imp[j] && (par[i]+1)!=imp[j])
                    ok=1,i1=i,i2=j;
        if(n1==0 || n2==0)
            i1=0,i2=1,ok=1;
        if(ok)
        {
            char aux=par[0];
            par[0]=par[i1];
            par[i1]=aux;
            aux=imp[n2-1];
            imp[n2-1]=imp[i2];
            imp[i2]=aux;
            for(int i=0;i<n2;++i)
                printf("%c",imp[i]);
            for(int i=0;i<n1;++i)
                printf("%c",par[i]);
            printf("\n");
        }
        else
            printf("No answer\n");
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
bool viz[105];
char s[105],out[105];
vector<int>adc[105];
struct mm
{
    int x,viz[105];
};
queue<mm>q;
void dfs(int nod)
{
    viz[nod]=1;
    for(int i=0; i<adc[nod].size(); ++i)
        if(!viz[adc[nod][i]])
            dfs(adc[nod][i]);
}
int main()
{
    //freopen("1.in","r",stdin);
   // freopen("1.out","w",stdout);
    int test;
    scanf("%d\n",&test);
    while(test--)
    {
        int n,ok=1,k;
        gets(s);
        n=strlen(s);
        for(int i=0; i<n; ++i)
            for(int j=i+1; j<n; ++j)
                if(i!=j && (s[i]+1)!=s[j] && (s[i]-1)!=s[j])
                {
                    adc[i].push_back(j);
                    adc[j].push_back(i);
                }
        dfs(1);
        for(int i=0; i<n; ++i)
        {
            if(viz[i]==0)
                ok=0;
            viz[i]=0;
        }
        if(!ok)
            printf("No answer\n");
        else
        {
            for(k=0; k<n; ++k)
                if(adc[k].size()==1)
                    break;
            mm t;
            for(int i=0;i<n;++i)
                t.viz[i]=0;
            k=k%n;
            t.viz[k]=1;
            t.x=k;
            q.push(t);
            while(!q.empty())
            {
                t=q.front();
                if(t.viz[t.x]==n)
                {
                    for(int i=0;i<n;++i)
                        out[t.viz[i]-1]=s[i];
                    for(int i=0;i<n;++i)
                        printf("%c",out[i]);
                    printf("\n");
                    break;
                }
                q.pop();
                for(int i=0;i<adc[t.x].size();++i)
                    if(!t.viz[adc[t.x][i]])
                    {
                        mm p=t;
                        p.viz[adc[t.x][i]]=p.viz[t.x]+1;
                        p.x=adc[t.x][i];
                        q.push(p);
                    }
            }
            while(!q.empty())
                q.pop();
        }
        for(int i=0; i<n; ++i)
            adc[i].clear(),viz[i]=0;
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
char s[1005],par[1005],imp[1005];
int main()
{
    //freopen("1.in","r",stdin);
   // freopen("1.out","w",stdout);
    int test;
    scanf("%d\n",&test);
    while(test--)
    {
        int n,n1=0,n2=0,ok=0,i1,i2;
        gets(s);
        n=strlen(s);
        for(int i=0;i<n;++i)
            if(s[i]%2==0)
                par[n1++]=s[i];
            else
                imp[n2++]=s[i];
        for(int i=0;i<n1 && !ok;++i)
            for(int j=0;j<n2 && !ok;++j)
                if((par[i]-1)!=imp[j] && (par[i]+1)!=imp[j])
                    ok=1,i1=i,i2=j;
        if(n1==0)
        {
            for(int i=0;i<n2;++i)
                printf("%c",imp[i]);
            printf("\n");
            continue;
        }
        if(n2==0)
        {
            for(int i=0;i<n1;++i)
                printf("%c",par[i]);
            printf("\n");
            continue;
        }
        if(ok)
        {
            char aux=par[0];
            par[0]=par[i1];
            par[i1]=aux;
            aux=imp[n2-1];
            imp[n2-1]=imp[i2];
            imp[i2]=aux;
            for(int i=0;i<n2;++i)
                printf("%c",imp[i]);
            for(int i=0;i<n1;++i)
                printf("%c",par[i]);
            printf("\n");
        }
        else
            printf("No answer\n");
    }
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
char s[1005],par[1005],imp[1005];
int main()
{
    //freopen("1.in","r",stdin);
   // freopen("1.out","w",stdout);
    int test;
    scanf("%d\n",&test);
    while(test--)
    {
        int n,n1=0,n2=0,ok=0,i1,i2;
        gets(s);
        n=strlen(s);
        for(int i=0;i<n;++i)
            if(s[i]%2==0)
                par[n1++]=s[i];
            else
                imp[n2++]=s[i];
        for(int i=0;i<n1 && !ok;++i)
            for(int j=0;j<n2 && !ok;++j)
                if((par[i]-1)!=imp[j] && (par[i]+1)!=imp[j])
                    ok=1,i1=i,i2=j;
        if(n1==0 || n2==0)
            ok=1;
        if(ok)
        {
            char aux=par[0];
            par[0]=par[i1];
            par[i1]=aux;
            aux=imp[n2-1];
            imp[n2-1]=imp[i2];
            imp[i2]=aux;
            for(int i=0;i<n2;++i)
                printf("%c",imp[i]);
            for(int i=0;i<n1;++i)
                printf("%c",par[i]);
            printf("\n");
        }
        else
            printf("No answer\n");
    }
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
bool visit[102];
int main(){
	string str;
	int t;
	cin >> t;
	while(t--){
		cin >> str;
		memset(visit,0,sizeof(visit));
		sort(str.begin(),str.end());
		string ans = "";
		int sz = str.size();
		for(int i = 0;i<sz and str.size();i++){
			if(   ans.size() == 0   or (fabs(ans.back()-str[i] )!=1 and !visit[i] )){
				ans.push_back(str[i]);
				visit[i] =1;
			}
		}
		string other = "";
		for(int i = 0;i<str.size();i++){
			if(!visit[i])
				other.push_back(str[i]);

		}
		other+=ans;
		bool b = 0;
		for(int i = 0;i<ans.size() -1;i++){
			if(fabs(other[i]-other[i+1]) == 1)
				b = 1;
			}
		if(b)
			cout<<"No answer\n";
		else
			cout<<other<<endl;
		//ans+=str;

		//cout<<ans<<endl;
	}

}


#include<bits/stdc++.h>
using namespace std;
int n;
string a,b,c;

bool p(string str){
    for(int i = 0;i<str.size()-1;i++){
        if(abs(str[i]-str[i+1]) == 1)
            return 0;
    }

    return 1;
}

int main(){
    cin >> n;
    while(n--){
        a.clear();
        b.clear();
        cin >> c;
        for(int i = 0;i<c.size();i++){
            if(c[i]%2 == 0)
                a.push_back(c[i]);
            else
                b.push_back(c[i]);
        }
        sort(a.begin(),a.end());
        sort(b.begin(),b.end());
        if(p(a+b))
            cout<<(a+b)<<endl;
        else if(p(b+a))
            cout<<(b+a)<<endl;
        else
            cout<<"No answer\n";

    }

}


#include<bits/stdc++.h>
using namespace std;
const int maxn=5e6+10;
int Laxt[maxn],Next[maxn],To[maxn],cnt;
int Laxt2[maxn],Next2[maxn],To2[maxn],cnt2;
int d,n,m,dfn[maxn],low[maxn],sk[maxn],vis[maxn];
int sz[maxn],dp[maxn],bel[maxn],Time,scc,top;
char s[100001][51];
void add(int u,int v)
{
	Next[++cnt]=Laxt[u];Laxt[u]=cnt;To[cnt]=v;
}
void add2(int u,int v)
{
	Next2[++cnt2]=Laxt2[u];Laxt2[u]=cnt2;To2[cnt2]=v;
}
int id(int a,int b)
{
	return (a-1)*d+b+1;
}
void tarjan(int u)
{
	dfn[u]=low[u]=++Time;
	sk[++top]=u;vis[u]=1;
	for(int i=Laxt[u];i;i=Next[i])
	{
		int v=To[i];
		if(!dfn[v])
		{
			tarjan(v);
			low[u]=min(low[u],low[v]);
		}
		else if(vis[v])
		low[u]=min(low[u],dfn[v]);
	}
	if(low[u]==dfn[u])
	{
		++scc;
		do{
			vis[sk[top]]=0;
			bel[sk[top--]]=scc;
		}while(sk[top+1]!=u);
	}
}
int dfs(int u)
{
	if(dp[u])return dp[u];
	int ans=0;
	for(int i=Laxt2[u];i;i=Next2[i])
	ans=max(ans,dfs(To2[i]));
	dp[u]=sz[u]+ans;
	return dp[u];
}
int main()
{
	int u,v;
	scanf("%d%d%d",&n,&m,&d);
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&u,&v);
		for(int j=0;j<d;j++)
		add(id(u,j),id(v,(j+1)%d));
	}
	for(int i=1;i<=n;i++)
	scanf("%s",s[i]);
	for(int i=1;i<=n*d;i++)
	if(!dfn[i])tarjan(i);
	for(int i=1;i<=n;i++)
	for(int j=0;j<d;j++)
	{
		int x=id(i,j);
		if(s[i][j]=='1'&&vis[bel[x]]!=i)
		vis[bel[x]]=i,sz[bel[x]]++;
		for(int k=Laxt[x];k;k=Next[k])
		{
			int v=To[k];
			if(bel[x]!=bel[v])
			add2(bel[x],bel[v]);
		}
	}
	printf("%d\n",dfs(bel[1]));
}


#include<bits/stdc++.h>
using namespace std;
string odd, even;

bool check(string str){
  for(int i =0;i<str.size()-1;i++){
    if(abs(str[i]-str[i+1]) == 1)
      	return false;
  }
  return true;
}

int main(){
  string str;
  int n;
  cin >> n;
  while(n--){
  	cin >> str;
    for(auto &it:str){
      if(it%2 == 0)
        even.push_back(it);
      else
        odd.push_back(it);
    }
    sort(even.begin(),even.end());
    sort(odd.begin(),odd.end());
    if(check(even+odd))
      cout<<(even+odd)<<endl;
    else if(check(odd+even))
      cout<<(odd+even)<<endl;
    else
        cout<<"No answer\n";
  }

}


#include<bits/stdc++.h>
using namespace std;
string odd, even;

bool check(string str){
  for(int i =0;i<str.size()-1;i++){
    if(abs(str[i]-str[i+1]) == 1)
      	return false;
  }
  return true;
}

int main(){
  string str;
  int n;
  cin >> n;
  while(n--){
  	cin >> str;
  	even.clear();
  	odd.clear();
    for(auto &it:str){
      if(it%2 == 0)
        even.push_back(it);
      else
        odd.push_back(it);
    }
    sort(even.begin(),even.end());
    sort(odd.begin(),odd.end());
    if(check(even+odd))
      cout<<(even+odd)<<endl;
    else if(check(odd+even))
      cout<<(odd+even)<<endl;
    else
        cout<<"No answer\n";
  }

}


#include<bits/stdc++.h>
using namespace std;
bool visit[102];
int main(){
	string str;
	int t;
	cin >> t;
	while(t--){
		cin >> str;
		memset(visit,0,sizeof(visit));
		sort(str.begin(),str.end());
		string ans = "";
		int sz = str.size();
		for(int i = 0;i<sz and str.size();i++){
			if(   ans.size() == 0   or (fabs(ans.back()-str[i] )!=1 and !visit[i] )){
				ans.push_back(str[i]);
				visit[i] =1;
			}
		}
		string other = "";
		for(int i = 0;i<str.size();i++){
			if(!visit[i])
				other.push_back(str[i]);

		}
		other+=ans;
		bool b = 0;
		for(int i = 0;i<other.size() -1;i++){
			if(fabs(other[i]-other[i+1]) == 1)
				b = 1;
			}
		if(b)
			cout<<"No answer\n";
		else
			cout<<other<<endl;
		//ans+=str;

		//cout<<ans<<endl;
	}

}


#include<bits/stdc++.h>
using namespace std;
int n;
string a,b,c;

bool p(string str){
    for(int i = 0;i<str.size()-1;i++){
        if(abs(str[i]-str[i+1]) == 1)
            return 0;
    }

    return 1;
}

int main(){
    cin >> n;
    while(n--){
        a.clear();
        b.clear();
        cin >> c;
        for(int i = 0;i<c.size();i++){
            if(c[i]%2 == 0)
                a.push_back(c[i]);
            else
                b.push_back(c[i]);
        }
        if(p(a+b))
            cout<<(a+b)<<endl;
        else if(p(b+a))
            cout<<(b+a)<<endl;
        else
            cout<<"No answer\n";

    }

}


#pragma GCC optimize("O3")
#pragma GCC target("tune=native")

#include <math.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <time.h>
#include <cassert>
#include <functional>
#include <memory.h>
#include <stack>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <chrono>
#include <fstream>
#include <climits>
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef unsigned u;
typedef long double ld;
typedef vector<vector<int>> vvi;
typedef unsigned char uc;
typedef unsigned short us;

#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define EPS 1e-9l
#define pii pair<int, int>
#define puu pair<u, u>
#define all(a) (a).begin(), (a).end()

const int DEBUG = 0;

mt19937 gen((u)chrono::high_resolution_clock::now().time_since_epoch().count());

#pragma comment(linker, "/STACK:67108864")

int ok(const string& s)
{
	for (int i = 0; i + 1 < s.size(); i++)
		if (abs(s[i] - s[i + 1]) == 1)
			return 0;

	return 1;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int test;
	cin >> test;

	while (test--)
	{
		string s;
		cin >> s;

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

		string s1 = s.substr(0, (s.size() + 1) / 2);
		string s2 = s.substr((s.size() + 1) / 2, s.size() - (s.size() + 1) / 2);

		{
			string res;

			for (int i1 = 0, i2 = 0; i1 < s1.size() || i2 < s2.size();)
			{
				if (i1 < s1.size())
					res += s1[i1++];

				if (i2 < s2.size())
					res += s2[i2++];
			}

			if (ok(res))
			{
				cout << res << "\n";
				continue;
			}
		}

		{
			string res;

			for (int i1 = 0, i2 = 0; i1 < s1.size() || i2 < s2.size();)
			{
				if (i2 < s2.size())
					res += s2[i2++];

				if (i1 < s1.size())
					res += s1[i1++];
			}

			if (ok(res))
			{
				cout << res << "\n";
				continue;
			}
		}

		{
			s1 = s2 = "";

			for (int i = 0; i < s.size(); i++)
				if (i % 2)
					s2 += s[i];
				else
					s1 += s[i];

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

			string res = s1 + s2;

			if (ok(res))
			{
				cout << res << "\n";
				continue;
			}
		}

		cout << "No answer\n";
	}

	return 0;
}


#pragma GCC optimize("O3")
#pragma GCC target("tune=native")

#include <math.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <time.h>
#include <cassert>
#include <functional>
#include <memory.h>
#include <stack>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <chrono>
#include <fstream>
#include <climits>
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef unsigned u;
typedef long double ld;
typedef vector<vector<int>> vvi;
typedef unsigned char uc;
typedef unsigned short us;

#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define EPS 1e-9l
#define pii pair<int, int>
#define puu pair<u, u>
#define all(a) (a).begin(), (a).end()

const int DEBUG = 0;

mt19937 gen((u)chrono::high_resolution_clock::now().time_since_epoch().count());

#pragma comment(linker, "/STACK:67108864")

int ok(const string& s)
{
	for (int i = 0; i + 1 < s.size(); i++)
		if (abs(s[i] - s[i + 1]) == 1)
			return 0;

	return 1;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int test;
	cin >> test;

	while (test--)
	{
		string s;
		cin >> s;

		sort(s.begin(), s.end());
		vector<int> cnt(26);

		for (char c : s)
			cnt[c - 'a']++;

		string res;

		for (int st = 0; st < s.size(); st++)
		{
			vector<int> tcnt(cnt);
			string tres;
			tres += s[st];
			tcnt[s[st] - 'a']--;

			for (int i = 1; i < s.size(); i++)
			{
				int next = -1;

				for (int j = 0; j < 26; j++)
					if (tcnt[j] && abs(j - tres[i - 1] - 'a') != 1)
						next = j;

				if (next == -1)
					break;

				tcnt[next]--;
				tres += 'a' + next;
			}

			if (tres.size() == s.size())
			{
				res = tres;
				break;
			}
		}

		if (res.size() == s.size())
			cout << res << "\n";
		else
			cout << "No answer\n";
	}

	return 0;
}


#pragma GCC optimize("O3")
#pragma GCC target("tune=native")

#include <math.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <time.h>
#include <cassert>
#include <functional>
#include <memory.h>
#include <stack>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <chrono>
#include <fstream>
#include <climits>
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef unsigned u;
typedef long double ld;
typedef vector<vector<int>> vvi;
typedef unsigned char uc;
typedef unsigned short us;

#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define EPS 1e-9l
#define pii pair<int, int>
#define puu pair<u, u>
#define all(a) (a).begin(), (a).end()

const int DEBUG = 0;

mt19937 gen((u)chrono::high_resolution_clock::now().time_since_epoch().count());

#pragma comment(linker, "/STACK:67108864")

int ok(const string& s)
{
	for (int i = 0; i + 1 < s.size(); i++)
		if (abs(s[i] - s[i + 1]) == 1)
			return 0;

	return 1;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int test;
	cin >> test;

	while (test--)
	{
		string s;
		cin >> s;

		string res;

		for (int i = 0; i < 100000; i++)
		{
			shuffle(s.begin(), s.end(), gen);

			if (ok(s))
			{
				res = s;
				break;
			}
		}

		if (res.size() == s.size())
			cout << res << "\n";
		else
			cout << "No answer\n";
	}

	return 0;
}


#pragma GCC optimize("O3")
#pragma GCC target("tune=native")

#include <math.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <time.h>
#include <cassert>
#include <functional>
#include <memory.h>
#include <stack>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <chrono>
#include <fstream>
#include <climits>
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef unsigned u;
typedef long double ld;
typedef vector<vector<int>> vvi;
typedef unsigned char uc;
typedef unsigned short us;

#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define EPS 1e-9l
#define pii pair<int, int>
#define puu pair<u, u>
#define all(a) (a).begin(), (a).end()

const int DEBUG = 0;

mt19937 gen((u)chrono::high_resolution_clock::now().time_since_epoch().count());

#pragma comment(linker, "/STACK:67108864")

int ok(const string& s)
{
	for (int i = 0; i + 1 < s.size(); i++)
		if (abs(s[i] - s[i + 1]) == 1)
			return 0;

	return 1;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int test;
	cin >> test;

	while (test--)
	{
		string s;
		cin >> s;

		string res;

		for (int i = 0; i < 25000; i++)
		{
			shuffle(s.begin(), s.end(), gen);

			if (ok(s))
			{
				res = s;
				break;
			}
		}

		if (res.size() == s.size())
			cout << res << "\n";
		else
			cout << "No answer\n";
	}

	return 0;
}


#pragma GCC optimize("O3")
#pragma GCC target("tune=native")

#include <math.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <time.h>
#include <cassert>
#include <functional>
#include <memory.h>
#include <stack>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <chrono>
#include <fstream>
#include <climits>
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef unsigned u;
typedef long double ld;
typedef vector<vector<int>> vvi;
typedef unsigned char uc;
typedef unsigned short us;

#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define EPS 1e-9l
#define pii pair<int, int>
#define puu pair<u, u>
#define all(a) (a).begin(), (a).end()

const int DEBUG = 0;

mt19937 gen((u)chrono::high_resolution_clock::now().time_since_epoch().count());

#pragma comment(linker, "/STACK:67108864")

int ok(const string& s)
{
	for (int i = 0; i + 1 < s.size(); i++)
		if (abs(s[i] - s[i + 1]) == 1)
			return 0;

	return 1;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int test;
	cin >> test;

	while (test--)
	{
		string s;
		cin >> s;

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

		string s1 = s.substr(0, (s.size() + 1) / 2);
		string s2 = s.substr((s.size() + 1) / 2, s.size() - (s.size() + 1) / 2);

		{
			string res;

			for (int i1 = 0, i2 = 0; i1 < s1.size() || i2 < s2.size();)
			{
				if (i1 < s1.size())
					res += s1[i1++];

				if (i2 < s2.size())
					res += s2[i2++];
			}

			if (ok(res))
			{
				cout << res << "\n";
				continue;
			}
		}

		{
			string res;

			for (int i1 = 0, i2 = 0; i1 < s1.size() || i2 < s2.size();)
			{
				if (i2 < s2.size())
					res += s2[i2++];

				if (i1 < s1.size())
					res += s1[i1++];
			}

			if (ok(res))
			{
				cout << res << "\n";
				continue;
			}
		}

		cout << "No answer\n";
	}

	return 0;
}


#pragma GCC optimize("O3")
#pragma GCC target("tune=native")

#include <math.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <time.h>
#include <cassert>
#include <functional>
#include <memory.h>
#include <stack>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <chrono>
#include <fstream>
#include <climits>
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef unsigned u;
typedef long double ld;
typedef vector<vector<int>> vvi;
typedef unsigned char uc;
typedef unsigned short us;

#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define EPS 1e-9l
#define pii pair<int, int>
#define puu pair<u, u>
#define all(a) (a).begin(), (a).end()

const int DEBUG = 0;

mt19937 gen((u)chrono::high_resolution_clock::now().time_since_epoch().count());

#pragma comment(linker, "/STACK:67108864")

int ok(const string& s)
{
	for (int i = 0; i + 1 < s.size(); i++)
		if (abs(s[i] - s[i + 1]) == 1)
			return 0;

	return 1;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int test;
	cin >> test;

	while (test--)
	{
		string s;
		cin >> s;

		sort(s.begin(), s.end());
		vector<int> cnt(26);

		for (char c : s)
			cnt[c - 'a']++;

		string res;

		for (int st = 0; st < s.size(); st++)
		{
			vector<int> tcnt(cnt);
			string tres;
			tres += s[st];
			tcnt[s[st] - 'a']--;

			for (int i = 1; i < s.size(); i++)
			{
				int next = -1;

				for (int j = 0; j < 26; j++)
					if (tcnt[j] && abs(j - (tres[i - 1] - 'a')) != 1)
						next = j;

				if (next == -1)
					break;

				tcnt[next]--;
				tres += 'a' + next;
			}

			if (tres.size() == s.size())
			{
				res = tres;
				break;
			}
		}

		if (res.size() == s.size())
			cout << res << "\n";
		else
			cout << "No answer\n";
	}

	return 0;
}


#include <math.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <time.h>
#include <cassert>
#include <functional>
#include <memory.h>
#include <stack>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <chrono>
#include <fstream>
#include <climits>
using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef unsigned u;
typedef long double ld;
typedef vector<vector<int>> vvi;
typedef unsigned char uc;
typedef unsigned short us;

#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define EPS 1e-9l
#define pii pair<int, int>
#define puu pair<u, u>
#define all(a) (a).begin(), (a).end()

const int DEBUG = 0;

mt19937 gen((u)chrono::high_resolution_clock::now().time_since_epoch().count());

#pragma comment(linker, "/STACK:67108864")

int ok(const string& s)
{
	for (int i = 0; i + 1 < s.size(); i++)
		if (abs(s[i] - s[i + 1]) == 1)
			return 0;

	return 1;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int test;
	cin >> test;

	while (test--)
	{
		string s;
		cin >> s;

		vector<int> cnt(26);

		for (char c : s)
			cnt[c - 'a']++;

		string s1, s2;

		for (int i = 0; i < 26; i += 2)
			for (; cnt[i]; cnt[i]--)
				s1 += 'a' + i;

		for (int i = 1; i < 26; i += 2)
			for (; cnt[i]; cnt[i]--)
				s2 += 'a' + i;

		string r1 = s1 + s2, r2 = s2 + s1;

		if (ok(r1))
			cout << r1 << "\n";
		else if (ok(r2))
			cout << r2 << "\n";
		else
			cout << "No answer\n";
	}

	return 0;
}


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

const int maxN = 100; int n;
int charCount[256];

int main()
{
  int t; scanf("%d", &t);
  while (t --)
  {
    char s[maxN + 1]; scanf(" %s", s); n = strlen(s);
    memset(charCount, 0, sizeof(charCount));
    for (int i = 0; s[i]; i ++) charCount[s[i]] ++;

    vector<char> toTest;
    for (int i = 'a'; i <= 'z'; i ++)
      if (charCount[i - 1] && charCount[i + 1])
        toTest.push_back(i);
    for (int i = 'a'; i <= 'z'; i ++)
      if (charCount[i - 1] || charCount[i + 1])
        toTest.push_back(i);
    for (int i = 'a'; i <= 'z'; i ++)
      if (!charCount[i - 1] && !charCount[i + 1])
        toTest.push_back(i);

    char newS[maxN + 1]; memset(newS, '\0', sizeof(newS));
    bool cant = false;
    for (int i = 0; i < n; i ++)
    {
      for (char jj: toTest)
        if (charCount[jj] && (!i || (newS[i - 1] != jj + 1 && newS[i - 1] != jj - 1)))
        {
          newS[i] = jj, charCount[jj] --;
          break;
        }
      if (newS[i] == '\0') cant = true;
    }
    printf("%s\n", cant ? "No answer" : newS);
  }
  return(0);
}


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

int main()
{
  int t; scanf("%d", &t);
  while (t --)
  {
    char s[101], seven[101], sodd[101];
    memset(s, '\0', sizeof(s)), memset(seven, '\0', sizeof(seven)), memset(sodd, '\0', sizeof(sodd));
    scanf(" %s", s);
    int sevenSize = 0, soddSize = 0;
    for (int i = 0; s[i]; i ++)
      if (s[i] & 1) seven[sevenSize ++] = s[i];
      else sodd[soddSize ++] = s[i];
    sort(seven, seven + sevenSize), sort(sodd, sodd + soddSize);

    if (abs(seven[sevenSize - 1] - sodd[0]) > 1)
      printf("%s%s\n", seven, sodd);
    else if (abs(sodd[soddSize - 1] - seven[0]) > 1)
      printf("%s%s\n", sodd, seven);
    else
      printf("No answer\n");
  }
  return(0);
}


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

const int maxN = 100; int n;
int charCount[256];

int main()
{
  int t; scanf("%d", &t);
  while (t --)
  {
    char s[maxN + 1]; scanf(" %s", s); n = strlen(s);
    memset(charCount, 0, sizeof(charCount));
    for (int i = 0; s[i]; i ++) charCount[s[i]] ++;

    vector<pair<pair<int, int>, char>> toTest;
    for (int i = 'a'; i <= 'z'; i ++)
      toTest.push_back({{(charCount[i - 1] > 0) || (charCount[i + 1] > 0), charCount[i - 1] + charCount[i + 1]}, i});

    char newS[maxN + 1]; memset(newS, '\0', sizeof(newS));
    bool cant = false;
    for (int i = 0; i < n; i ++)
    {
      sort(toTest.begin(), toTest.end()); reverse(toTest.begin(), toTest.end());
      for (auto j: toTest)
      {
        char jj = j.second;
        if (charCount[jj] && (!i || (newS[i - 1] != jj + 1 && newS[i - 1] != jj - 1)))
        {
          newS[i] = jj, charCount[jj] --;
          break;
        }
      }
      if (newS[i] == '\0') cant = true;
    }
    printf("%s\n", cant ? "No answer" : newS);
  }
  return(0);
}


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

const int maxN = 100; int n;
int charCount[256];

int main()
{
  int t; scanf("%d", &t);
  while (t --)
  {
    char s[maxN + 1]; scanf(" %s", s); n = strlen(s);
    memset(charCount, 0, sizeof(charCount));
    for (int i = 0; s[i]; i ++) charCount[s[i]] ++;

    vector<pair<pair<int, int>, char>> toTest;
    for (int i = 'a'; i <= 'z'; i ++)
      toTest.push_back({{charCount[i - 1] + charCount[i + 1], (charCount[i - 1] > 0) || (charCount[i + 1] > 0)}, i});
    sort(toTest.begin(), toTest.end()); reverse(toTest.begin(), toTest.end());

    char newS[maxN + 1]; memset(newS, '\0', sizeof(newS));
    bool cant = false;
    for (int i = 0; i < n; i ++)
    {
      for (auto j: toTest)
      {
        char jj = j.second;
        if (charCount[jj] && (!i || (newS[i - 1] != jj + 1 && newS[i - 1] != jj - 1)))
        {
          newS[i] = jj, charCount[jj] --;
          break;
        }
      }
      if (newS[i] == '\0') cant = true;
    }
    printf("%s\n", cant ? "No answer" : newS);
  }
  return(0);
}


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

const int maxN = 100; int n;
int charCount[256];

int main()
{
  int t; scanf("%d", &t);
  while (t --)
  {
    char s[maxN + 1]; scanf(" %s", s); n = strlen(s);
    memset(charCount, 0, sizeof(charCount));
    for (int i = 0; s[i]; i ++) charCount[s[i]] ++;

    vector<char> toTest;
    for (int i = 'a'; i <= 'z'; i ++)
      if (charCount[i - 1] && charCount[i + 1])
        toTest.push_back(i);
    for (int i = 'a'; i <= 'z'; i ++)
      if (charCount[i - 1] ^ charCount[i + 1])
        toTest.push_back(i);
    for (int i = 'a'; i <= 'z'; i ++)
      if (!charCount[i - 1] && !charCount[i + 1])
        toTest.push_back(i);

    char newS[maxN + 1]; memset(newS, '\0', sizeof(newS));
    bool cant = false;
    for (int i = 0; i < n; i ++)
    {
      for (char jj: toTest)
        if (charCount[jj] && (!i || (newS[i - 1] != jj + 1 && newS[i - 1] != jj - 1)))
        {
          newS[i] = jj, charCount[jj] --;
          break;
        }
      if (newS[i] == '\0') cant = true;
    }
    printf("%s\n", cant ? "No answer" : newS);
  }
  return(0);
}


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

const int maxN = 100; int n;
char s[maxN + 1];
int charCount[256];

int memo[100][256];
bool solve(int i = 0, int prv = 0)
{
  if (i == n) return(true);

  if (memo[i][prv] == -1)
    for (int j = 'a'; j <= 'z'; j ++)
      if (charCount[j] && (j != prv + 1 && j != prv - 1))
      {
        s[i] = j, charCount[j] --;
        if (solve(i + 1, j)) return(memo[i][prv] = true);
        charCount[j] ++;
      }
  return(memo[i][prv] = false);
}

int main()
{
  int t; scanf("%d", &t);
  while (t --)
  {
    scanf(" %s", s); n = strlen(s);
    memset(charCount, 0, sizeof(charCount));
    for (int i = 0; s[i]; i ++) charCount[s[i]] ++;

    memset(memo, -1, sizeof(memo));
    bool can = solve();
    printf("%s\n", !can ? "No answer" : s);
  }
  return(0);
}


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

const int maxN = 100; int n;
char s[maxN + 1];
int charCount[256];

int memo[100][256][256];
bool solve(int i = 0, int prv = 0, int prvprv = 0)
{
  if (i == n) return(true);

  if (memo[i][prv][prvprv] == -1)
    for (int j = 'a'; j <= 'z'; j ++)
      if (charCount[j] && (j != prv + 1 && j != prv - 1))
      {
        s[i] = j, charCount[j] --;
        if (solve(i + 1, j, prv)) return(memo[i][prv][prvprv] = true);
        charCount[j] ++;
      }
  return(memo[i][prv][prvprv] = false);
}

int main()
{
  int t; scanf("%d", &t);
  while (t --)
  {
    scanf(" %s", s); n = strlen(s);
    memset(charCount, 0, sizeof(charCount));
    for (int i = 0; s[i]; i ++) charCount[s[i]] ++;

    memset(memo, -1, sizeof(memo));
    bool can = solve();
    printf("%s\n", !can ? "No answer" : s);
  }
  return(0);
}


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

const int maxN = 100; int n;
int charCount[256];

int main()
{
  int t; scanf("%d", &t);
  while (t --)
  {
    char s[maxN + 1]; scanf(" %s", s); n = strlen(s);
    memset(charCount, 0, sizeof(charCount));
    for (int i = 0; s[i]; i ++) charCount[s[i]] ++;

    vector<pair<pair<int, int>, char>> toTest;
    for (int i = 'a'; i <= 'z'; i ++)
      toTest.push_back({{(charCount[i - 1] > 0) || (charCount[i + 1] > 0), charCount[i - 1] + charCount[i + 1]}, i});
    sort(toTest.begin(), toTest.end()); reverse(toTest.begin(), toTest.end());

    char newS[maxN + 1]; memset(newS, '\0', sizeof(newS));
    bool cant = false;
    for (int i = 0; i < n; i ++)
    {
      for (auto j: toTest)
      {
        char jj = j.second;
        if (charCount[jj] && (!i || (newS[i - 1] != jj + 1 && newS[i - 1] != jj - 1)))
        {
          newS[i] = jj, charCount[jj] --;
          break;
        }
      }
      if (newS[i] == '\0') cant = true;
    }
    printf("%s\n", cant ? "No answer" : newS);
  }
  return(0);
}


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

const int maxN = 100; int n;
int charCount[256];

int main()
{
  int t; scanf("%d", &t);
  while (t --)
  {
    char s[maxN + 1]; scanf(" %s", s); n = strlen(s);
    memset(charCount, 0, sizeof(charCount));
    for (int i = 0; s[i]; i ++) charCount[s[i]] ++;

    vector<pair<pair<int, int>, char>> toTest;
    for (int i = 'a'; i <= 'z'; i ++)
      toTest.push_back({{charCount[i - 1] + charCount[i + 1], (charCount[i - 1] > 0) || (charCount[i + 1] > 0)}, i});

    char newS[maxN + 1]; memset(newS, '\0', sizeof(newS));
    bool cant = false;
    for (int i = 0; i < n; i ++)
    {
      sort(toTest.begin(), toTest.end()); reverse(toTest.begin(), toTest.end());
      for (auto j: toTest)
      {
        char jj = j.second;
        if (charCount[jj] && (!i || (newS[i - 1] != jj + 1 && newS[i - 1] != jj - 1)))
        {
          newS[i] = jj, charCount[jj] --;
          break;
        }
      }
      if (newS[i] == '\0') cant = true;
    }
    printf("%s\n", cant ? "No answer" : newS);
  }
  return(0);
}


#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <cstring>
#include <iterator>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <chrono>
#include <assert.h>
#include <memory>
#include <cstddef>
#include <iterator>

#pragma comment(linker, "/stack:20000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

using namespace std;
typedef long long mt;
typedef double fl;

template<typename T>
constexpr mt infValue = std::is_same<T, int>::value ? 2000100007 : 8600000000000000007ll;
template<typename T>
constexpr mt maxValue = std::is_same<T, int>::value ? 1000000007 : 1000000000000000001ll;

#define rep(a, b, i) for(mt i = a; i < b; ++i)
#define repe(a, b, i) for(mt i = a; i <= (b); ++i)
#define repd(a, b, i) for(mt i = a; i > b; --i)
#define repde(a, b, i) for(mt i = a; i >= b; --i)

const mt INF = infValue<mt>;
const long long MOD = 1000000007ll;//998244353ll;
const double EPS = 1e-6;
const mt MAX = maxValue<mt>;
using pr = pair<mt, mt>;

#define N 2010
#define K 256
#define P 3
#define M (N * N)
#define p2(x) ((((x) * (x)) % (MOD)))
#define mxy(x, y) ((((x) * (y)) % (MOD)))
#define p2p(x) ((((x) * (x))))

mt t, n, cnt[256], diff;
char s[N];

int main(void) {
#ifdef _DEBUG
	freopen("in.txt", "r", stdin);
#endif
	scanf("%lld", &t);
	while (t--) {
		scanf("%s", s);
		n = strlen(s), diff = 0;
		rep(0, n, i) diff += !cnt[s[i]], ++cnt[s[i]];

		bool ok = true;
		if (diff == 2) {
			repe('a', 'z', i) if (cnt[i] && cnt[i - 1]) ok = false;
		}
		else if (diff == 3) {
			repe('a', 'z', i) if (cnt[i] && cnt[i - 1] && cnt[i - 2]) ok = false;
		}

		if (ok) {
			mt idx = 0;
			vector<mt> pos;
			repde('z', 'a', i) if ((i & 1) == 0 && cnt[i]) pos.push_back(i);
			idx = pos.size() - 1;
			repde('z', 'a', i) if ((i & 1) == 1 && cnt[i]) pos.push_back(i);

			if (idx >= 0 &&
				idx + 1 < pos.size() &&
				abs(pos[idx] - pos[idx + 1]) == 1) {

				swap(pos[0], pos[idx]);
				swap(pos[idx + 1], pos[pos.size() - 1]);
			}

			for (const mt& p : pos) while (cnt[p]--) putc(p, stdout), dc[tn++] = p;
			putc('\n', stdout);
		}
		else puts("No answer");
		memset(cnt, 0, sizeof(cnt));
	}

	return 0;
}


#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <cstring>
#include <iterator>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <chrono>
#include <assert.h>
#include <memory>
#include <cstddef>
#include <iterator>

#pragma comment(linker, "/stack:20000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

using namespace std;
typedef long long mt;
typedef double fl;

template<typename T>
constexpr mt infValue = std::is_same<T, int>::value ? 2000100007 : 8600000000000000007ll;
template<typename T>
constexpr mt maxValue = std::is_same<T, int>::value ? 1000000007 : 1000000000000000001ll;

#define rep(a, b, i) for(mt i = a; i < b; ++i)
#define repe(a, b, i) for(mt i = a; i <= (b); ++i)
#define repd(a, b, i) for(mt i = a; i > b; --i)
#define repde(a, b, i) for(mt i = a; i >= b; --i)

const mt INF = infValue<mt>;
const long long MOD = 1000000007ll;//998244353ll;
const double EPS = 1e-6;
const mt MAX = maxValue<mt>;
using pr = pair<mt, mt>;

#define N 2010
#define K 256
#define P 3
#define M (N * N)
#define p2(x) ((((x) * (x)) % (MOD)))
#define mxy(x, y) ((((x) * (y)) % (MOD)))
#define p2p(x) ((((x) * (x))))

mt t, n, cnt[256], diff;
char s[N];

char dc[N];
mt tn;
int main(void) {
#ifdef _DEBUG
	freopen("in.txt", "r", stdin);
#endif
	scanf("%lld", &t);
	while (t--) {
		scanf("%s", s);
		n = strlen(s), diff = 0;
		rep(0, n, i) diff += !cnt[s[i]], ++cnt[s[i]];

		bool ok = true;
		if (diff == 2) {
			repe('a', 'z', i) if (cnt[i] && cnt[i - 1]) ok = false;
		}
		else if (diff == 3) {
			repe('a', 'z', i) if (cnt[i] && cnt[i - 1] && cnt[i - 2]) ok = false;
		}

		if (ok) {
			tn = 0;

			if (diff == 3) {
				vector<mt> pos;
				repe('a', 'z', i) if (cnt[i]) pos.push_back(i);
				if (pos[0] + 1 == pos[1]) swap(pos[1], pos[2]);
				else swap(pos[0], pos[1]);
				rep(0, 3, i) while (cnt[pos[i]]--) putc(pos[i], stdout);
			}
			else {
				repde('z', 'a', i) if (i & 1) while (cnt[i]--) putc(i, stdout), dc[tn++] = i;
				repde('z', 'a', i) if (!(i & 1)) while (cnt[i]--) putc(i, stdout), dc[tn++] = i;
			}
			putc('\n', stdout);

			//dc[tn++] = 0;
			//rep(1, n, i) {
			//	if (abs(dc[i] - dc[i - 1]) == 1) {
			//		puts("===================================================");
			//		puts("Incomplete");
			//		puts(dc);
			//		puts("===================================================");
			//	}
			//}
		}
		else puts("No answer");
		memset(cnt, 0, sizeof(cnt));
	}

	return 0;
}


#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <cstring>
#include <iterator>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <chrono>
#include <assert.h>
#include <memory>
#include <cstddef>
#include <iterator>

#pragma comment(linker, "/stack:20000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

using namespace std;
typedef long long mt;
typedef double fl;

template<typename T>
constexpr mt infValue = std::is_same<T, int>::value ? 2000100007 : 8600000000000000007ll;
template<typename T>
constexpr mt maxValue = std::is_same<T, int>::value ? 1000000007 : 1000000000000000001ll;

#define rep(a, b, i) for(mt i = a; i < b; ++i)
#define repe(a, b, i) for(mt i = a; i <= (b); ++i)
#define repd(a, b, i) for(mt i = a; i > b; --i)
#define repde(a, b, i) for(mt i = a; i >= b; --i)

const mt INF = infValue<mt>;
const long long MOD = 1000000007ll;//998244353ll;
const double EPS = 1e-6;
const mt MAX = maxValue<mt>;
using pr = pair<mt, mt>;

#define N 2010
#define K 256
#define P 3
#define M (N * N)
#define p2(x) ((((x) * (x)) % (MOD)))
#define mxy(x, y) ((((x) * (y)) % (MOD)))
#define p2p(x) ((((x) * (x))))

mt t, n, cnt[256], diff;
char s[N];

int main(void) {
#ifdef _DEBUG
	freopen("in.txt", "r", stdin);
#endif
	scanf("%lld", &t);
	while (t--) {
		scanf("%s", s);
		n = strlen(s), diff = 0;
		rep(0, n, i) diff += !cnt[s[i]], ++cnt[s[i]];

		bool ok = true;
		if (diff == 2) {
			repe('a', 'z', i) if (cnt[i] && cnt[i - 1]) ok = false;
		}
		else if (diff == 3) {
			repe('a', 'z', i) if (cnt[i] && cnt[i - 1] && cnt[i - 2]) ok = false;
		}

		if (ok) {
			mt idx = 0;
			vector<mt> pos;
			repde('z', 'a', i) if ((i & 1) == 0 && cnt[i]) pos.push_back(i);
			idx = pos.size() - 1;
			repde('z', 'a', i) if ((i & 1) == 1 && cnt[i]) pos.push_back(i);

			if (idx >= 0 &&
				idx + 1 < pos.size() &&
				abs(pos[idx] - pos[idx + 1]) == 1) {

				swap(pos[0], pos[idx]);
				swap(pos[idx + 1], pos[pos.size() - 1]);
			}

			for (const mt& p : pos) while (cnt[p]--) putc(p, stdout);
			putc('\n', stdout);
		}
		else puts("No answer");
		memset(cnt, 0, sizeof(cnt));
	}

	return 0;
}


#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <cstring>
#include <iterator>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <chrono>
#include <assert.h>
#include <memory>
#include <cstddef>
#include <iterator>

#pragma comment(linker, "/stack:20000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

using namespace std;
typedef long long mt;
typedef double fl;

template<typename T>
constexpr mt infValue = std::is_same<T, int>::value ? 2000100007 : 8600000000000000007ll;
template<typename T>
constexpr mt maxValue = std::is_same<T, int>::value ? 1000000007 : 1000000000000000001ll;

#define rep(a, b, i) for(mt i = a; i < b; ++i)
#define repe(a, b, i) for(mt i = a; i <= (b); ++i)
#define repd(a, b, i) for(mt i = a; i > b; --i)
#define repde(a, b, i) for(mt i = a; i >= b; --i)

const mt INF = infValue<mt>;
const long long MOD = 1000000007ll;//998244353ll;
const double EPS = 1e-6;
const mt MAX = maxValue<mt>;
using pr = pair<mt, mt>;

#define N 2010
#define K 256
#define P 3
#define M (N * N)
#define p2(x) ((((x) * (x)) % (MOD)))
#define mxy(x, y) ((((x) * (y)) % (MOD)))
#define p2p(x) ((((x) * (x))))

mt t, n, cnt[256], diff;
char s[N];

char dc[N];
mt tn;
int main(void) {
#ifdef _DEBUG
	freopen("in.txt", "r", stdin);
#endif
	scanf("%lld", &t);
	while (t--) {
		scanf("%s", s);
		n = strlen(s), diff = 0;
		rep(0, n, i) diff += !cnt[s[i]], ++cnt[s[i]];

		bool ok = true;
		if (diff == 2) {
			repe('a', 'z', i) if (cnt[i] && cnt[i - 1]) ok = false;
		}
		else if (diff == 3) {
			repe('a', 'z', i) if (cnt[i] && cnt[i - 1] && cnt[i - 2]) ok = false;
		}

		if (ok) {
			tn = 0;

			mt idx = 0;
			vector<mt> pos;
			repde('z', 'a', i) if ((i & 1) == 0 && cnt[i]) pos.push_back(i);
			idx = pos.size() - 1;
			repde('z', 'a', i) if ((i & 1) == 1 && cnt[i]) pos.push_back(i);

			if (idx >= 0 &&
				idx + 1 < pos.size() &&
				abs(pos[idx] - pos[idx + 1]) == 1) {

				swap(pos[0], pos[idx]);
				swap(pos[idx + 1], pos[pos.size() - 1]);//swap(pos[0], pos[idx]);
				//else swap(pos[idx + 1], pos[pos.size() - 1]);
			}

			/*for (mt i = 0; i < (pos.size() >> 1); i += 2) {
				swap(pos[i], pos[pos.size() - 1 - i]);
			}*/
			//if(!!(pos.size() & 1)) swap(pos[(pos.size() >> 1) - 1], pos[pos.size() >> 1]);
			//swap(pos[0], pos[pos.size() >> 1]);
			//swap(pos[pos.size() - 1], pos[(pos.size() >> 1) - 1]);

			for (const mt& p : pos) while (cnt[p]--) putc(p, stdout), dc[tn++] = p;
			putc('\n', stdout);

			dc[tn++] = 0;
			rep(1, n, i) {
				if (abs(dc[i] - dc[i - 1]) == 1) {
					puts("===================================================");
					puts("Incomplete");
					puts(s);
					puts("RESULT");
					puts(dc);
					puts("===================================================");
				}
			}
		}
		else puts("No answer");
		memset(cnt, 0, sizeof(cnt));
	}

	return 0;
}


#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <cstring>
#include <iterator>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <chrono>
#include <assert.h>
#include <memory>
#include <cstddef>
#include <iterator>

#pragma comment(linker, "/stack:20000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

using namespace std;
typedef long long mt;
typedef double fl;

template<typename T>
constexpr mt infValue = std::is_same<T, int>::value ? 2000100007 : 8600000000000000007ll;
template<typename T>
constexpr mt maxValue = std::is_same<T, int>::value ? 1000000007 : 1000000000000000001ll;

#define rep(a, b, i) for(mt i = a; i < b; ++i)
#define repe(a, b, i) for(mt i = a; i <= (b); ++i)
#define repd(a, b, i) for(mt i = a; i > b; --i)
#define repde(a, b, i) for(mt i = a; i >= b; --i)

const mt INF = infValue<mt>;
const long long MOD = 1000000007ll;//998244353ll;
const double EPS = 1e-6;
const mt MAX = maxValue<mt>;
using pr = pair<mt, mt>;

#define N 2010
#define K 256
#define P 3
#define M (N * N)
#define p2(x) ((((x) * (x)) % (MOD)))
#define mxy(x, y) ((((x) * (y)) % (MOD)))
#define p2p(x) ((((x) * (x))))

mt t, n, cnt[256], diff;
char s[N];

char dc[N];
mt tn;
int main(void) {
#ifdef _DEBUG
	freopen("in.txt", "r", stdin);
#endif
	scanf("%lld", &t);
	while (t--) {
		scanf("%s", s);
		n = strlen(s), diff = 0;
		rep(0, n, i) diff += !cnt[s[i]], ++cnt[s[i]];

		bool ok = true;
		if (diff == 2) {
			repe('a', 'z', i) if (cnt[i] && cnt[i - 1]) ok = false;
		}
		else if (diff == 3) {
			repe('a', 'z', i) if (cnt[i] && cnt[i - 1] && cnt[i - 2]) ok = false;
		}

		if (ok) {
			tn = 0;

			vector<mt> pos;
			repe('a', 'z', i) if (cnt[i]) pos.push_back(i);
			for (mt i = 0; i < (pos.size() >> 1); i += 2) {
				swap(pos[i], pos[pos.size() - 1 - i]);
			}
			swap(pos[0], pos[pos.size() >> 1]);

			for (const mt& p : pos) while (cnt[p]--) putc(p, stdout);
			putc('\n', stdout);

			//dc[tn++] = 0;
			//rep(1, n, i) {
			//	if (abs(dc[i] - dc[i - 1]) == 1) {
			//		puts("===================================================");
			//		puts("Incomplete");
			//		puts(s);
			//		puts("RESULT");
			//		puts(dc);
			//		puts("===================================================");
			//	}
			//}
		}
		else puts("No answer");
		memset(cnt, 0, sizeof(cnt));
	}

	return 0;
}


#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <cstring>
#include <iterator>
#include <cmath>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <chrono>
#include <assert.h>
#include <memory>
#include <cstddef>
#include <iterator>

#pragma comment(linker, "/stack:20000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

using namespace std;
typedef long long mt;
typedef double fl;

template<typename T>
constexpr mt infValue = std::is_same<T, int>::value ? 2000100007 : 8600000000000000007ll;
template<typename T>
constexpr mt maxValue = std::is_same<T, int>::value ? 1000000007 : 1000000000000000001ll;

#define rep(a, b, i) for(mt i = a; i < b; ++i)
#define repe(a, b, i) for(mt i = a; i <= (b); ++i)
#define repd(a, b, i) for(mt i = a; i > b; --i)
#define repde(a, b, i) for(mt i = a; i >= b; --i)

const mt INF = infValue<mt>;
const long long MOD = 1000000007ll;//998244353ll;
const double EPS = 1e-6;
const mt MAX = maxValue<mt>;
using pr = pair<mt, mt>;

#define N 2010
#define K 256
#define P 3
#define M (N * N)
#define p2(x) ((((x) * (x)) % (MOD)))
#define mxy(x, y) ((((x) * (y)) % (MOD)))
#define p2p(x) ((((x) * (x))))

mt t, n, cnt[256], diff;
char s[N];

char dc[N];
mt tn;
int main(void) {
#ifdef _DEBUG
	freopen("in.txt", "r", stdin);
#endif
	scanf("%lld", &t);
	while (t--) {
		scanf("%s", s);
		n = strlen(s), diff = 0;
		rep(0, n, i) diff += !cnt[s[i]], ++cnt[s[i]];

		bool ok = true;
		if (diff == 2) {
			repe('a', 'z', i) if (cnt[i] && cnt[i - 1]) ok = false;
		}
		else if (diff == 3) {
			repe('a', 'z', i) if (cnt[i] && cnt[i - 1] && cnt[i - 2]) ok = false;
		}

		if (ok) {
			tn = 0;

			if (diff == 3) {
				repe('a', 'z', i) if (i & 1) {
					while (cnt[i]--) putc(i, stdout), dc[tn++] = i; break;
				}
				repe('a', 'z', i) if (!(i & 1)) {
					while (cnt[i]--) putc(i, stdout), dc[tn++] = i; break;
				}
				repde('z', 'a', i) if (i & 1) {
					while (cnt[i]--) putc(i, stdout), dc[tn++] = i; break;
				}
			}
			else {
				repde('z', 'a', i) if (i & 1) while (cnt[i]--) putc(i, stdout), dc[tn++] = i;
				repde('z', 'a', i) if (!(i & 1)) while (cnt[i]--) putc(i, stdout), dc[tn++] = i;
			}
			/*repe('a', 'z', i) if (!(i & 1)) while (cnt[i]--) putc(i, stdout), dc[tn++] = i;
			repe('a', 'z', i) if (i & 1) while (cnt[i]--) putc(i, stdout), dc[tn++] = i;*/
			putc('\n', stdout);

			/*dc[tn++] = 0;
			rep(1, n, i) {
				if (abs(dc[i] - dc[i - 1]) == 1) {
					puts("===================================================");
					puts("Incomplete");
					puts(dc);
					puts("===================================================");
				}
			}*/
		}
		else puts("No answer");
		memset(cnt, 0, sizeof(cnt));
	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = a; i <= b; ++i)
#define REP(i, n) for(int i = 0; i < n; ++i)
typedef long long llint;
const int MAXN = 200'200;

int main() {
	ios::sync_with_stdio(false);

#ifdef LOCAL
	freopen("input", "r", stdin);
#endif

	int T;
	cin >> T;
	REP (t, T) {
		string s;
		cin >> s;
		map<char, int> fre;
		for (char c: s) {
			fre[c] += 1;
		}

		vector<char> keys;
		keys.reserve(fre.size());
		for (auto e: fre) {
			keys.emplace_back(e.first);
		}
		sort(begin(keys), end(keys));

		unsigned long n = keys.size();
		if (n == 2 && keys[1] - keys[0] == 1) {
			cout << "No answer\n";
			continue;
		}

		if (n == 3 && keys[2] - keys[0] == 2) {
			cout << "No answer\n";
			continue;
		}

		for (int starter: {n - 2, n - 1}) {
			for (int i = starter; i >= 0; i -= 2) {
				REP (j, fre[keys[i]]) {
					cout << keys[i];
				}
			}
		}
		cout << "\n";
	}

	fclose(stdin);
}


#include<bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = a; i <= b; ++i)
#define REP(i, n) for(int i = 0; i < n; ++i)
typedef long long llint;
const int MAXN = 200'200;

int main() {
	ios::sync_with_stdio(false);

#ifdef LOCAL
	freopen("input", "r", stdin);
#endif

	int T;
	cin >> T;

	auto print = [] (char c, int n) {
		REP (i, n) {
			cout << c;
		}
	};

	REP (t, T) {
		string s;
		cin >> s;
		map<char, int> fre;
		for (char c: s) {
			fre[c] += 1;
		}

		vector<char> keys;
		for (auto e: fre) {
			keys.emplace_back(e.first);
		}

		unsigned long n = keys.size();
		if ((n == 2 && keys[1] - keys[0] == 1) ||  (n == 3 && keys[2] - keys[0] == 2)) {
			cout << "No answer\n";
			continue;
		}

		if (n == 3 && keys[1] - keys[0] > 1) {
			print(keys[1], fre[keys[1]]);
			print(keys[0], fre[keys[0]]);
			print(keys[2], fre[keys[2]]);
			cout << "\n";
			continue;
		}

		if (n == 3 && keys[2] - keys[1] > 1) {
			print(keys[0], fre[keys[0]]);
			print(keys[2], fre[keys[2]]);
			print(keys[1], fre[keys[1]]);
			cout << "\n";
			continue;
		}

		for (int starter: {1, 0}) {
			for (int i = starter; i < n; i += 2) {
				print(keys[i], fre[keys[i]]);
			}
		}
		cout << "\n";
	}

	fclose(stdin);
}


#include<bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = a; i <= b; ++i)
#define REP(i, n) for(int i = 0; i < n; ++i)
typedef long long llint;
const int MAXN = 200'200;

int main() {
	ios::sync_with_stdio(false);

#ifdef LOCAL
	freopen("input", "r", stdin);
#endif

	int T;
	cin >> T;

	auto print = [] (char c, int n) {
		REP (i, n) {
			cout << c;
		}
	};

	REP (t, T) {
		string s;
		cin >> s;
		map<char, int> fre;
		for (char c: s) {
			fre[c] += 1;
		}

		vector<char> keys;
		for (auto e: fre) {
			keys.emplace_back(e.first);
		}

		unsigned long n = keys.size();
		if ((n == 2 && keys[1] - keys[0] == 1) ||  (n == 3 && keys[2] - keys[0] == 2)) {
			cout << "No answer\n";
			continue;
		}

		if (n == 3 && keys[1] - keys[0] > 1) {
			print(keys[1], fre[keys[1]]);
			print(keys[0], fre[keys[0]]);
			print(keys[2], fre[keys[2]]);
			continue;
		}

		if (n == 3 && keys[2] - keys[1] > 1) {
			print(keys[0], fre[keys[0]]);
			print(keys[2], fre[keys[2]]);
			print(keys[1], fre[keys[1]]);
			continue;
		}

		for (int starter: {1, 0}) {
			for (int i = starter; i < n; i += 2) {
				print(keys[i], fre[keys[i]]);
			}
		}
		cout << "\n";
	}

	fclose(stdin);
}


#include <bits/stdc++.h>
using namespace std;
#define MAX                 100100
#define EPS                 1e-9
#define INF                 1e7
#define MOD                 1000003
#define pb                  push_back
#define mp                  make_pair
#define fi                  first
#define se                  second
#define pi                  acos(-1)
#define sf                  scanf
#define pf                  printf
#define SIZE(a)             ((int)a.size())
#define Equal(a, b)         (abs(a-b) < EPS)
#define Greater(a, b)       (a >= (b+EPS))
#define GreaterEqual(a, b)  (a > (b-EPS))
#define fr(i, a, b)         for(register int i = (a); i < (int)(b); i++)
#define FastRead            ios_base::sync_with_stdio(false); cin.tie(NULL);
#define dbug(vari)          cerr << #vari << " = " << (vari) <<endl
#define isOn(S, j)          (S & (1 << j))
#define setBit(S, j)        (S |= (1 << j))
#define clearBit(S, j)      (S &= ~(1 << j))
#define toggleBit(S, j)     (S ^= (1 << j))
#define lowBit(S)           (S & (-S))
#define setAll(S, n)        (S = (1 << n) - 1)
#define fileRead(S)         freopen(S, "r", stdin);
#define fileWrite(S)        freopen(S, "w", stdout);
#define Unique(X)           X.erase(unique(X.begin(), X.end()), X.end())

typedef unsigned long long ull;
typedef long long ll;
typedef map<int, int> mii;
typedef map<ll, ll>mll;
typedef map<string, int> msi;
typedef vector<int> vi;
typedef vector<long long>vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pair<int, int> > vii;
typedef vector<pair<ll, ll> >vll;

struct node {
    int val, prop;
    node() {
        val = 0;
        prop = -1;
    }
};

node tree[1510000];
queue<pair<pii, int> >query;
vi point;

void propagate(int pos, int l, int r) {
    if(tree[pos].prop == -1 || l==r)
        return;

    int mid = (l+r)>>1;
    if(tree[pos].prop) {
        tree[pos<<1].val = point[mid]-point[l]+1;
        tree[pos<<1|1].val = point[r]-point[mid+1]+1;
    }
    else {
        tree[pos<<1].val = 0;
        tree[pos<<1|1].val = 0;
    }
    tree[pos<<1].prop = tree[pos<<1|1].prop = tree[pos].prop;
    tree[pos].prop = -1;
}

void update(int pos, int l, int r, int lft, int rht, int flag) {
    if(rht < point[l] || point[r] < lft)
        return;

    //if(tree[pos].val == flag)
    //    return;

    propagate(pos, l, r);

    if(lft <= point[l] && point[r] <= rht) {
        //pf("update at %d- %d : ", point[l], point[r]);
        if(flag)
            tree[pos].val = point[r]-point[l]+1;
        else
            tree[pos].val = 0;
        //pf("%d\n", tree[pos].val);
        if(l != r)
            tree[pos].prop = flag;
        return;
    }

    int mid = (l+r)>>1;
    update(pos<<1, l, mid, lft, rht, flag);
    update(pos<<1|1, mid+1, r, lft, rht, flag);

    tree[pos].val = tree[pos<<1].val + tree[pos<<1|1].val;
    //pf("%d - %d : %d\n%d - %d : %d\n", point[l], point[mid], tree[pos<<1].val, point[mid+1], point[r], tree[pos<<1|1].val);
}

int main() {
    FastRead;
    //fileRead("in");
    int n, q, l, r, k;
    cin >> n >> q;

    point.pb(0);       // dummy
    while(q--) {
        cin >> l >> r >> k;
        k = (k==1 ? 1:0);
        query.push({{l, r}, k});

        point.pb(l);
        point.pb(r);
    }
    //cout << "DONE" << endl;
    sort(point.begin(), point.end());
    point.erase(unique(point.begin(), point.end()), point.end());

    //for(int i = 1; i < SIZE(point); ++i)
    //    cout << point[i] << " ";
    //cout << "DONE " << SIZE(point)-1<< endl;
    while(!query.empty()) {
        l = query.front().fi.fi, r = query.front().fi.se, k = query.front().se;
        query.pop();

        update(1, 1, SIZE(point)-1, l, r, k);
        cout << n-tree[1].val << endl;
    }

    return 0;
}


#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>

using std::vector;
using std::string;
using std::map;
using std::set;
using std::min;
using std::max;

typedef long long ll;
typedef double dd;

map<int, int> breaks;

int main()
{
    int n, m;
    std::cin >> n >> m;
    int wdc = n;
    for (int yy = 0; yy < m; ++yy)
    {
        int start, stop, t;
        std::cin >> start >> stop >> t;
        if (t == 1)
        {
            auto startIt = breaks.lower_bound(start);
            bool remove = true;
            if (breaks.size() == 0)
            {
                breaks[start] = stop;
                wdc -= stop - start + 1;
                std::cout << wdc << std::endl;
                continue;
            }
            if (startIt != breaks.begin())
            {
                startIt--;
                if(startIt->second < start) startIt++;
            }

            auto stopIt = breaks.upper_bound(stop);

            if (stopIt == breaks.end())
            {
                stopIt = breaks.find(breaks.rbegin()->first);
            }
            else
            {
                stopIt--;
            }

            auto newstart = start;
            if (startIt != breaks.end())
            {
                newstart = min(newstart, startIt->first);
            }
            auto newstop = max(stop, stopIt->second);
            stopIt++;
            for (auto It = startIt; It != stopIt; ++It)
            {
                wdc += It->second - It->first + 1;
            }
            breaks.erase(startIt, stopIt);
            breaks[newstart] = newstop;
            wdc -= newstop - newstart + 1;
        }
        else
        {
            auto startIt = breaks.lower_bound(start);
            bool remove = true;
            if (breaks.size() == 0)
            {
                std::cout << wdc << std::endl;
                continue;
            }
            if (startIt != breaks.begin())
            {
                startIt--;
                if (startIt->second < start) startIt++;
            }

            auto stopIt = breaks.upper_bound(stop);

            if (stopIt == breaks.end())
            {
                stopIt = breaks.find(breaks.rbegin()->first);
            }
            else
            {
                stopIt--;
            }

            auto newstart = start;
            if (startIt != breaks.end())
            {
                newstart = min(newstart, startIt->first);
            }
            auto newstop = max(stop, stopIt->second);
            stopIt++;
            for (auto It = startIt; It != stopIt; ++It)
            {
                wdc += It->second - It->first + 1;
            }
            breaks.erase(startIt, stopIt);
            if (newstart != start)
            {
                breaks[newstart] = start -1;
                wdc -= start - newstart;
            }
            if (newstop != stop)
            {
                breaks[stop+1] = newstop;
                wdc -= newstop - stop ;
            }

        }
        std::cout << wdc << std::endl;
    }
}


#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <set>
#include <cstdio>
using std::vector;
using std::string;
using std::map;
using std::set;
using std::min;
using std::max;

typedef long long ll;
typedef double dd;

struct element
{
    int start;
    int stop;
    element(int start, int stop) :start(start), stop(stop) {}
    bool operator<(const element& o) const
        {
            return stop < o.stop;
        }
};

std::set<element> breaks;

int main()
{
    int n, m;
    scanf("%d%d",&n,&m);
    int wdc = n;
    for (int yy = 0; yy < m; ++yy)
    {
        int start, stop, t;
        scanf("%d%d%d",&start,&stop,&t);
        auto startIt = breaks.lower_bound(element(start,start));
        int nstart = start;
        int nstop = stop;
        while(startIt != breaks.end())
        {
            const element& c = *startIt;
            if (c.start > stop)
                break;
            nstart = min(nstart, c.start);
            nstop = max(nstop, c.stop);
            wdc += c.stop - c.start + 1;
            startIt = breaks.erase(startIt);
        }
        if (t == 1)
        {
            wdc -= nstop - nstart + 1;
            breaks.insert(element(nstart,nstop));
        }
        else
        {
            if (nstart < start)
            {
                wdc -= start - nstart;
                breaks.insert(element(nstart,start - 1));
            }
            if (stop < nstop)
            {
                wdc -= nstop - stop;
                breaks.insert(element(stop + 1, nstop));
            }
        }
        printf("%d\n", wdc);
        // for (auto x : breaks)
        // {
        //     std::cout << "    " << x.start << "-" << x.stop << std::endl;
        // }
        // std::cout << "---------------------------" << std::endl;
    }
}


#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <set>
using std::vector;
using std::string;
using std::map;
using std::set;
using std::min;
using std::max;

typedef long long ll;
typedef double dd;

struct element
{
    int start;
    int stop;
    element(int start, int stop) :start(start), stop(stop) {}
    bool operator<(const element& o) const
        {
            return stop < o.stop;
        }
};

std::set<element> breaks;

int main()
{
    int n, m;
    std::cin >> n >> m;
    int wdc = n;
    for (int yy = 0; yy < m; ++yy)
    {
        int start, stop, t;
        std::cin >> start >> stop >> t;
        auto startIt = breaks.lower_bound(element(start,start));
        int nstart = start;
        int nstop = stop;
        while(startIt != breaks.end())
        {
            const element& c = *startIt;
            if (c.start > stop)
                break;
            nstart = min(nstart, c.start);
            nstop = max(nstart, c.stop);
            wdc += c.stop - c.start + 1;
            startIt = breaks.erase(startIt);
        }
        if (t == 1)
        {
            wdc -= nstop - nstart + 1;
            breaks.insert(element(nstart,nstop));
        }
        else
        {
            if (nstart < start)
            {
                wdc -= start - nstart;
                breaks.insert(element(nstart,start - 1));
            }
            if (stop < nstop)
            {
                wdc -= nstop - stop;
                breaks.insert(element(stop + 1, nstop));
            }
        }
        std::cout << wdc << std::endl;
    }
}


#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>

using std::vector;
using std::string;
using std::map;
using std::set;
using std::min;
using std::max;

typedef long long ll;
typedef double dd;

map<int, int> breaks;

int main()
{
    int n, m;
    std::cin >> n >> m;
    int wdc = n;
    for (int yy = 0; yy < m; ++yy)
    {
        int start, stop, t;
        std::cin >> start >> stop >> t;
        if (t == 1)
        {
            auto startIt = breaks.lower_bound(start);
            bool remove = true;
            if (breaks.size() == 0)
            {
                breaks[start] = stop;
                wdc -= stop - start + 1;
                std::cout << wdc << std::endl;
                continue;
            }
            if (startIt != breaks.begin())
            {
                startIt--;
                if(startIt->second < start) startIt++;
            }

            auto stopIt = breaks.upper_bound(stop);

            if (stopIt == breaks.end())
            {
                stopIt = breaks.find(breaks.rbegin()->first);
            }
            else
            {
                stopIt--;
            }

            auto newstart = start;
            if (startIt != breaks.end())
            {
                newstart = min(newstart, startIt->first);
            }
            auto newstop = max(stop, stopIt->second);
            stopIt++;
            for (auto It = startIt; It != stopIt; ++It)
            {
                wdc += It->second - It->first + 1;
            }
            breaks.erase(startIt, stopIt);
            breaks[newstart] = newstop;
            wdc -= newstop - newstart + 1;
        }
        else
        {
            auto startIt = breaks.lower_bound(start);
            bool remove = true;
            if (breaks.size() == 0)
            {
                std::cout << wdc << std::endl;
                continue;
            }
            if (startIt != breaks.begin())
            {
                startIt--;
                if (startIt->second < start) startIt++;
            }

            auto stopIt = breaks.upper_bound(stop);

            if (stopIt == breaks.end())
            {
                stopIt = breaks.find(breaks.rbegin()->first);
            }
            else
            {
                stopIt--;
            }

            auto newstart = start;
            if (startIt != breaks.end())
            {
                newstart = min(newstart, startIt->first);
            }
            auto newstop = max(stop, stopIt->second);
            stopIt++;
            for (auto It = startIt; It != stopIt; ++It)
            {
                wdc += It->second - It->first + 1;
            }
            breaks.erase(startIt, stopIt);
            if (newstart != start)
            {
                breaks[newstart+1] = start;
                wdc -= start - newstart;
            }
            if (newstop != stop)
            {
                breaks[stop+1] = newstop;
                wdc -= newstop - stop ;
            }

        }
        std::cout << wdc << std::endl;
    }
}


#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <set>
using std::vector;
using std::string;
using std::map;
using std::set;
using std::min;
using std::max;

typedef long long ll;
typedef double dd;

struct element
{
    int start;
    int stop;
    element(int start, int stop) :start(start), stop(stop) {}
    bool operator<(const element& o) const
        {
            return stop < o.stop;
        }
};

std::set<element> breaks;

int main()
{
    int n, m;
    std::cin >> n >> m;
    int wdc = n;
    for (int yy = 0; yy < m; ++yy)
    {
        int start, stop, t;
        std::cin >> start >> stop >> t;
        auto startIt = breaks.lower_bound(element(start,start));
        int nstart = start;
        int nstop = stop;
        while(startIt != breaks.end())
        {
            const element& c = *startIt;
            if (c.start > stop)
                break;
            nstart = min(nstart, c.start);
            nstop = max(nstop, c.stop);
            wdc += c.stop - c.start + 1;
            startIt = breaks.erase(startIt);
        }
        if (t == 1)
        {
            wdc -= nstop - nstart + 1;
            breaks.insert(element(nstart,nstop));
        }
        else
        {
            if (nstart < start)
            {
                wdc -= start - nstart;
                breaks.insert(element(nstart,start - 1));
            }
            if (stop < nstop)
            {
                wdc -= nstop - stop;
                breaks.insert(element(stop + 1, nstop));
            }
        }
        std::cout << wdc << std::endl;
        // for (auto x : breaks)
        // {
        //     std::cout << "    " << x.start << "-" << x.stop << std::endl;
        // }
        // std::cout << "---------------------------" << std::endl;
    }
}


#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <set>
using std::vector;
using std::string;
using std::map;
using std::set;
using std::min;
using std::max;

typedef long long ll;
typedef double dd;

struct element
{
    int start;
    int stop;
    element(int start, int stop) :start(start), stop(stop) {}
    bool operator<(const element& o) const
        {
            return stop < o.stop;
        }
};

std::set<element> breaks;

int main()
{
    int n, m;
    std::cin >> n >> m;
    int wdc = n;
    for (int yy = 0; yy < m; ++yy)
    {
        int start, stop, t;
        std::cin >> start >> stop >> t;
        auto startIt = breaks.lower_bound(element(start,start));
        int nstart = start;
        int nstop = stop;
        while(startIt != breaks.end())
        {
            const element& c = *startIt;
            if (c.start > stop)
                break;
            nstart = min(nstart, c.start);
            nstop = max(nstop, c.stop);
            wdc += c.stop - c.start + 1;
            startIt = breaks.erase(startIt);
        }
        if (t == 1)
        {
            wdc -= nstop - nstart + 1;
            breaks.insert(element(nstart,nstop));
        }
        else
        {
            if (nstart < start)
            {
                wdc -= start - nstart;
                breaks.insert(element(nstart,start - 1));
            }
            if (stop < nstop)
            {
                wdc -= nstop - stop;
                breaks.insert(element(stop + 1, nstop));
            }
        }
        std::cout << wdc << "\n";
        // for (auto x : breaks)
        // {
        //     std::cout << "    " << x.start << "-" << x.stop << std::endl;
        // }
        // std::cout << "---------------------------" << std::endl;
    }
}


#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>

using std::vector;
using std::string;
using std::map;
using std::set;
using std::min;
using std::max;

typedef long long ll;
typedef double dd;

map<int, int> breaks;

int main()
{
    int n, m;
    std::cin >> n >> m;
    int wdc = n;
    for (int yy = 0; yy < m; ++yy)
    {
        int start, stop, t;
        std::cin >> start >> stop >> t;
        if (breaks.size() == 0)
        {
            if (t == 1)
            {
                breaks[start] = stop;
                wdc -= stop - start + 1;
            }
            std::cout << wdc << std::endl;
            continue;
        }
        auto startIt = breaks.lower_bound(start - 1);
        bool remove = true;
        if (startIt != breaks.begin())
        {
            startIt--;
            if (startIt->second < start -1) startIt++;
        }
        auto stopIt = breaks.lower_bound(stop + 1);
        auto realStopIt = stopIt--;
        if (stopIt == startIt)
        {
            if (t == 1)
            {
                breaks[start] = stop;
                wdc -= stop - start + 1;
            }
            std::cout << wdc << std::endl;
            continue;

        }

        auto newstart = min(start, startIt->first);
        auto newstop = max(stop, realStopIt->second);
        for (auto It = startIt; It != stopIt; ++It)
        {
            wdc += It->second - It->first + 1;
        }
        breaks.erase(startIt, stopIt);
        if (t == 1)
        {
            breaks[newstart] = newstop;
            wdc -= newstop - newstart + 1;
        }
        else
        {
            if (newstart != start)
            {
                breaks[newstart] = start -1;
                wdc -= start - newstart;

            }
            if (newstop != stop)
            {
                breaks[stop+1] = newstop;
                wdc -= newstop - stop;
            }

        }
        std::cout << wdc << std::endl;
    }
}


#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>

using std::vector;
using std::string;
using std::map;
using std::set;
using std::min;
using std::max;

typedef long long ll;
typedef double dd;

map<int, int> breaks;

int main()
{
    int n, m;
    std::cin >> n >> m;
    int wdc = n;
    for (int yy = 0; yy < m; ++yy)
    {
        int start, stop, t;
        std::cin >> start >> stop >> t;
        if (breaks.size() == 0)
        {
            if (t == 1)
            {
                breaks[start] = stop;
                wdc -= stop - start + 1;
            }
            std::cout << wdc << std::endl;
            continue;
        }
        auto startIt = breaks.lower_bound(start - 1);
        bool remove = true;
        if (startIt != breaks.begin())
        {
            startIt--;
            if (startIt->second < start -1) startIt++;
        }
        auto stopIt = breaks.lower_bound(stop + 1);
        if (stopIt == startIt)
        {
            if (t == 1)
            {
                breaks[start] = stop;
                wdc -= stop - start + 1;
            }
            std::cout << wdc << std::endl;
            continue;

        }
        auto realStopIt = stopIt;
        realStopIt--;

        auto newstart = min(start, startIt->first);
        auto newstop = max(stop, realStopIt->second);
        for (auto It = startIt; It != stopIt; ++It)
        {
            wdc += It->second - It->first + 1;
        }
        breaks.erase(startIt, stopIt);
        if (t == 1)
        {
            breaks[newstart] = newstop;
            wdc -= newstop - newstart + 1;
        }
        else
        {
            if (newstart != start)
            {
                breaks[newstart] = start -1;
                wdc -= start - newstart;

            }
            if (newstop != stop)
            {
                breaks[stop+1] = newstop;
                wdc -= newstop - stop;
            }

        }
        std::cout << wdc << std::endl;
    }
}


#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>

using std::vector;
using std::string;
using std::map;
using std::set;
using std::min;
using std::max;

typedef long long ll;
typedef double dd;

map<int, int> breaks;

int main()
{
    int n, m;
    std::cin >> n >> m;
    int wdc = n;
    for (int yy = 0; yy < m; ++yy)
    {
        int start, stop, t;
        std::cin >> start >> stop >> t;
        if (breaks.size() == 0)
        {
            if (t == 1)
            {
                breaks[start] = stop;
                wdc -= stop - start + 1;
            }
            std::cout << wdc << std::endl;
            continue;
        }
        auto startIt = breaks.lower_bound(start - 1);
        bool remove = true;
        if (startIt != breaks.begin())
        {
            startIt--;
            if (startIt->second < start -1) startIt++;
        }
        if (startIt == breaks.end() || startIt->first > stop + 1)
        {
            if (t == 1)
            {
                breaks[start] = stop;
                wdc -= stop - start + 1;
            }
            std::cout << wdc << std::endl;
            continue;
        }
        auto stopIt = breaks.lower_bound(stop + 1);
        auto realStopIt = stopIt;
        realStopIt--;

        auto newstart = min(start, startIt->first);
        auto newstop = max(stop, realStopIt->second);
        for (auto It = startIt; It != stopIt; ++It)
        {
            wdc += It->second - It->first + 1;
        }
        breaks.erase(startIt, stopIt);
        if (t == 1)
        {
            breaks[newstart] = newstop;
            wdc -= newstop - newstart + 1;
        }
        else
        {
            if (newstart != start)
            {
                breaks[newstart] = start -1;
                wdc -= start - newstart;

            }
            if (newstop != stop)
            {
                breaks[stop+1] = newstop;
                wdc -= newstop - stop;
            }

        }
        std::cout << wdc << std::endl;
    }
}


#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <set>
using std::vector;
using std::string;
using std::map;
using std::set;
using std::min;
using std::max;

typedef long long ll;
typedef double dd;

struct element
{
    int start;
    int stop;
    element(int start, int stop) :start(start), stop(stop) {}
    bool operator<(const element& o) const
        {
            return stop < o.stop;
        }
};

std::set<element> breaks;

int main()
{
    std::ios_base::sync_with_stdio(false);
    int n, m;
    std::cin >> n >> m;
    int wdc = n;
    for (int yy = 0; yy < m; ++yy)
    {
        int start, stop, t;
        std::cin >> start >> stop >> t;
        auto startIt = breaks.lower_bound(element(start,start));
        int nstart = start;
        int nstop = stop;
        while(startIt != breaks.end())
        {
            const element& c = *startIt;
            if (c.start > stop)
                break;
            nstart = min(nstart, c.start);
            nstop = max(nstop, c.stop);
            wdc += c.stop - c.start + 1;
            startIt = breaks.erase(startIt);
        }
        if (t == 1)
        {
            wdc -= nstop - nstart + 1;
            breaks.insert(element(nstart,nstop));
        }
        else
        {
            if (nstart < start)
            {
                wdc -= start - nstart;
                breaks.insert(element(nstart,start - 1));
            }
            if (stop < nstop)
            {
                wdc -= nstop - stop;
                breaks.insert(element(stop + 1, nstop));
            }
        }
        std::cout << wdc << "\n";
        // for (auto x : breaks)
        // {
        //     std::cout << "    " << x.start << "-" << x.stop << std::endl;
        // }
        // std::cout << "---------------------------" << std::endl;
    }
}


#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>

using std::vector;
using std::string;
using std::map;
using std::set;
using std::min;
using std::max;

typedef long long ll;
typedef double dd;

map<int, int> breaks;

int main()
{
    int n, m;
    std::cin >> n >> m;
    int wdc = n;
    for (int yy = 0; yy < m; ++yy)
    {
        int start, stop, t;
        std::cin >> start >> stop >> t;
        if (breaks.size() == 0)
        {
            if (t == 1)
            {
                breaks[start] = stop;
                wdc -= stop - start + 1;
            }
            std::cout << wdc << std::endl;
            continue;
        }
        auto startIt = breaks.lower_bound(start - 1);
        bool remove = true;
        if (startIt != breaks.begin())
        {
            startIt--;
            if (startIt->second < start -1) startIt++;
        }
        auto stopIt = startIt;
        auto realStopIt = startIt;
        while (stopIt != breaks.end() && stopIt->first <= stop + 1)
        {
            realStopIt = stopIt++;
        }

        if (stopIt == startIt)
        {
            if (t == 1)
            {
                breaks[start] = stop;
                wdc -= stop - start + 1;
            }
            std::cout << wdc << std::endl;
            continue;

        }

        auto newstart = min(start, startIt->first);
        auto newstop = max(stop, realStopIt->second);
        for (auto It = startIt; It != stopIt; ++It)
        {
            wdc += It->second - It->first + 1;
        }
        breaks.erase(startIt, stopIt);
        if (t == 1)
        {
            breaks[newstart] = newstop;
            wdc -= newstop - newstart + 1;
        }
        else
        {
            if (newstart != start)
            {
                breaks[newstart] = start -1;
                wdc -= start - newstart;

            }
            if (newstop != stop)
            {
                breaks[stop+1] = newstop;
                wdc -= newstop - stop;
            }

        }
        std::cout << wdc << std::endl;
    }
}


#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>

using std::vector;
using std::string;
using std::map;
using std::set;
using std::min;
using std::max;

typedef long long ll;
typedef double dd;

map<int, int> breaks;

int main()
{
    int n, m;
    std::cin >> n >> m;
    int wdc = n;
    for (int yy = 0; yy < m; ++yy)
    {
        int start, stop, t;
        std::cin >> start >> stop >> t;
        if (breaks.size() == 0)
        {
            if (t == 1)
            {
                breaks[start] = stop;
                wdc -= stop - start + 1;
            }
            std::cout << wdc << std::endl;
            continue;
        }
        auto startIt = breaks.lower_bound(start - 1);
        bool remove = true;
        if (startIt != breaks.begin())
        {
            startIt--;
            if (startIt->second < start -1) startIt++;
        }
        if (startIt == breaks.end() || startIt->first > stop + 1)
        {
            if (t == 1)
            {
                breaks[start] = stop;
                wdc -= stop - start + 1;
            }
            std::cout << wdc << std::endl;
            continue;
        }
        auto stopIt = breaks.lower_bound(stop + 1);
        if (stopIt == breaks.begin())
        {
            if (t == 1)
            {
                breaks[start] = stop;
                wdc -= stop - start + 1;
            }
            std::cout << wdc << std::endl;
            continue;
        }

        auto realStopIt = stopIt;
        realStopIt--;

        auto newstart = min(start, startIt->first);
        auto newstop = max(stop, realStopIt->second);
        for (auto It = startIt; It != stopIt; ++It)
        {
            wdc += It->second - It->first + 1;
        }
        breaks.erase(startIt, stopIt);
        if (t == 1)
        {
            breaks[newstart] = newstop;
            wdc -= newstop - newstart + 1;
        }
        else
        {
            if (newstart != start)
            {
                breaks[newstart] = start -1;
                wdc -= start - newstart;

            }
            if (newstop != stop)
            {
                breaks[stop+1] = newstop;
                wdc -= newstop - stop;
            }

        }
        std::cout << wdc << std::endl;
    }
}