#include <bits/stdc++.h>
#include <vector>
#include <cstdio>
#include <string>
using namespace std;
typedef long long ll;
int main()
{
	int t;
	cin >> t;
	while ( t-- )
	{
		int n;
		cin>>n;
		int a[n];
		for(int i=0;i<n;i++)
			cin >>a[i];
		if(n<=11)
		{
			cout<<n<<endl;
			for(int i=0;i<n;i++)
				cout <<i+1<<" ";
			cout<<endl;
			continue;
		}
		int c[n];
		int b[]={2,3,5,7,11,13,17,19,23,29,31};int x=1;
		int d[11]={};
		for(int j=0;j<11;j++)
			d[j]=-1;
		for(int i=0;i<n;i++)
		{
			int flag=0;
			for(int j=0;j<11;j++)
			{
				if(a[i]%b[j]==0 && d[j]==-1)
				{
					d[j]=x++;
					c[i]=d[j];
					break;
				}
				else if(a[i]%b[j]==0 && d[j]!=-1)
				{

					c[i]=d[j];
					break;
				}

			}

		}
//			for(int j=0;j<11;j++)
//			cout<<d[j]<<" ";
//			cout<<endl;
		for(int i=0;i<n;i++)
		{
			int flag=0;
			for(int j=0;j<11;j++)
			{
				if(a[i]%b[j]==0)
				{
					flag=1;
					break;
				}

			}
			if(flag==0)
				c[i]=x++;
		}
		int mx=*max_element(c,c+n);
		cout<<mx<<endl;
		for(int i=0;i<n;i++)
				cout <<c[i]<<" ";
		cout<<endl;
	}
}


#include <bits/stdc++.h>
#include <vector>
#include <cstdio>
#include <string>
using namespace std;
typedef long long ll;
int main()
{
	int t;
	cin >> t;
	while ( t-- )
	{
		int n;
		cin>>n;
		int a[n];
		for(int i=0;i<n;i++)
			cin >>a[i];
		if(n<=11)
		{
			cout<<n<<endl;
			for(int i=0;i<n;i++)
				cout <<i+1<<" ";
			cout<<endl;
			continue;
		}
		int c[n];
		int b[]={2,3,5,7,11,13,17,19,23,31,37};int x=1;
		for(int i=0;i<n;i++)
		{
			int flag=0;
			for(int j=0;j<11;j++)
			{
				if(a[i]%b[j]==0)
				{
					flag=1;
					break;
				}

			}
			if(flag==0)
				c[i]=x++;
		}
		for(int i=0;i<n;i++)
		{
			int flag=0;
			for(int j=0;j<11;j++)
			{
				if(a[i]%b[j]==0)
				{
					c[i]=x+j;
					break;
				}
			}
		}
		int mx=*max_element(c,c+n);
		cout<<mx<<endl;
		for(int i=0;i<n;i++)
				cout <<c[i]<<" ";
		cout<<endl;
	}
}


#include <bits/stdc++.h>
#include <vector>
#include <cstdio>
#include <string>
using namespace std;
typedef long long ll;
int main()
{
	int t;
	cin >> t;
	while ( t-- )
	{
		int n;
		cin>>n;
		int a[n];
		for(int i=0;i<n;i++)
			cin >>a[i];
		if(n<=11)
		{
			cout<<n<<endl;
			for(int i=0;i<n;i++)
				cout <<i+1<<" ";
			cout<<endl;
			continue;
		}
		int c[n];
		int b[]={2,3,5,7,11,13,17,19,23,31,37};int x=1;
		for(int i=0;i<n;i++)
		{
			int flag=0;
			for(int j=0;j<12;j++)
			{
				if(a[i]%b[j]==0)
				{
					flag=1;
					break;
				}

			}
			if(flag==0)
				c[i]=x++;
		}
		for(int i=0;i<n;i++)
		{
			int flag=0;
			for(int j=0;j<12;j++)
			{
				if(a[i]%b[j]==0)
				{
					c[i]=x+j;
					break;
				}
			}
		}
		int mx=*max_element(c,c+n);
		cout<<mx<<endl;
		for(int i=0;i<n;i++)
				cout <<c[i]<<" ";
		cout<<endl;
	}
}


#include <bits/stdc++.h>
#include <vector>
#include <cstdio>
#include <string>
using namespace std;
typedef long long ll;
int main()
{
	int t;
	cin >> t;
	while ( t-- )
	{
		int n;
		cin>>n;
		int a[n];
		for(int i=0;i<n;i++)
			cin >>a[i];
		if(n<=11)
		{
			cout<<n<<endl;
			for(int i=0;i<n;i++)
				cout <<i+1<<" ";
			cout<<endl;
			continue;
		}
		int c[n];
		int b[]={2,3,5,7,11,13,17,19,23,31,37};int x=1;
		int d[11]={};
		for(int j=0;j<11;j++)
			d[j]=-1;
		for(int i=0;i<n;i++)
		{
			int flag=0;
			for(int j=0;j<11;j++)
			{
				if(a[i]%b[j]==0 && d[j]==-1)
				{
					d[j]=x++;
					c[i]=d[j];
					break;
				}
				else if(a[i]%b[j]==0 && d[j]!=-1)
				{

					c[i]=d[j];
					break;
				}

			}

		}
//			for(int j=0;j<11;j++)
//			cout<<d[j]<<" ";
//			cout<<endl;
		for(int i=0;i<n;i++)
		{
			int flag=0;
			for(int j=0;j<11;j++)
			{
				if(a[i]%b[j]==0)
				{
					flag=1;
					break;
				}

			}
			if(flag==0)
				c[i]=x++;
		}
		int mx=*max_element(c,c+n);
		cout<<mx<<endl;
		for(int i=0;i<n;i++)
				cout <<c[i]<<" ";
		cout<<endl;
	}
}


#include <bits/stdc++.h>
#include <vector>
#include <cstdio>
#include <string>
using namespace std;
typedef long long ll;
int main()
{
	int t;
	cin >> t;
	while ( t-- )
	{
		int n;
		cin>>n;
		int a[n];
		for(int i=0;i<n;i++)
			cin >>a[i];
		if(n<=11)
		{
			cout<<n<<endl;
			for(int i=0;i<n;i++)
				cout <<i+1<<" ";
			cout<<endl;
			continue;
		}
		int c[n];
		int b[]={2,3,5,7,11,13,17,19,23,31,37};int x=1;
		int d[11]={};
		for(int j=0;j<11;j++)
			d[j]=-1;
		for(int i=0;i<n;i++)
		{
			int flag=0;
			for(int j=0;j<11;j++)
			{
				if(a[i]%b[j]==0 && d[j]==-1)
				{
					d[j]=x++;
					break;
				}

			}

		}
		for(int j=0;j<11;j++)
//			cout<<d[j]<<" ";
//			cout<<endl;
		for(int i=0;i<n;i++)
		{
			int flag=0;
			for(int j=0;j<11;j++)
			{
				if(a[i]%b[j]==0)
				{
					flag=1;
					break;
				}

			}
			if(flag==0)
				c[i]=x++;
		}
		for(int i=0;i<n;i++)
		{
			int flag=0;
			for(int j=0;j<11;j++)
			{
				if(a[i]%b[j]==0)
				{
					c[i]=d[j];
					break;
				}
			}
		}
		int mx=*max_element(c,c+n);
		cout<<mx<<endl;
		for(int i=0;i<n;i++)
				cout <<c[i]<<" ";
		cout<<endl;
	}
}


#include<bits/stdc++.h>
#define fi        first
#define se        second
#define pb        push_back
#define PI        acos(-1)
#define LC(a)     ((a<<1))
#define RC(a)     ((a<<1)+1)
#define MID(a,b)  ((a+b)>>1)
#define mem(a, b) memset(a, b, sizeof(a))
#define IOS()     std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
typedef long long ll;
typedef unsigned long long ULL;
typedef pair<int,int> PII;
typedef pair<ll,ll>   PLL;
typedef pair<ll,int>  PLI;
const int INF = 0X3F3F3F3F;
const int MIN = -(1<<30);
const ll N = 1e5+7;
map<int,int> mp;
int v[1005];
int a[1005];
int idx=1;
int check(int x)
{
	int prime[100];
	int k=0;
	for(int i=2; i*i<=x; i++)
	{
		if(x%i==0)
		{
			prime[k++]=i;
			while(x%i==0)
			{
				x/=i;
			}
		}
	}
	if(x!=1) prime[k++]=x;
	int flag=1;
	for(int i=0; i<k; i++)
		if(mp[prime[i]])
			return mp[prime[i]];

	mp[prime[0]] = idx++;
	return mp[prime[0]];
}
inline void solve()
{
	idx=1;
	mp.clear();
	mem(v,0);
	int n;
	cin>>n;
	for(int i=1; i<=n; i++)
	{
		cin>>a[i];
		v[i] = check(a[i]);
	}

	cout<<idx-1<<endl;
	for(int i=1; i<=n; i++)
		cout<<v[i]<<" ";
	cout<<endl;
}
int main()
{
	IOS();
	int T;
	cin>>T;
	while(T--) solve();
	return 0;
}


#include<bits/stdc++.h>
#define fi        first
#define se        second
#define pb        push_back
#define PI        acos(-1)
#define LC(a)     ((a<<1))
#define RC(a)     ((a<<1)+1)
#define MID(a,b)  ((a+b)>>1)
#define mem(a, b) memset(a, b, sizeof(a))
#define IOS()     std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
typedef long long ll;
typedef unsigned long long ULL;
typedef pair<int,int> PII;
typedef pair<ll,ll>   PLL;
typedef pair<ll,int>  PLI;
const int INF = 0X3F3F3F3F;
const int MIN = -(1<<30);
const ll N = 1e5+7;
map<int,int> mp;
int v[1005];
int a[1005];
int idx=1;
//int check(int x)
//{
//	int prime[100];
//	int k=0;
//	for(int i=2; i*i<=x; i++)
//	{
//		if(x%i==0)
//		{
//			prime[k++]=i;
//			while(x%i==0)
//			{
//				x/=i;
//			}
//		}
//	}
//	if(x!=1) prime[k++]=x;
//	int flag=1;
//	for(int i=0; i<k; i++)
//		if(mp[prime[i]])
//			return mp[prime[i]];
//
//	mp[prime[0]] = idx++;
//	return mp[prime[0]];
//}
int pre[]= {0,2,3,5,7,11,13,17,19,23,29,31};
int check(int x)
{
	for(int i=1; i<12; i++)
		if(x%pre[i]==0)
		{
			idx = max(idx,i);
			      return i;
		}
}
inline void solve()
{
	mem(v,0);
	int n;
	cin>>n;
	for(int i=1; i<=n; i++)
	{
		cin>>a[i];
		v[i] = check(a[i]);
	}

	cout<<idx<<endl;
	for(int i=1; i<=n; i++)
		cout<<v[i]<<" ";
	cout<<endl;
}
int main()
{
	IOS();
	int T;
	cin>>T;
	while(T--) solve();
	return 0;
}


#include<bits/stdc++.h>
#define fi        first
#define se        second
#define pb        push_back
#define PI        acos(-1)
#define LC(a)     ((a<<1))
#define RC(a)     ((a<<1)+1)
#define MID(a,b)  ((a+b)>>1)
#define mem(a, b) memset(a, b, sizeof(a))
#define IOS()     std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
typedef long long ll;
typedef unsigned long long ULL;
typedef pair<int,int> PII;
typedef pair<ll,ll>   PLL;
typedef pair<ll,int>  PLI;
const int INF = 0X3F3F3F3F;
const int MIN = -(1<<30);
const ll N = 1e5+7;
map<int,int> mp;
int v[1005];
int a[1005];
int idx=1;
int check(int x)
{
	int prime[100];
	int k=0;
	for(int i=2; i*i<=x; i++)
	{
		if(x%i==0)
		{
			prime[k++]=i;
			while(x%i==0)
			{
				x/=i;
			}
		}
	}
	if(x!=1) prime[k++]=x;
	int flag=1;
	for(int i=0; i<k; i++)
		if(mp[prime[i]])
			return mp[prime[i]];

	mp[prime[0]] = idx++;
	return mp[prime[0]];
}
inline void solve()
{
	mem(v,0);
	int n;
	cin>>n;
	for(int i=1; i<=n; i++)
	{
		cin>>a[i];
		v[i] = check(a[i]);
	}

	cout<<idx-1<<endl;
	for(int i=1; i<=n; i++)
		cout<<v[i]<<" ";
	cout<<endl;
}
int main()
{
	IOS();
	int T;
	cin>>T;
	while(T--) solve();
	return 0;
}


#include<bits/stdc++.h>
#define fi        first
#define se        second
#define pb        push_back
#define PI        acos(-1)
#define LC(a)     ((a<<1))
#define RC(a)     ((a<<1)+1)
#define MID(a,b)  ((a+b)>>1)
#define mem(a, b) memset(a, b, sizeof(a))
#define IOS()     std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
typedef long long ll;
typedef unsigned long long ULL;
typedef pair<int,int> PII;
typedef pair<ll,ll>   PLL;
typedef pair<ll,int>  PLI;
const int INF = 0X3F3F3F3F;
const int MIN = -(1<<30);
const ll N = 1e5+7;
map<int,int> mp;
int v[1005];
int a[1005];
int idx=1;
int check(int x)
{
	int prime[100];
	int k=0;
	for(int i=2; i*i<=x; i++)
	{
		if(x%i==0)
		{
			prime[k++]=i;
			while(x%i==0)
			{
				x/=i;
			}
		}
	}

	int flag=1;
	for(int i=0; i<k; i++)
		if(mp[prime[i]])
			return mp[prime[i]];

	mp[prime[0]] = idx++;
	return mp[prime[0]];
}
inline void solve()
{
	mem(v,0);
	int n;
	cin>>n;
	for(int i=1; i<=n; i++) cin>>a[i];

	for(int i=1; i<=n; i++)
	{
		v[i] = check(a[i]);
	}
	cout<<idx-1<<endl;
	for(int i=1;i<=n;i++)
	cout<<v[i]<<" ";
	cout<<endl;
}
int main()
{
	IOS();
	int T;
	cin>>T;
	while(T--) solve();
	return 0;
}


#include<bits/stdc++.h>
#define fi        first
#define se        second
#define pb        push_back
#define PI        acos(-1)
#define LC(a)     ((a<<1))
#define RC(a)     ((a<<1)+1)
#define MID(a,b)  ((a+b)>>1)
#define mem(a, b) memset(a, b, sizeof(a))
#define IOS()     std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
typedef long long ll;
typedef unsigned long long ULL;
typedef pair<int,int> PII;
typedef pair<ll,ll>   PLL;
typedef pair<ll,int>  PLI;
const int INF = 0X3F3F3F3F;
const int MIN = -(1<<30);
const ll N = 1e5+7;
map<int,int> mp;
int v[1005];
int a[1005];
int idx=1;
int check(int x)
{
	int prime[100];
	int k=0;
	for(int i=2; i*i<=x; i++)
	{
		if(x%i==0)
		{
			prime[k++]=i;
			while(x%i==0)
			{
				x/=i;
			}
		}
	}
	if(x!=1) prime[k++]=x;
	int flag=1;
	for(int i=0; i<k; i++)
		if(mp[prime[i]])
			return mp[prime[i]];

	mp[prime[0]] = idx++;
	return mp[prime[0]];
}
inline void solve()
{
	mem(v,0);
	int n;
	cin>>n;
	for(int i=1; i<=n; i++) cin>>a[i];

	for(int i=1; i<=n; i++)
	{
		v[i] = check(a[i]);
	}
	cout<<idx-1<<endl;
	for(int i=1;i<=n;i++)
	cout<<v[i]<<" ";
	cout<<endl;
}
int main()
{
	IOS();
	int T;
	cin>>T;
	while(T--) solve();
	return 0;
}


#include<bits/stdc++.h>
#define fi        first
#define se        second
#define pb        push_back
#define PI        acos(-1)
#define LC(a)     ((a<<1))
#define RC(a)     ((a<<1)+1)
#define MID(a,b)  ((a+b)>>1)
#define mem(a, b) memset(a, b, sizeof(a))
#define IOS()     std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
typedef long long ll;
typedef unsigned long long ULL;
typedef pair<int,int> PII;
typedef pair<ll,ll>   PLL;
typedef pair<ll,int>  PLI;
const int INF = 0X3F3F3F3F;
const int MIN = -(1<<30);
const ll N = 1e5+7;
map<int,int> mp;
int v[1005];
int a[1005];
int idx=1;
//int check(int x)
//{
//	int prime[100];
//	int k=0;
//	for(int i=2; i*i<=x; i++)
//	{
//		if(x%i==0)
//		{
//			prime[k++]=i;
//			while(x%i==0)
//			{
//				x/=i;
//			}
//		}
//	}
//	if(x!=1) prime[k++]=x;
//	int flag=1;
//	for(int i=0; i<k; i++)
//		if(mp[prime[i]])
//			return mp[prime[i]];
//
//	mp[prime[0]] = idx++;
//	return mp[prime[0]];
//}
int pre[]= {0,2,3,5,7,11,13,17,19,23,29,31};
int check(int x)
{
	for(int i=1; i<12; i++)
		if(x%pre[i]==0)
		{
			return i;
		}
}
inline void solve()
{
	set<int> s;
	mem(v,0);
	int n;
	cin>>n;
	for(int i=1; i<=n; i++)
	{
		cin>>a[i];
		v[i] = check(a[i]);
		s.insert(v[i]);
	}

	cout<<s.size()<<endl;
	for(int i=1; i<=n; i++)
		cout<<v[i]<<" ";
	cout<<endl;
}
int main()
{
	IOS();
	int T;
	cin>>T;
	while(T--) solve();
	return 0;
}


#include<bits/stdc++.h>
#define fi        first
#define se        second
#define pb        push_back
#define PI        acos(-1)
#define LC(a)     ((a<<1))
#define RC(a)     ((a<<1)+1)
#define MID(a,b)  ((a+b)>>1)
#define mem(a, b) memset(a, b, sizeof(a))
#define IOS()     std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
typedef long long ll;
typedef unsigned long long ULL;
typedef pair<int,int> PII;
typedef pair<ll,ll>   PLL;
typedef pair<ll,int>  PLI;
const int INF = 0X3F3F3F3F;
const int MIN = -(1<<30);
const ll N = 1e5+7;
int a[1005];
int v[1005];
inline void solve()
{
	int n;
	cin>>n;
	for(int i=1; i<=n; i++) cin>>a[i];
	mem(v,0);
	int k=1;
	v[1]=k++;
	for(int i=2; i<=n; i++)
	{
		int flag=1;
		for(int j=1; j<i; j++)
		{
			if(__gcd(a[i],a[j])>1)
			{
				v[i]=v[j];
				flag=0;
				break;
			}
		}
		if(flag) v[i]=k++;
	}
	for(int i=1; i<=n; i++)
		cout<<v[i]<<" ";
	cout<<endl;
}
int main()
{
	IOS();
	int T;
	cin>>T;
	while(T--) solve();
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
//vector<int> vect[100001];
//int dp[100001];
vector<int> cum;
long long int mod=998244353;
long long  int modularExponentiation(long long int x,long long int n,long long int M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return modularExponentiation((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*modularExponentiation((x*x)%M,(n-1)/2,M))%M;

}
long long int GCD(long long  int A,long long int B) {
    if(B==0)
        return A;
    else
        return GCD(B, A % B);
}
void primeFactors1(int n,int color[],int temp)
{
    // Print the number of 2s that divide n
    while (n % 2 == 0 && n>2)
    {   if(color[n/2]==0)
        color[n/2]=temp;
        if(color[2]==0)
        color[2]=temp;
        n = n/2;
    }

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

}
int primeFactors(int n,int *temp)
{  int kit=0;
    while (n % 2 == 0 && n>2 )
    {
        kit=max(kit,temp[2]);
        kit=max(kit,temp[n/2]);

        n = n/2;
    }
    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        // While i divides n, print i and divide n
        while (n % i == 0)
        {
            kit=max(kit,temp[i]);
            kit=max(kit,temp[n/i]);
            n = n/i;
        }
    }
    return kit;
}

int main(){
    int t;
    cin>>t;
    while(t--){
        int n;
        vector<int> vect;
        cin>>n;
        int a[n];
        for(int i=0;i<n;i++)
            cin>>a[i];
        int temp = 0;
        int color[1001]={0};
        for(int i=0;i<n;i++){
            int kit = primeFactors(a[i],color);
            if(kit==0){
                primeFactors1(a[i],color,++temp);
                vect.push_back(temp);
            }
            else{
                vect.push_back(kit);
            }

        }
        cout<<temp<<endl;
        for(auto i:vect)
            cout<<i<<" ";
        cout<<endl;

    }
}


#include<bits/stdc++.h>
using namespace std;
//vector<int> vect[100001];
//int dp[100001];
vector<int> cum;
long long int mod=998244353;
long long  int modularExponentiation(long long int x,long long int n,long long int M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return modularExponentiation((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*modularExponentiation((x*x)%M,(n-1)/2,M))%M;

}
long long int GCD(long long  int A,long long int B) {
    if(B==0)
        return A;
    else
        return GCD(B, A % B);
}
void primeFactors1(int n,int *color,int temp)
{
    // Print the number of 2s that divide n
    while (n % 2 == 0 && n!=1&&n!=2)
    {   color[n/2]=temp;
        color[2]=temp;
        n = n/2;
    }

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

}
int primeFactors(int n,int *temp)
{  int kit=0;
    while (n % 2 == 0 && n!=2 && n!=1)
    {   kit=temp[n];
        kit=max(kit,temp[2]);
        kit=max(kit,temp[n/2]);

        n = n/2;
    }
    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        // While i divides n, print i and divide n
        while (n % i == 0)
        {
            kit=max(kit,temp[i]);
            kit=max(kit,temp[n/i]);
            n = n/i;
        }
    }
    return kit;
}

int main(){
    int t;
    cin>>t;
    while(t--){
        int n;
        vector<int> vect;
        cin>>n;
        int a[n];
        for(int i=0;i<n;i++)
            cin>>a[i];
        int temp = 0;
        int color[1001]={0};
        for(int i=0;i<n;i++){
            int kit = primeFactors(a[i],color);
            if(kit==0){
                primeFactors1(a[i],color,++temp);
                vect.push_back(temp);
            }
            else{
                primeFactors1(a[i],color,kit);
                vect.push_back(kit);
            }

        }
        cout<<temp<<endl;
        for(auto i:vect)
            cout<<i<<" ";
        cout<<endl;

    }
}


#include<bits/stdc++.h>
using namespace std;
//vector<int> vect[100001];
//int dp[100001];
vector<int> cum;
long long int mod=998244353;
long long  int modularExponentiation(long long int x,long long int n,long long int M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return modularExponentiation((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*modularExponentiation((x*x)%M,(n-1)/2,M))%M;

}
long long int GCD(long long  int A,long long int B) {
    if(B==0)
        return A;
    else
        return GCD(B, A % B);
}
void primeFactors1(int n,int color[],int temp)
{
    // Print the number of 2s that divide n
    while (n % 2 == 0 && n!=1&& n!=2)
    {   if(color[n/2]==0)
        color[n/2]=temp;
        if(color[2]==0)
        color[2]=temp;
        n = n/2;
    }

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

}
int primeFactors(int n,int *temp)
{  int kit=0;
    while (n % 2 == 0 && n>2 )
    {
        kit=max(kit,temp[2]);
        kit=max(kit,temp[n/2]);

        n = n/2;
    }
    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        // While i divides n, print i and divide n
        while (n % i == 0)
        {
            kit=max(kit,temp[i]);
            kit=max(kit,temp[n/i]);
            n = n/i;
        }
    }
    return kit;
}

int main(){
    int t;
    cin>>t;
    while(t--){
        int n;
        vector<int> vect;
        cin>>n;
        int a[n];
        for(int i=0;i<n;i++)
            cin>>a[i];
        int temp = 0;
        int color[1001]={0};
        for(int i=0;i<n;i++){
            int kit = primeFactors(a[i],color);
            if(kit==0){
                primeFactors1(a[i],color,++temp);
                vect.push_back(temp);
            }
            else{
                primeFactors1(a[i],color,kit);
                vect.push_back(kit);
            }

        }
        cout<<temp<<endl;
        for(auto i:vect)
            cout<<i<<" ";
        cout<<endl;

    }
}


#include<bits/stdc++.h>
using namespace std;
//vector<int> vect[100001];
//int dp[100001];
vector<int> cum;
long long int mod=998244353;
long long  int modularExponentiation(long long int x,long long int n,long long int M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return modularExponentiation((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*modularExponentiation((x*x)%M,(n-1)/2,M))%M;

}
long long int GCD(long long  int A,long long int B) {
    if(B==0)
        return A;
    else
        return GCD(B, A % B);
}
void primeFactors1(int n,int color[],int temp)
{
    // Print the number of 2s that divide n
    while (n % 2 == 0 && n>2)
    {   if(color[n/2]==0)
            color[n/2]=temp;
        if(color[2]==0)
            color[2]=temp;
        n = n/2;
    }

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

}
int primeFactors(int n,int *temp)
{  int kit=0;
    while (n % 2 == 0 && n>2 )
    {   if(kit==0)
            kit=temp[2];
        else if( kit != temp[n/2] || kit!=temp[2] )
            return 0;
        n = n/2;
    }
    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        // While i divides n, print i and divide n
        while (n % i == 0 && n!=i)
        {   if(kit==0){
                kit=temp[i];
            }
            else if(kit!=temp[i] || kit!=temp[n/i])
                return 0;
            n = n/i;
        }
    }
    return kit;
}

int main(){
    int t;
    cin>>t;
    int tak[12]={0,2,3,5,7,11,13,17,19,23,29,31};
    while(t--){
        int n;
        vector<int> vect;
        cin>>n;
        int a[n];
        for(int i=0;i<n;i++)
            cin>>a[i];
        int ans[n]={0};
        int temp=1,count=0,maxi=0;
        for(int i=1;i<12;i++){
            if(count!=0)
                temp++;
            count=0;
            for(int j=0;j<n;j++)
            {
                if(a[j]%tak[i]==0 && ans[j]==0)
                    ans[j]=temp,count++;
                maxi=max(ans[j],maxi);
            }
        }

        cout<<maxi<<endl;
        for(auto i:ans)
            cout<<i<<" ";
        cout<<endl;

    }
}


#include<bits/stdc++.h>
using namespace std;
//vector<int> vect[100001];
//int dp[100001];
vector<int> cum;
long long int mod=998244353;
long long  int modularExponentiation(long long int x,long long int n,long long int M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return modularExponentiation((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*modularExponentiation((x*x)%M,(n-1)/2,M))%M;

}
long long int GCD(long long  int A,long long int B) {
    if(B==0)
        return A;
    else
        return GCD(B, A % B);
}
void primeFactors1(int n,int color[],int temp)
{
    // Print the number of 2s that divide n
    while (n % 2 == 0 && n>2)
    {   if(color[n/2]==0)
        color[n/2]=temp;
        if(color[2]==0)
        color[2]=temp;
        n = n/2;
    }

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

}
int primeFactors(int n,int *temp)
{  int kit=0;
    while (n % 2 == 0 && n>2 )
    {   if(kit==0)
            kit=temp[2];
        else if( kit != temp[n/2] || kit!=temp[2] )
            return 0;
        n = n/2;
    }
    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        // While i divides n, print i and divide n
        while (n % i == 0 && n!=i)
        {   if(kit==0){
                kit=temp[i];
            }
            else if(kit!=temp[i] || kit!=temp[n/i])
                return 0;
            n = n/i;
        }
    }
    return kit;
}

int main(){
    int t;
    cin>>t;
    while(t--){
        int n;
        vector<int> vect;
        cin>>n;
        int a[n];
        for(int i=0;i<n;i++)
            cin>>a[i];
        int temp = 0;
        int color[1001]={0};
        for(int i=0;i<n;i++){
            int kit = primeFactors(a[i],color);
            if(kit==0){
                primeFactors1(a[i],color,++temp);
                vect.push_back(temp);
            }
            else{
                vect.push_back(kit);
            }

        }
        cout<<temp<<endl;
        for(auto i:vect)
            cout<<i<<" ";
        cout<<endl;

    }
}


#include<bits/stdc++.h>
using namespace std;
//vector<int> vect[100001];
//int dp[100001];
vector<int> cum;
long long int mod=998244353;
long long  int modularExponentiation(long long int x,long long int n,long long int M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return modularExponentiation((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*modularExponentiation((x*x)%M,(n-1)/2,M))%M;

}
long long int GCD(long long  int A,long long int B) {
    if(B==0)
        return A;
    else
        return GCD(B, A % B);
}
void primeFactors1(int n,int *color,int temp)
{
    // Print the number of 2s that divide n
    while (n % 2 == 0 && n!=1&& n!=2)
    {   color[n/2]=temp;
        color[2]=temp;
        n = n/2;
    }

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

}
int primeFactors(int n,int *temp)
{  int kit=0;
    while (n % 2 == 0 && n>2 )
    {
        kit=max(kit,temp[2]);
        kit=max(kit,temp[n/2]);

        n = n/2;
    }
    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        // While i divides n, print i and divide n
        while (n % i == 0)
        {
            kit=max(kit,temp[i]);
            kit=max(kit,temp[n/i]);
            n = n/i;
        }
    }
    return kit;
}

int main(){
    int t;
    cin>>t;
    while(t--){
        int n;
        vector<int> vect;
        cin>>n;
        int a[n];
        for(int i=0;i<n;i++)
            cin>>a[i];
        int temp = 0;
        int color[1001]={0};
        for(int i=0;i<n;i++){
            int kit = primeFactors(a[i],color);
            if(kit==0){
                primeFactors1(a[i],color,++temp);
                vect.push_back(temp);
            }
            else{
                primeFactors1(a[i],color,kit);
                vect.push_back(kit);
            }

        }
        cout<<temp<<endl;
        for(auto i:vect)
            cout<<i<<" ";
        cout<<endl;

    }
}


#include<bits/stdc++.h>
using namespace std;
//vector<int> vect[100001];
//int dp[100001];
vector<int> cum;
long long int mod=998244353;
long long  int modularExponentiation(long long int x,long long int n,long long int M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return modularExponentiation((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*modularExponentiation((x*x)%M,(n-1)/2,M))%M;

}
long long int GCD(long long  int A,long long int B) {
    if(B==0)
        return A;
    else
        return GCD(B, A % B);
}
void primeFactors1(int n,int color[],int temp)
{
    // Print the number of 2s that divide n
    while (n % 2 == 0 && n>2)
    {   if(color[n/2]==0)
        color[n/2]=temp;
        if(color[2]==0)
        color[2]=temp;
        n = n/2;
    }

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

}
int primeFactors(int n,int *temp)
{  int kit=0;
    while (n % 2 == 0 && n>2 )
    {
        kit=max(kit,temp[2]);
        kit=max(kit,temp[n/2]);

        n = n/2;
    }
    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        // While i divides n, print i and divide n
        while (n % i == 0 && n!=i)
        {
            kit=max(kit,temp[i]);
            kit=max(kit,temp[n/i]);
            n = n/i;
        }
    }
    return kit;
}

int main(){
    int t;
    cin>>t;
    while(t--){
        int n;
        vector<int> vect;
        cin>>n;
        int a[n];
        for(int i=0;i<n;i++)
            cin>>a[i];
        int temp = 0;
        int color[1001]={0};
        for(int i=0;i<n;i++){
            int kit = primeFactors(a[i],color);
            if(kit==0){
                primeFactors1(a[i],color,++temp);
                vect.push_back(temp);
            }
            else{
                vect.push_back(kit);
            }

        }
        cout<<temp<<endl;
        for(auto i:vect)
            cout<<i<<" ";
        cout<<endl;

    }
}


#include<bits/stdc++.h>
using namespace std;
//vector<int> vect[100001];
//int dp[100001];
vector<int> cum;
long long int mod=998244353;
long long  int modularExponentiation(long long int x,long long int n,long long int M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return modularExponentiation((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*modularExponentiation((x*x)%M,(n-1)/2,M))%M;

}
long long int GCD(long long  int A,long long int B) {
    if(B==0)
        return A;
    else
        return GCD(B, A % B);
}
void primeFactors1(int n,int *color,int temp)
{
    // Print the number of 2s that divide n
    while (n % 2 == 0)
    {   color[n/2]=temp;
        color[2]=temp;
        n = n/2;
    }

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

}
int primeFactors(int n,int *temp)
{  int kit=0;
    while (n % 2 == 0)
    {   kit=temp[n];
        kit=max(kit,temp[2]);
        kit=max(kit,temp[n/2]);

        n = n/2;
    }
    for (int i = 3; i <= sqrt(n); i = i + 2)
    {
        // While i divides n, print i and divide n
        while (n % i == 0)
        {
            kit=max(kit,temp[i]);
            kit=max(kit,temp[n/i]);
            n = n/i;
        }
    }
    return kit;
}

int main(){
    int t;
    cin>>t;
    while(t--){
        int n;
        vector<int> vect;
        cin>>n;
        int a[n];
        for(int i=0;i<n;i++)
            cin>>a[i];
        int temp = 0;
        int color[1001]={0};
        for(int i=0;i<n;i++){
            int kit = primeFactors(a[i],color);
            if(kit==0)
                primeFactors1(a[i],color,temp++);
            else
                primeFactors1(a[i],color,kit);
            vect.push_back(max(kit,temp));
        }
        cout<<temp<<endl;
        for(auto i:vect)
            cout<<i<<" ";
        cout<<endl;

    }
}


/* author : akshatjai258 */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define mod int(1e9 + 7)
#define inf int(1e9)
#define endl "\n"
#define FOR(a, b, c) for (int(a) = (b); (a) <= (c); ++(a))
#define fi first
#define mem0(a) memset(a, 0, sizeof(a))
#define mem1(a) memset(a, -1, sizeof(a))
#define memf(a) memset(a, false, sizeof(a))
#define all(v) v.begin(), v.end()
#define se second
#define mp make_pair
#define pb push_back
#define w(x)  \
	int x;    \
	cin >> x; \
	while (x--)
#define ps(x, y) fixed << setprecision(y) << x
void prep()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/
}
int main()
{
	prep();
	int primes[]={2,3,5,7,11,13,17,19,23,29,31};
	w(t){
		int n;
		set<int>s;
		cin>>n;
		vi v(n);
		vi an;
		for(int &x:v)
			cin>>x;
		for(int x:v){
			int ans=-1;
			for(int i=0;i<10;i++){
				if(x%primes[i]==0){
					ans=i+1;
					s.insert(ans);
					an.pb(ans);
					break;
				}
			}
			if(ans==-1){
				ans=11;
				an.pb(ans);
				s.insert(ans);
			}
		}
		cout<<s.size()<<endl;
		for(int x:an){
			cout<<x<<" ";
		}

		cout<<endl;

	}
	return 0;
}


/* author : akshatjai258 */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
//typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define mod int(1e9 + 7)
#define inf int(1e9)
#define endl "\n"
#define FOR(a, b, c) for (int(a) = (b); (a) <= (c); ++(a))
#define fi first
#define mem0(a) memset(a, 0, sizeof(a))
#define mem1(a) memset(a, -1, sizeof(a))
#define memf(a) memset(a, false, sizeof(a))
#define all(v) v.begin(), v.end()
#define se second
#define mp make_pair
#define pb push_back
#define w(x)  \
	int x;    \
	cin >> x; \
	while (x--)
#define ps(x, y) fixed << setprecision(y) << x
void prep()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/
}
int main()
{
	prep();
	int primes[]={2,3,5,7,11,13,17,19,23,29,31};
	w(t){
		int n;
		int curr=1;
		cin>>n;
		vi v(n);
		vi an(n,-1);
		for(int &x:v)
			cin>>x;
		for(int p:primes){
			bool flag=false;
			for(int i=0;i<n;i++){
				if(an[i]!=-1)
					continue;
				if(v[i]%p)
					continue;
				flag=true;
				an[i]=curr;
			}
			if(flag)
				curr++;
		}
		cout<<curr-1<<endl;
		for(int x:an)
		{
			cout<<x<<" ";
		}
		cout<<endl;

	}
	return 0;
}


/* author : akshatjai258 */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define mod int(1e9 + 7)
#define inf int(1e9)
#define endl "\n"
#define FOR(a, b, c) for (int(a) = (b); (a) <= (c); ++(a))
#define fi first
#define mem0(a) memset(a, 0, sizeof(a))
#define mem1(a) memset(a, -1, sizeof(a))
#define memf(a) memset(a, false, sizeof(a))
#define all(v) v.begin(), v.end()
#define se second
#define mp make_pair
#define pb push_back
#define w(x)  \
	int x;    \
	cin >> x; \
	while (x--)
#define ps(x, y) fixed << setprecision(y) << x
void prep()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/
}
int main()
{
	prep();
	int primes[]={2,3,5,7,11,13,17,23,29,31};
	w(t){
		int n;
		cin>>n;
		vi v(n);
		for(int &x:v)
			cin>>x;
		for(int x:v){
			int ans=-1;
			for(int i=0;i<10;i++){
				if(x%primes[i]==0){
					ans=i+1;
					break;
				}
			}
			if(ans==-1)
				ans=11;
			cout<<ans<<' ';
		}
		cout<<endl;

	}
	return 0;
}


/* author : akshatjai258 */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define mod int(1e9 + 7)
#define inf int(1e9)
#define endl "\n"
#define FOR(a, b, c) for (int(a) = (b); (a) <= (c); ++(a))
#define fi first
#define mem0(a) memset(a, 0, sizeof(a))
#define mem1(a) memset(a, -1, sizeof(a))
#define memf(a) memset(a, false, sizeof(a))
#define all(v) v.begin(), v.end()
#define se second
#define mp make_pair
#define pb push_back
#define w(x)  \
	int x;    \
	cin >> x; \
	while (x--)
#define ps(x, y) fixed << setprecision(y) << x
void prep()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/
}
int main()
{
	prep();
	int primes[]={2,3,5,7,11,13,17,19,23,29,31};
	w(t){
		int n,cr=1;
		set<int>s;
		cin>>n;
		vi v(n);
		vi an;
		for(int &x:v)
			cin>>x;
		for(int x:v){
			int ans=-1;
			for(int i=0;i<10;i++){
				if(x%primes[i]==0){
					ans=i+1;
					if(ans>cr)
					    cr=ans;
					an.pb(ans);
					break;
				}
			}
		}
		cout<<cr<<endl;
		for(int x:an){
			cout<<x<<" ";
		}

		cout<<endl;

	}
	return 0;
}


/* author : akshatjai258 */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define mod int(1e9 + 7)
#define inf int(1e9)
#define endl "\n"
#define FOR(a, b, c) for (int(a) = (b); (a) <= (c); ++(a))
#define fi first
#define mem0(a) memset(a, 0, sizeof(a))
#define mem1(a) memset(a, -1, sizeof(a))
#define memf(a) memset(a, false, sizeof(a))
#define all(v) v.begin(), v.end()
#define se second
#define mp make_pair
#define pb push_back
#define w(x)  \
	int x;    \
	cin >> x; \
	while (x--)
#define ps(x, y) fixed << setprecision(y) << x
void prep()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/
}
int main()
{
	prep();
	int primes[]={2,3,5,7,11,13,17,23,29,31};
	w(t){
		int n;
		int curr=1;
		cin>>n;
		vi v(n);
		vi an(n,-1);
		for(int &x:v)
			cin>>x;
		for(int p:primes){
			bool flag=false;
			for(int i=0;i<n;i++){
				if(an[i]!=-1)
					continue;
				if(v[i]%p)
					continue;
				flag=true;
				an[i]=curr;
			}
			if(flag)
				curr++;
		}
		cout<<curr-1<<endl;
		for(int x:an)
		{
			cout<<x<<" ";
		}
		cout<<endl;

	}
	return 0;
}


/* author : akshatjai258 */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define mod int(1e9 + 7)
#define inf int(1e9)
#define endl "\n"
#define FOR(a, b, c) for (int(a) = (b); (a) <= (c); ++(a))
#define fi first
#define mem0(a) memset(a, 0, sizeof(a))
#define mem1(a) memset(a, -1, sizeof(a))
#define memf(a) memset(a, false, sizeof(a))
#define all(v) v.begin(), v.end()
#define se second
#define mp make_pair
#define pb push_back
#define w(x)  \
	int x;    \
	cin >> x; \
	while (x--)
#define ps(x, y) fixed << setprecision(y) << x
void prep()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/
}
int main()
{
	prep();
	int primes[]={2,3,5,7,11,13,17,23,29,31};
	w(t){
		int n;
		set<int>s;
		cin>>n;
		vi v(n);
		vi an;
		for(int &x:v)
			cin>>x;
		for(int x:v){
			int ans=-1;
			for(int i=0;i<10;i++){
				if(x%primes[i]==0){
					ans=i+1;
					s.insert(ans);
					an.pb(ans);
					break;
				}
			}
			if(ans==-1){
				ans=11;
				an.pb(ans);
				s.insert(ans);
			}
		}
		cout<<s.size()<<endl;
		for(int x:an){
			cout<<x<<" ";
		}

		cout<<endl;

	}
	return 0;
}


/* author : akshatjai258 */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define mod int(1e9 + 7)
#define inf int(1e9)
#define endl "\n"
#define FOR(a, b, c) for (int(a) = (b); (a) <= (c); ++(a))
#define fi first
#define mem0(a) memset(a, 0, sizeof(a))
#define mem1(a) memset(a, -1, sizeof(a))
#define memf(a) memset(a, false, sizeof(a))
#define all(v) v.begin(), v.end()
#define se second
#define mp make_pair
#define pb push_back
#define w(x)  \
	int x;    \
	cin >> x; \
	while (x--)
#define ps(x, y) fixed << setprecision(y) << x
void prep()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/
}
int main()
{
	prep();
	int primes[]={2,3,5,7,11,13,17,19,23,29,31};
	w(t){
		int n;
		int curr=1;
		cin>>n;
		vi v(n);
		vi an(n,-1);
		for(int &x:v)
			cin>>x;
		for(int p:primes){
			bool flag=false;
			for(int i=0;i<n;i++){
				if(an[i]!=-1)
					continue;
				if(v[i]%p)
					continue;
				flag=true;
				an[i]=curr;
			}
			if(flag)
				curr++;
		}
		cout<<curr-1<<endl;
		for(int x:an)
		{
			cout<<x<<" ";
		}
		cout<<endl;

	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
ll mod=pow(10,9)+7;

int main()
{
   vector<int> primes;
   int is_prime[1001]={0}; //0-yes 1-no
   is_prime[1]=1;
   for(int i=2;i<=1000;i++)
   {
      if(is_prime[i]==0)
      {
          primes.push_back(i);
          for(int j=i*i;j<=1000;j+=i)
          is_prime[j]=1;
      }
   }

   int t; cin>>t;
   while(t--)
   {
     int n;cin>>n;
     int a[n];
     for(int i=0;i<n;i++) cin>>a[i];

     set <int, greater <int> > pset;
     for(int i=0;i<n;i++)
     {
        for(int p=0;p<primes.size() && primes[p]<=a[i];p++)
        {
            if(a[i]%primes[p]==0) { pset.insert(primes[p]); break;}
        }
     }

     vector<int> v;
     set <int, greater <int> > :: iterator itr;
     for (itr = pset.begin(); itr != pset.end(); ++itr)
        v.push_back(*itr);

     int m=pset.size();
     int color[n];
     for(int i=0;i<n;i++)
     {
         for(int j=0;j<v.size();j++)
         {
             if(a[i]%v[j]==0) {color[i]=j+1; break;}
         }
     }
     cout<<m<<endl;
     for(int i=0;i<n;i++) cout<<color[i]<<" "; cout<<endl;

   }

}


#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
ll mod=pow(10,9)+7;

int main()
{
   vector<int> primes;
   int is_prime[1001]={0}; //0-yes 1-no
   is_prime[1]=1;
   for(int i=2;i<=1000;i++)
   {
      if(is_prime[i]==0)
      {
          primes.push_back(i);
          for(int j=i*i;j<=1000;j+=i)
          is_prime[j]=1;
      }
   }

   int t; cin>>t;
   while(t--)
   {
     int n;cin>>n;
     int a[n];
     for(int i=0;i<n;i++) cin>>a[i];

     set <int, greater <int> > pset;
     for(int i=0;i<n;i++)
     {
        for(int p=0; p<primes.size() && primes[p]<=a[i]; p++)
        {
            if(a[i]%primes[p]==0) { pset.insert(primes[p]); break;}
        }
     }

     vector<int> v;
     set <int, greater <int> > :: iterator itr;
     for (itr = pset.begin(); itr != pset.end(); ++itr)
        v.push_back(*itr);

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

     int color[n];
     for(int i=0;i<n;i++)
     {
         for(int j=0;j<v.size();j++)
         {
             if(a[i]%v[j]==0) {color[i]=j+1; break;}
         }
     }
     cout<<v.size()<<endl;
     for(int i=0;i<n;i++) cout<<color[i]<<" "; cout<<endl;

   }

}


#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
ll mod=pow(10,9)+7;

int main()
{
   int primes[11]={2,3,5,7,11,13,17,19,23,29,31};

   int t; cin>>t;
   while(t--)
   {
     int n;cin>>n;
     int a[n];
     for(int i=0;i<n;i++) cin>>a[i];

     int is_prime[11]={0};
     for(int i=0;i<n;i++)
     {
        for(int p=0; p<11; p++)
        {
            if(a[i]%primes[p]==0) { is_prime[p]=1; break;}
        }
     }

     vector<int> v;
     for(int i=0;i<11;i++)
     {
         if(is_prime[i]==1)
         v.push_back(primes[i]);
     }

     int color[n];
     for(int i=0;i<n;i++)
     {
         for(int j=0;j<v.size();j++)
         {
             if(a[i]%v[j]==0) {color[i]=j+1; break;}
         }
     }
     cout<<v.size()<<endl;
     for(int i=0;i<n;i++) cout<<color[i]<<" "; cout<<endl;

   }

}


#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
ll mod=pow(10,9)+7;

int main()
{
   vector<int> primes;
   int is_prime[1000]={0}; //0-yes 1-no
   is_prime[1]=1;
   for(int i=2;i<=1000;i++)
   {
      if(is_prime[i]==0)
      {
          primes.push_back(i);
          for(int j=i*i;j<=1000;j+=i)
          is_prime[j]=1;
      }
   }

   int t; cin>>t;
   while(t--)
   {
     int n;cin>>n;
     int a[n];
     for(int i=0;i<n;i++) cin>>a[i];

     set <int, greater <int> > pset;
     for(int i=0;i<n;i++)
     {
        for(int p=0;p<=primes.size() && primes[p]<=a[i];p++)
        {
            if(a[i]%primes[p]==0) { pset.insert(primes[p]); break;}
        }
     }

     vector<int> v;
     set <int, greater <int> > :: iterator itr;
     for (itr = pset.begin(); itr != pset.end(); ++itr)
        v.push_back(*itr);

     int m=pset.size();
     int color[n];
     for(int i=0;i<n;i++)
     {
         for(int j=0;j<v.size();j++)
         {
             if(a[i]%v[j]==0) {color[i]=j+1; break;}
         }
     }
     cout<<m<<endl;
     for(int i=0;i<n;i++) cout<<color[i]<<" "; cout<<endl;

   }
}


#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
ll mod=pow(10,9)+7;

int main()
{
   vector<int> primes;
   int is_prime[1000]={0}; //0-yes 1-no
   is_prime[1]=1;
   for(int i=2;i<=1000;i++)
   {
      if(is_prime[i]==0)
      {
          primes.push_back(i);
          for(int j=i*i;j<=1000;j+=i)
          is_prime[j]=1;
      }
   }

   int t; cin>>t;
   while(t--)
   {
     int n;cin>>n;
     int a[n];
     for(int i=0;i<n;i++) cin>>a[i];

     set <int, greater <int> > pset;
     for(int i=0;i<n;i++)
     {
        for(int p=0;p<=primes.size() && primes[p]<=a[i];p++)
        {
            if(a[i]%primes[p]==0) { pset.insert(primes[p]); break;}
        }
     }

     vector<int> v;
     set <int, greater <int> > :: iterator itr;
     for (itr = pset.begin(); itr != pset.end(); ++itr)
        v.push_back(*itr);

     int m=pset.size();
     int color[n];
     for(int i=0;i<n;i++)
     {
         for(int j=0;j<v.size();j++)
         {
             if(a[i]%v[j]==0) {color[i]=j+1; break;}
         }
     }
     cout<<m<<endl;
     for(int i=0;i<n;i++) cout<<color[i]<<" "; cout<<endl;

   }

}


#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
ll mod=pow(10,9)+7;

int main()
{
   vector<int> primes;
   int is_prime[1001]={0}; //0-yes 1-no
   is_prime[1]=1;
   for(int i=2;i<=1000;i++)
   {
      if(is_prime[i]==0)
      {
          primes.push_back(i);
          for(int j=i*i;j<=1000;j+=i)
          is_prime[j]=1;
      }
   }

   int t; cin>>t;
   while(t--)
   {
     int n;cin>>n;
     int a[n];
     for(int i=0;i<n;i++) cin>>a[i];

     set <int, greater <int> > pset;
     for(int i=0;i<n;i++)
     {
        for(int p=0; p<primes.size() && primes[p]<=a[i]; p++)
        {
            if(a[i]%primes[p]==0) { pset.insert(primes[p]); break;}
        }
     }

     vector<int> v;
     set <int, greater <int> > :: iterator itr;
     for (itr = pset.begin(); itr != pset.end(); ++itr)
        v.push_back(*itr);

     int color[n];
     for(int i=0;i<n;i++)
     {
         for(int j=0;j<v.size();j++)
         {
             if(a[i]%v[j]==0) {color[i]=j+1; break;}
         }
     }
     cout<<v.size()<<endl;
     for(int i=0;i<n;i++) cout<<color[i]<<" "; cout<<endl;

   }

}


#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
ll mod=pow(10,9)+7;

int main()
{
   vector<int> primes;
   int is_prime[1000]={0}; //0-yes 1-no
   is_prime[1]=1;
   for(int i=2;i<=1000;i++)
   {
      if(is_prime[i]==0)
      {
          primes.push_back(i); cout<<i<<" ";
          for(int j=i*i;j<=1000;j+=i)
          is_prime[j]=1;
      }
   }

   int t; cin>>t;
   while(t--)
   {
     int n;cin>>n;
     int a[n];
     for(int i=0;i<n;i++) cin>>a[i];

     set <int, greater <int> > pset;
     for(int i=0;i<n;i++)
     {
        for(int p=0;p<=primes.size() && primes[p]<=a[i];p++)
        {
            if(a[i]%primes[p]==0) { pset.insert(primes[p]); break;}
        }
     }

     vector<int> v;
     set <int, greater <int> > :: iterator itr;
     for (itr = pset.begin(); itr != pset.end(); ++itr)
        v.push_back(*itr);

     int m=pset.size();
     int color[n];
     for(int i=0;i<n;i++)
     {
         for(int j=0;j<v.size();j++)
         {
             if(a[i]%v[j]==0) {color[i]=j+1; break;}
         }
     }
     cout<<m<<endl;
     for(int i=0;i<n;i++) cout<<color[i]<<" "; cout<<endl;

   }

}


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

long long q,x,n,ans,p[12]={0,2,3,5,7,11,13,17,19,23,29,31};
bitset<12>b;
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin>>q;
	for(int rr=0;rr<q;rr++)
	{
		cin>>n;
		for(int i=1;i<=11;i++)
		{
			b[i]=false;
		}
		ans=0;
		vector<long long>v;
		for(int i=1;i<=n;i++)
		{
			cin>>x;
			for(int j=1;j<=11;j++)
			{
				if(x%p[j]==0)
				{
					if(b[j]==false)
					{
						b[j]=true;
						ans++;
					}
					v.push_back(j);
					break;
				}
			}
		}
		cout<<ans<<'\n';
		for(int i=0;i<v.size();i++)
		{
			cout<<v[i]<<" ";
		}
		cout<<'\n';
	}
	return 0;
}


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

long long q,x,n,ans,p[12]={0,2,3,5,7,11,13,17,19,23,29,31};
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin>>q;
	for(int rr=0;rr<q;rr++)
	{
		cin>>n;
		bool b[12];
		vector<long long>v;
		for(int i=1;i<=n;i++)
		{
			cin>>x;
			for(int j=1;j<=11;j++)
			{
				if(x%p[j]==0)
				{
					if(!b[j])
					{
						b[j]=true;
						ans++;
					}
					v.push_back(j);
					break;
				}
			}
		}
		cout<<ans<<'\n';
		for(int i=0;i<v.size();i++)
		{
			cout<<v[i]<<" ";
		}
		cout<<'\n';
	}
	return 0;
}


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

long long q,x,n,ans,p[12]={0,2,3,5,7,11,13,17,19,23,29,31};
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin>>q;
	for(int rr=0;rr<q;rr++)
	{
		cin>>n;
		bool b[12];
		ans=0;
		vector<long long>v;
		for(int i=1;i<=n;i++)
		{
			cin>>x;
			for(int j=1;j<=11;j++)
			{
				if(x%p[j]==0)
				{
					if(!b[j])
					{
						b[j]=true;
						ans++;
					}
					v.push_back(j);
					break;
				}
			}
		}
		cout<<ans<<'\n';
		for(int i=0;i<v.size();i++)
		{
			cout<<v[i]<<" ";
		}
		cout<<'\n';
	}
	return 0;
}


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

long long q,x,n,a[12],ans,p[12]={0,2,3,5,7,11,13,17,19,23,29,31};
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin>>q;
	for(int rr=0;rr<q;rr++)
	{
		cin>>n;
		for(int i=1;i<=11;i++)
		{
			a[i]=0;
		}
		ans=1;
		vector<long long>v;
		for(int i=1;i<=n;i++)
		{
			cin>>x;
			for(int j=1;j<=11;j++)
			{
				if(x%p[j]==0)
				{
					if(!a[j])
					{
						a[j]=ans;
						ans++;
					}
					v.push_back(a[j]);
					break;
				}
			}
		}
		cout<<ans-1<<'\n';
		for(int i=0;i<v.size();i++)
		{
			cout<<v[i]<<" ";
		}
		cout<<'\n';
	}
	return 0;
}


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

long long q,x,n,p[12]={0,2,3,5,7,11,13,17,19,23,29,31};
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin>>q;
	for(int rr=0;rr<q;rr++)
	{
		cin>>n;
		for(int i=1;i<=n;i++)
		{
			cin>>x;
			for(int j=1;j<=11;j++)
			{
				if(x%p[j]==0)
				{
					cout<<j<<" ";
					break;
				}
			}
		}
		cout<<'\n';
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b){ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}

const int N=1e3+10;
int n;
int a[N];
int prime[11]={2,3,5,7,11,13,17,19,23,29,31};
int main(){
	int t;
	scanf("%d",&t);
	while(t--)
	{
		map<int,int>m;
		scanf("%d",&n);
		int ans[N]={0};
		rep(i,1,n+1){
			scanf("%d",&a[i]);
		}
		int cnt=1;
		rep(i,1,n+1){
			rep(j,0,11){
				if(a[i]%prime[j]==0)
				{
					if(!m[j])
					{
						m[j]=cnt;
					}
					ans[i]=m[j];
					break;
				}
				else
				{
					cnt++;
				}
			}
		}
		rep(i,1,n+1){
			printf("%d",ans[i]);
			if(i!=n)printf(" ");
		}
		puts("");
	}
    return 0;
}


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

void solve()
{
    int n;cin>>n;
    int res[n]={};

    int color=0;
    map<int,int> m;

    for(int i=0;i<n;i++){
        int t;cin>>t;
        for(int j=2;j<=t;j++){
            if(t%j==0){
                if(m[j]) res[i]=m[j];//�����������֮ǰ�ѳ��֣�����Ⱦ��ͬ��ɫ����
                else res[i]=m[j]=++color;//�����������������һ������ɫ
                break;
            }
        }
    }

    cout<<color<<"\n";
    for(int i=0;i<n;i++) cout<<i<<" \n"[i==n-1];
}

int main()
{
    int t;cin>>t;
    while(t--)
        solve();
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b){ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}

const int N=1e3+10;
int n;
int a[N];
int prime[11]={2,3,5,7,11,13,17,19,23,29,31};
int main(){
	int t;
	scanf("%d",&t);
	while(t--)
	{
		map<int,int>m;
		scanf("%d",&n);
		int ans[N]={0};
		rep(i,1,n+1){
			scanf("%d",&a[i]);
		}
		int cnt=1,vis[15]={0};
		rep(i,1,n+1){
			rep(j,0,11){
				if(a[i]%prime[j]==0)
				{
					if(!m[j])
					{
						m[j]=cnt++;
					}
					ans[i]=m[j];
					break;
				}
			}
		}
		printf("%d\n",cnt-1);
		rep(i,1,n+1){
			printf("%d",ans[i]);
			if(i!=n)printf(" ");
		}
		puts("");
	}
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b){ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

const int N=1e3+10;
int n;
int a[N];
int prime[N];
int cnt=0;
bool st[N];
void get_prime(int x)
{
    for(int i=2;i<=x;i++)
    {
        if(!st[i])
        {
            prime[cnt++]=i;
        }
        for(int j=0;prime[j]<=n/i;j++)
        {
            st[prime[j]*i]=true;
            if(i%prime[j]==0)
            {
                break;
            }
        }
    }
}
int main(){
	int t;
	scanf("%d",&t);
	get_prime(N);
	while(t--)
	{
		map<int,int>m;
		scanf("%d",&n);
		rep(i,1,n+1){
			scanf("%d",&a[i]);
		}
		int k=0;
		int ans[N],c=0;
		rep(i,1,n+1){
			bool f=false;
			for(int j=2;j<=a[i]/j;j++)
			{
				if(a[i]%j==0)
				{
					while(a[i]%j==0)
					{
						a[i]/=j;
					}
					if(!f)
					{
						if(!m[j])
						{
							m[j]=++k;
							ans[i]=m[j];
						}
						else
						{
							ans[i]=m[j];
						}
						f=true;
					}
					else if(!m[j])
					{
						m[j]=k;
					}
				}
			}
			if(a[i])
			{
				if(!f)
					{
						if(!m[a[i]])
						{
							m[a[i]]=++k;
							ans[i]=m[a[i]];
						}
						else
						{
							ans[i]=m[a[i]];
						}
						f=true;
					}
					else if(!m[a[i]])
					{
						m[a[i]]=k;
					}
			}
		}
		rep(i,1,n+1){
			printf("%d",ans[i]);
			if(i!=n)printf(" ");
		}
		puts("");
	}
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b){ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}

const int N=1e3+10;
int n;
int a[N];
int prime[11]={2,3,5,7,11,13,17,19,23,29,31};
int main(){
	int t;
	scanf("%d",&t);
	while(t--)
	{
		map<int,int>m;
		scanf("%d",&n);
		int ans[N]={0};
		rep(i,1,n+1){
			scanf("%d",&a[i]);
		}
		rep(i,1,n+1){
			int cnt=1;
			rep(j,0,11){
				if(a[i]%prime[j]==0)
				{
					if(!m[prime[j]])
					{
						if(!ans[i]){
							ans[i]=cnt;
							m[prime[j]]=cnt;
						}
						else
						{
							m[prime[j]]=ans[i];
						}
					}
					else if(!ans[i])
					{
						ans[i]=m[prime[j]];
					}
				}
				else
				{
					cnt++;
				}
			}
		}
		rep(i,1,n+1){
			printf("%d",ans[i]);
			if(i!=n)printf(" ");
		}
		puts("");
	}
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b){ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}

const int N=1e3+10;
int n;
int a[N];
int prime[11]={2,3,5,7,11,13,17,19,23,29,31};
int main(){
	int t;
	scanf("%d",&t);
	while(t--)
	{
		map<int,int>m;
		scanf("%d",&n);
		int ans[N]={0};
		rep(i,1,n+1){
			scanf("%d",&a[i]);
		}
		int cnt=1,vis[15]={0};
		rep(i,1,n+1){
			cnt=1;
			rep(j,0,11){
				if(a[i]%prime[j]==0)
				{
					if(!m[j])
					{
						m[j]=cnt;
					}
					ans[i]=m[j];
					break;
				}
				else
				{
					cnt++;
				}
			}
		}
		cnt=0;
		rep(i,1,n+1){
			if(!vis[ans[i]])
			{
				cnt++;
				vis[ans[i]]=1;
			}
		}
		printf("%d\n",cnt);
		rep(i,1,n+1){
			printf("%d",ans[i]);
			if(i!=n)printf(" ");
		}
		puts("");
	}
    return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll powmod(ll a,ll b){ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}

const int N=1e3+10;
int n;
int a[N];
int prime[11]={2,3,5,7,11,13,17,19,23,29,31};
int main(){
	int t;
	scanf("%d",&t);
	while(t--)
	{
		map<int,int>m;
		scanf("%d",&n);
		int ans[N]={0};
		rep(i,1,n+1){
			scanf("%d",&a[i]);
		}
		int cnt=1,p=0;
		rep(i,1,n+1){
			cnt=1;
			rep(j,0,11){
				if(a[i]%prime[j]==0)
				{
					if(!m[j])
					{
						m[j]=cnt;
					}
					ans[i]=m[j];
					break;
				}
				else
				{
					cnt++;
				}
			}
			p=max(p,cnt);
		}
		printf("%d\n",cnt);
		rep(i,1,n+1){
			printf("%d",ans[i]);
			if(i!=n)printf(" ");
		}
		puts("");
	}
    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define MAX 500005
using namespace std;

int n;
int a[MAX], vis[MAX];

void solve(){
    scanf("%d", &n);
    int tot = 1;
    for(int i = 1; i <= n; i++){
        scanf("%d", &a[i]);
        vis[i] = 0;
        if(a[i] == 1) vis[i] = 1, tot = 2;
    }
    for(int i = 2; i <= 1000; i++){
        int flag = 0;
        for(int j = 1; j <= n; j++){
            if(vis[j]) continue;
            if(a[j]%i == 0) vis[j] = tot, flag = 1;
        }
        if(flag) tot++;
    }
    printf("%d\n", tot-1);
    for(int i = 1; i <= n; i++){
        printf("%d ", vis[i]);
    }
    puts("");
}

int main()
{
//    cout << __gcd(731, 697) << endl;
    int T;
    cin >> T;
    while(T--){
        solve();
    }

    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define MAX 500005
using namespace std;

int n;
int a[MAX], vis[MAX];

void solve(){
    scanf("%d", &n);
    int tot = 1;
    for(int i = 1; i <= n; i++){
        scanf("%d", &a[i]);
        vis[i] = 0;
        if(a[i] == 1) vis[i] = 1, tot = 2;
    }
    for(int i = 2; i <= 1000; i++){
        int flag = 0;
        for(int j = 1; j <= n; j++){
            if(vis[j]) continue;
            if(a[j]%i == 0) vis[j] = tot, flag = 1;
        }
        if(flag) tot++;
    }
    printf("%d\n", tot);
    for(int i = 1; i <= n; i++){
        printf("%d ", vis[i]);
    }
    puts("");
}

int main()
{
//    cout << __gcd(519, 395) << endl;
    int T;
    cin >> T;
    while(T--){
        solve();
    }

    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define MAX 500005
using namespace std;

int n;
int a[MAX], vis[MAX];

void solve(){
    scanf("%d", &n);
    for(int i = 1; i <= n; i++){
        scanf("%d", &a[i]);
        vis[i] = 0;
    }
//    sort(a+1, a+n+1);
    int tot = 0;
    for(int i = 1; i <= n; i++){
        if(vis[i]) continue;
        vis[i] = ++tot;
        for(int j = i+1; j <= n; j++){
            if(!vis[j] && __gcd(a[i], a[j]) > 1) vis[j] = tot;
        }
    }
    printf("%d\n", tot);
    for(int i = 1; i <= n; i++){
        printf("%d ", vis[i]);
    }
    puts("");
}

int main()
{
//    cout << __gcd(437, 391) << endl;
    int T;
    cin >> T;
    while(T--){
        solve();
    }

    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define MAX 500005
using namespace std;

int n;
int a[MAX], vis[MAX];

void solve(){
    scanf("%d", &n);
    for(int i = 1; i <= n; i++){
        scanf("%d", &a[i]);
        vis[i] = 0;
    }
    int tot = 0;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            if(vis[j] && __gcd(a[i], a[j]) > 1){
                vis[i] = vis[j];
                break;
            }
        }
        if(!vis[i]) vis[i] = ++tot;
    }
    printf("%d\n", tot);
    for(int i = 1; i <= n; i++){
        printf("%d ", vis[i]);
    }
    puts("");
}

int main()
{
//    cout << __gcd(519, 395) << endl;
    int T;
    cin >> T;
    while(T--){
        solve();
    }

    return 0;
}


#include <bits/stdc++.h>
#define ll long long
#define MAX 500005
using namespace std;

int n;
int a[MAX], vis[MAX];

void solve(){
    scanf("%d", &n);
    int tot = 1;
    for(int i = 1; i <= n; i++){
        scanf("%d", &a[i]);
        vis[i] = 0;
        if(a[i] == 1) vis[i] = 1, tot = 2;
    }
    for(int i = 2; i <= 1000; i++){
        int flag = 0;
        for(int j = 1; j <= n; j++){
            if(vis[j]) continue;
            if(a[j]%i == 0) vis[j] = tot, flag = 1;
        }
        if(flag) tot++;
    }

    printf("%d\n", tot-1);
    for(int i = 1; i <= n; i++){
        printf("%d ", vis[i]);
    }
    puts("");
}

int main()
{
//    cout << __gcd(731, 697) << endl;
    int T;
    cin >> T;
    while(T--){
        solve();
    }

    return 0;
}


#include <vector>
#include <algorithm>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <bitset>
#include <map>
#include <queue>
#include <climits>
#include <bitset>
#define LL long long
#define INFI 1000000000
#define D double
#define M 1000000007
using namespace std;

LL len = 11;
LL arr[11] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31};

int main(void){
    LL t;
    cin>>t;
    while(t--){
        LL n;
        cin>>n;
        vector<LL> a(n);
        for(LL i=0; i<n; i++){
            cin>>a[i];
        }
        vector<LL> ans(n,0);
        vector<LL> ans1(len,0);

        for(LL i=0; i<n; i++){
            for(LL j=0; j<len; j++){
                if(a[i]%arr[j] == 0){
                    ans[i] = j;
                    ans1[j] = 1;
                    break;
                }
            }
        }
        LL m=1;
        for(LL i=0; i<len; i++){
            if(ans1[i] > 0){
                ans1[i] = m;
                m++;
            }
        }
        cout<<m-1<<endl;
        for(LL i=0; i<n; i++){
            cout<<ans1[ans[i]]<<" ";
        }
        cout<<endl;

    }
    return 0;
}


#include <vector>
#include <algorithm>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <bitset>
#include <map>
#include <queue>
#include <climits>
#include <bitset>
#define LL long long
#define INFI 1000000000
#define D double
#define M 1000000007
using namespace std;

LL len = 11;
LL arr[11] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31};

int main(void){
    LL t;
    cin>>t;
    while(t--){
        LL n;
        cin>>n;
        vector<LL> a(n);
        for(LL i=0; i<n; i++){
            cin>>a[i];
        }
        vector<LL> ans(n,0);
        vector<LL> ans1(len,0);

        LL m=0;
        for(LL i=0; i<n; i++){
            for(LL j=len-1; j>=0; j--){
                if(a[i]%arr[j] == 0){
                    ans[i] = j+1;
                    ans1[j] = 1;
                    break;
                }
            }
        }
        for(LL i=0; i<len; i++){
            if(ans1[i] == 1){
                m=i;
            }
        }
        cout<<m<<endl;
        for(LL i=0; i<n; i++){
            cout<<ans[i]<<" ";
        }
        cout<<endl;

    }
    return 0;
}


#include <vector>
#include <algorithm>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <bitset>
#include <map>
#include <queue>
#include <climits>
#include <bitset>
#define LL long long
#define INFI 1000000000
#define D double
#define M 1000000007
using namespace std;

LL len = 11;
LL arr[11] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31};

int main(void){
    LL t;
    cin>>t;
    while(t--){
        LL n;
        cin>>n;
        vector<LL> a(n);
        for(LL i=0; i<n; i++){
            cin>>a[i];
        }
        vector<LL> ans(n,0);
        vector<LL> ans1(len,0);

        LL m=0;
        for(LL i=0; i<n; i++){
            for(LL j=len-1; j>=0; j--){
                if(a[i]%arr[j] == 0){
                    ans[i] = j+1;
                    ans1[j] = 1;
                    break;
                }
            }
        }
        for(LL i=0; i<len; i++){
            if(ans1[i] == 1){
                m++;
            }
        }
        cout<<m<<endl;
        for(LL i=0; i<n; i++){
            cout<<ans[i]<<" ";
        }
        cout<<endl;

    }
    return 0;
}


#include <vector>
#include <algorithm>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <bitset>
#include <map>
#include <queue>
#include <climits>
#include <bitset>
#define LL long long
#define INFI 1000000000
#define D double
#define M 1000000007
using namespace std;

LL len = 11;
LL arr[11] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31};

int main(void){
    LL t;
    cin>>t;
    while(t--){
        LL n;
        cin>>n;
        vector<LL> a(n);
        for(LL i=0; i<n; i++){
            cin>>a[i];
        }
        vector<LL> ans(n,0);
        LL m=0;
        for(LL i=0; i<n; i++){
            for(LL j=0; j<len; j++){
                if(a[i]%arr[j] == 0){
                    ans[i] = j+1;
                    m=max(m,j+1);
                    break;
                }
            }
        }
        cout<<m<<endl;
        for(LL i=0; i<n; i++){
            cout<<ans[i]<<" ";
        }
        cout<<endl;

    }
    return 0;
}


#include <vector>
#include <algorithm>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <bitset>
#include <map>
#include <queue>
#include <climits>
#include <bitset>
#define LL long long
#define INFI 1000000000
#define D double
#define M 1000000007
using namespace std;

LL len = 11;
LL arr[11] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31};

int main(void){
    LL t;
    cin>>t;
    while(t--){
        LL n;
        cin>>n;
        vector<LL> a(n);
        for(LL i=0; i<n; i++){
            cin>>a[i];
        }
        vector<LL> ans(n,0);
        vector<LL> ans1(len,0);

        LL m=0;
        for(LL i=0; i<n; i++){
            for(LL j=len-1; j>=0; j--){
                if(a[i]%arr[j] == 0){
                    ans[i] = j+1;
                    ans1[j] = 1;
                    break;
                }
            }
        }
        for(LL i=0; i<len; i++){
            if(ans1[i] == 1){
                m=i+1;
            }
        }
        cout<<m<<endl;
        for(LL i=0; i<n; i++){
            cout<<ans[i]<<" ";
        }
        cout<<endl;

    }
    return 0;
}


#include <vector>
#include <algorithm>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <bitset>
#include <map>
#include <queue>
#include <climits>
#include <bitset>
#define LL long long
#define INFI 1000000000
#define D double
#define M 1000000007
using namespace std;

LL len = 11;
LL arr[11] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31};

int main(void){
    LL t;
    cin>>t;
    while(t--){
        LL n;
        cin>>n;
        vector<LL> a(n);
        for(LL i=0; i<n; i++){
            cin>>a[i];
        }
        vector<LL> ans(n,0);
        vector<LL> ans1(len,0);

        LL m=0;
        for(LL i=0; i<n; i++){
            for(LL j=0; j<len; j++){
                if(a[i]%arr[j] == 0){
                    ans[i] = j+1;
                    ans1[j] = 1;
                    break;
                }
            }
        }
        for(LL i=0; i<len; i++){
            if(ans1[i] == 1){
                m++;
            }
        }
        cout<<m<<endl;
        for(LL i=0; i<n; i++){
            cout<<ans[i]<<" ";
        }
        cout<<endl;

    }
    return 0;
}


#include "stdio.h"
#include "string.h"
#include <iostream>
#include <queue>
#include <map>
using namespace std;
const int MAXN = 1000010;

map<char, int> nxt[MAXN];
deque<int> indices[MAXN];
int maxIndex[MAXN];
int counter[MAXN];

map<char, int> root;
string hashtags[MAXN];

void clearString(const int i, const int j, map<char, int>* curr) {
   if (j == (int)hashtags[i].length())
      return;
   int currID = (*curr)[hashtags[i][j]];
   clearString(i, j + 1, &nxt[currID]);

   if (--counter[currID] == 0)
      curr->erase(hashtags[i][j]);
   else
      indices[currID].pop_front();
}//clearString

int main() {
   int n;
   int idx, prev;
   int until;
   int id = 1, currID;
   ios::sync_with_stdio(false);
   cin >> n;
   map<char, int>* curr;
   map<char, int>::iterator it;
   string result;
   getline(cin, hashtags[0]);
   memset(counter, 0, sizeof(counter));
   for (int i = 0; i < n; i++) {
      getline(cin, hashtags[i]);
      hashtags[i] += '$'; //end of string character
      curr = &root;
      for (int j = 1; j < (int)hashtags[i].length(); j++) {
         if ((*curr)[hashtags[i][j]] == 0)
            currID = id, (*curr)[hashtags[i][j]] = id++;
         else
            currID = (*curr)[hashtags[i][j]];

         counter[currID]++;
         indices[currID].push_back(i);
         maxIndex[currID] = i;
         curr = &nxt[currID];
      }//for
   }//for
   for (int i = 0; i < n; i++) {
      curr = &root;
      result = "#";
      for (int j = 1; j < (int)hashtags[i].length(); j++) {
         it = curr->find(hashtags[i][j]);
         until = -1;

         if (it == curr->begin()) {
            it = curr->begin();
            prev = maxIndex[it->second];
            advance(it, 1);
            for (; it != curr->end(); it++) {
               currID = it->second;
               idx = indices[currID].front();
               if (idx < prev) {
                  until = j;
                  break;
               }//if
               prev = max(prev, maxIndex[currID]);
            }//for

            if (it != curr->end())
               break;

            it = curr->begin();
            currID = it->second;

            if (counter[currID] == 1 || hashtags[i][j] == '$') {
               until = (int)hashtags[i].length() - 1;
               break;
            }//if
            else
               curr = &nxt[currID];
         }//if
         else {
            until = j;
            break;
         }//else
      }//for
      for (int j = 1; j < until; j++)
         result += hashtags[i][j];
      cout << result << endl;
      clearString(i, 1, &root);
   }//for
   return 0;
}//main


#include "stdio.h"
#include "string.h"
#include <iostream>
#include <map>
using namespace std;
const int MAXN = 500010;

struct Node {
   int counter;
   map<char, Node> next;
   Node() {
      counter = 0;
   }
};

map<char, Node> root;
string hashtags[MAXN];

void clearString(const int i, const int j, map<char, Node>* curr) {
   if (j == (int)hashtags[i].length())
      return;
   clearString(i, j + 1, &(*curr)[hashtags[i][j]].next);

   if (--(*curr)[hashtags[i][j]].counter == 0)
      curr->erase(hashtags[i][j]);
}//clearString

int main() {
   int n;
   int until;
   ios::sync_with_stdio(false);
   cin >> n;
   map<char, Node>* curr;
   map<char, Node>::iterator it;
   string result;
   getline(cin, hashtags[0]);
   for (int i = 0; i < n; i++) {
      getline(cin, hashtags[i]);
      hashtags[i] += '$';
      curr = &root;
      for (int j = 1; j < (int)hashtags[i].length(); j++) {

         (*curr)[hashtags[i][j]].counter++;

         curr = &(*curr)[hashtags[i][j]].next;
      }//for
   }//for
   for (int i = 0; i < n; i++) {
      curr = &root;
      result = "#";
      for (int j = 1; j < (int)hashtags[i].length(); j++) {
         it = curr->find(hashtags[i][j]);
         if (it == curr->begin()) {
            if (it->second.counter == 1 || hashtags[i][j] == '$') {
               until = (int)hashtags[i].length() - 1;
               break;
            }//if
            else
               curr = &(*curr)[hashtags[i][j]].next;
         }//if
         else {
            until = j;
            break;
         }//else
      }//for
      for (int j = 1; j < until; j++)
         result += hashtags[i][j];
      cout << result << endl;
      clearString(i, 1, &root);
   }//for
   return 0;
}//main


#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<iostream>
using namespace std;
int n,m,mo=13331;
std::string s[500010];
std::vector<int>hash[500010];
int cmp(int s1,int s2){
	int l,r,m,a;
	l=0,r=min(s[s1].size(),s[s2].size()),a=0;
	while(l<=r){
		m=(l+r)>>1;
		if(hash[s1][m]==hash[s2][m])a=m,l=m+1;
		else r=m-1;
	}
	if(s[s1][a]<s[s2][a])return s[s1].size();
	return a;
}
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>s[i];hash[i].push_back(0);
		for(int j=0;j<s[i].size();j++)
			hash[i].push_back(hash[i][j]*mo+s[i][j]);
	}
	for(int i=n;i>1;i--)
		s[i-1].erase(cmp(i-1,i),s[i-1].size());
	for(int i=1;i<=n;i++)cout<<s[i]<<'\n';
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
string q[1000100];
int main()
{
    int n;
    cin>>n;
    for(int i=0; i<n; i++)
    {
        cin>>q[i];
    }
    for(int i=n-1; i>=1; i--)
    {

        string q1="";
        int flag=0;
        for(int j=0; j<(int )q[i].size(); j++)
        {

            if(q[i][j]<q[i-1][j]&&flag==0)
            {
                break;
            }
            if(q[i][j]>q[i-1][j])
            {
                flag=1;
            }
            q1+=q[i-1][j];
        }
        if(flag)
        {
            if(q[i].size()<q[i-1].size())
                for(int k=(int)q[i].size(); k<(int)q[i-1].size(); k++)
                {
                    q1+=q[i-1][k];
                }

        }
        q[i-1]=q1;
    }
    for(int i=0; i<n; i++)
    {
        cout<<q[i]<<'\n';
    }
}


#include <bits/stdc++.h>
using namespace std;
string q[1000100];
int main()
{
    int n;
    cin>>n;
    for(int i=0; i<n; i++)
    {
        cin>>q[i];
    }
    for(int i=n-1; i>=1; i--)
    {

        string q1="";
        int flag=0;
        for(int j=0; j<(int )q[i].size(); j++)
        {

            if(q[i][j]<q[i-1][j]&&flag==0)
            {
                break;
            }
            if(q[i][j]>q[i-1][j])
            {
                flag=1;
            }
            q1+=q[i-1][j];
        }
        if(flag)
        {
            if(q[i].size()<q[i-1].size())
                for(int k=(int)q[i].size(); k<(int)q[i-1].size(); k++)
                {
                    q1+=q[i-1][k];
                }

        }
        q[i-1]=q1;
    }
    for(int i=0; i<n; i++)
    {
        cout<<q[i]<<"\n";
    }
}


#include <bits/stdc++.h>
#define long long long
#define ull unsigned long long
#define up(i,a,b) for (int i=a; i<=b; i++)
#define down(i,a,b) for (int i=a; i>=b; i--)
#define endl '\n'
#define pb push_back
#define X first
#define Y second
#define II pair<int, int>
#define III pair<int, pair<int, int> >
#define V vector
#define debug(X) cerr<< #X << " = " <<X << endl
#define debug2(X,Y) cerr<< #X << " = " <<X << ","<<#Y<<" = "<<Y<<endl
#define show(X,a,b) {cerr << #X << " = "; up(__,a,b) cerr << X[__] << ' '; cerr << endl;}
#define gc getchar
#define pc putchar
using namespace std;

inline void read(int &x)
{
    register int c = gc();
    x = 0;
    int neg = 0;
    for (;((c<48 || c>57) && c != '-') ;c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}
inline void writeln(int x){

         char buffor[21];
         register int i=0;
         int neg=0; if (x<0) {neg=1; x= -x;}
         do{
               buffor[i++]=(x%10)+'0';
               x/=10;
            } while(x);
           i--;
           if (neg) pc('-');
           while(i>=0) pc(buffor[i--]);
           pc('\n');
       }
const int N= 1e6+10;
int dp[N];
string s[N];
int sum[N];
int t[N];
V<int> res;
int n;
void input()
{
    cin>>n;
    up(i,1,n) cin>>s[i];
    up(i,1,n) sum[i]= sum[i-1]+ (int)s[i].size();
    up(i,1,n) s[i]= " "+ s[i];

}

void solve()
{
	up(i,1,(int)s[1].size()-1) dp[i]= i;

    up(i,2,n)
     {
      int cmp= 0; int id= 0;
      up(j,1,(int)s[i].size()-1)
      {
		if (cmp==0)
		{
		  if (j> (int)s[i-1].size()-1 or s[i][j] > s[i-1][j]) cmp=1;
		  else if (s[i][j]< s[i-1][j])
		  {
		  	cmp= -1; id= j-1;
		  }

		}

        if (cmp==-1)
		{
			dp[ sum[i-1]+j]= dp[ sum[i-2]+ id]+ j;
			t[ sum[i-1]+j]= id;
		}
		else if (cmp==0)
		{
			dp[ sum[i-1]+j]= dp[sum[i-2]+ j]+ j;
			t[ sum[i-1]+j]= j;
		}
		else if (cmp==1)
		{
			dp[ sum[i-1]+j]= dp[sum[i-1]]+ j;
			t[ sum[i-1]+j]= (int)s[i-1].size()-1;
		}
      }
	  //show(t,sum[i-1]+1,sum[i]);
     }

    int best= 0; int last;
    up(i,1,(int)s[n].size()-1)
	 if (dp[sum[n-1]+i]> best )
	 {
	 	best= dp[sum[n-1]+i]; last= i;
	 }
    res.pb(last);
    down(i,n-1,1)
    {
    	last= t[ sum[i]+last ];
    	res.pb(last);
    }

    up(i,1,n)
    {
        up(j,1,res[n-i]) cout<<s[i][j];
    	cout<<endl;
    }

}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);// scanf phai bo
    #define TASK "777D"
   // freopen(TASK".inp","r",stdin);
    //freopen(TASK".out","w",stdout);

    input();
    solve();

    return 0;
}


#include <bits/stdc++.h>
#define long long long
#define ull unsigned long long
#define up(i,a,b) for (int i=a; i<=b; i++)
#define down(i,a,b) for (int i=a; i>=b; i--)
#define endl '\n'
#define pb push_back
#define X first
#define Y second
#define II pair<int, int>
#define III pair<int, pair<int, int> >
#define V vector
#define debug(X) cerr<< #X << " = " <<X << endl
#define debug2(X,Y) cerr<< #X << " = " <<X << ","<<#Y<<" = "<<Y<<endl
#define show(X,a,b) {cerr << #X << " = "; up(__,a,b) cerr << X[__] << ' '; cerr << endl;}
#define gc getchar
#define pc putchar
using namespace std;

inline void read(int &x)
{
    register int c = gc();
    x = 0;
    int neg = 0;
    for (;((c<48 || c>57) && c != '-') ;c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}
inline void writeln(int x){

         char buffor[21];
         register int i=0;
         int neg=0; if (x<0) {neg=1; x= -x;}
         do{
               buffor[i++]=(x%10)+'0';
               x/=10;
            } while(x);
           i--;
           if (neg) pc('-');
           while(i>=0) pc(buffor[i--]);
           pc('\n');
       }
const int N= 1e6+10;
int dp[N];
string s[N];
int sum[N];
int t[N];
V<int> res;
int n;
void input()
{
    cin>>n;
    up(i,1,n) cin>>s[i];
    up(i,1,n) sum[i]= sum[i-1]+ (int)s[i].size();
    up(i,1,n) s[i]= " "+ s[i];

}

void solve()
{
	up(i,1,(int)s[1].size()-1) dp[i]= i;

    up(i,2,n)
     {
      int cmp= 0; int id= 0;
      up(j,1,(int)s[i].size()-1)
      {
		if (cmp==0)
		{
		  if (j> (int)s[i-1].size()-1 or s[i][j] > s[i-1][j]) cmp=1;
		  else if (s[i][j]< s[i-1][j])
		  {
		  	cmp= -1; id= j-1;
		  }

		}

        if (cmp==-1)
		{
			dp[ sum[i-1]+j]= dp[ sum[i-2]+ id]+ j;
			t[ sum[i-1]+j]= id;
		}
		else if (cmp==0)
		{
			dp[ sum[i-1]+j]= dp[sum[i-2]+ j]+ j;
			t[ sum[i-1]+j]= j;
		}
		else if (cmp==1)
		{
			dp[ sum[i-1]+j]= dp[sum[i-1]]+ j;
			t[ sum[i-1]+j]= (int)s[i-1].size()-1;
		}
      }
	  //show(t,sum[i-1]+1,sum[i]);
     }

    int best= 0; int last;
    up(i,1,(int)s[n].size()-1)
	 if (dp[sum[n-1]+i]> best )
	 {
	 	best= dp[sum[n-1]+i]; last= i;
	 }
    res.pb(last);
    down(i,n-1,1)
    {
    	last= t[ sum[i]+last ];
    	res.pb(last);
    }

    up(i,1,n)
    {
        up(j,1,res[n-i]) cout<<s[i][j];
    	cout<<endl;
    }

}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #define TASK "777D"
    input();
    solve();

    return 0;
}


#include<cstdio>
#include<iostream>
#include<cmath>
using namespace std;

int min(int a,int b){
	if(a<b)return a;
	else return b;
}

int main(){
	int n,i,f,k,at;
	cin>>n;
	string aa[n+5],a,b;
	for(i=n;i>=1;i--){
		cin>>aa[i];
	}

	for(i=2;i<=n;i++){
		a=aa[i];b=aa[i-1];f=0;
		at=min(a.size(),b.size());
		for(k=1;k<=at;k++){
			if(a[k-1]!=b[k-1])if(a[k-1]<b[k-1]){f=1;break;}
			else break;
		}
		//cout<<k<<endl;
		if(k==at+1){
			if(a.size()>b.size())aa[i]=aa[i].substr(0,k-1);
		}
		else if(f!=1){
			aa[i]=aa[i].substr(0,k-1);
		}
	}

	for(i=n;i>=1;i--)cout<<aa[i]<<endl;
	return 0;
}


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

int main(){
	int i,j,k,n,m,t;
	cin>>n;
	vector<string> v(n+2);
	for(i=0;i<n;i++){
		cin>>v[i];
	}

	int l[n+3];
	for(i=0;i<n;i++)
		l[i] = v[i].length();

	int mx = 0;
	for(i=0;i<n;i++){
		mx = max(mx, l[i]);
	}

	int done[n+2];
	for(i=0;i<n;i++){
		done[i] = 0;
	}

	for(j=1;j<mx;j++){
		//for each character
		for(i=n-1;i>0;i--){
			//moving from bottom to up
			if(j >= l[i]){
				continue;
			}
			if(j < l[i-1] && v[i][j] < v[i-1][j] && !done[i]){
				//problem
				//delete the i-1 string from this location
				l[i-1] = j;
				done[i] = 1;
			}
			else if(j < l[i-1] && v[i][j] > v[i-1][j]){
				done[i] = 1;
			}
		}
	}

	for(i=n;i>=1;i--){
		if(done[i] == 0 && l[i] <= l[i-1]){
			done[i] = 1;
			l[i-1] = l[i];
		}
	}

	for(i=0;i<n;i++){
		for(j=0;j<l[i];j++){
			printf("%c",v[i][j]);
		}
		printf("\n");
	}

}


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

int main(){
	int i,j,k,n,m,t;
	cin>>n;
	vector<string> v(n+2);
	for(i=0;i<n;i++){
		cin>>v[i];
	}

	int l[n+3];
	for(i=0;i<n;i++)
		l[i] = v[i].length();

	int mx = 0;
	for(i=0;i<n;i++){
		mx = max(mx, l[i]);
	}

	int done[n+2];
	for(i=0;i<n;i++){
		done[i] = 0;
	}

	for(j=1;j<mx;j++){
		//for each character
		for(i=n-1;i>0;i--){
			//moving from bottom to up
			if(j >= l[i]){
				continue;
			}
			if(j < l[i-1] && v[i][j] < v[i-1][j] && !done[i]){
				//problem
				//delete the i-1 string from this location
				l[i-1] = j;
				done[i-1] = 1;
			}
			else if(j < l[i-1] && v[i][j] > v[i-1][j]){
				done[i] = 1;
			}
		}
	}

	for(i=n;i>=1;i--){
		if(done[i-1] == 0 && l[i] <= l[i-1]){
			done[i-1] = 1;
			l[i-1] = l[i];
		}
	}

	for(i=0;i<n;i++){
		for(j=0;j<l[i];j++){
			printf("%c",v[i][j]);
		}
		printf("\n");
	}

}


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

int main(){
	int i,j,k,n,m,t;
	cin>>n;
	vector<string> v(n+2);
	for(i=0;i<n;i++){
		cin>>v[i];
	}

	int l[n+3];
	for(i=0;i<n;i++)
		l[i] = v[i].length();

	for(i=n-1;i>0;i--){
		int flag = 0;
		for(j=0;j<min(l[i-1],l[i]);j++){
			if(v[i-1][j] < v[i][j]){
				flag = 1;
				break;
			}
			else if(v[i-1][j] > v[i][j]){
				v[i-1][j] = '\0';
				flag = 1;
				break;
			}
			else if(v[i-1][j] == '\0' || v[i][j] == '\0'){
				flag = 1;
				break;
			}
		}
		if(flag == 0){
			//same strings upto this point
			//check if their length is also same
			if(l[i-1] > l[i]){
				//main problem
				v[i-1][l[i]] = '\0';
			}
		}
	}

	for(i=0;i<n;i++){
		for(j=0;v[i][j] != '\0';j++){
			printf("%c",v[i][j]);
		}
		printf("\n");
	}

}


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

int main(){
	int i,j,k,n,m,t;
	cin>>n;
	vector<string> v(n+2);
	for(i=0;i<n;i++){
		cin>>v[i];
	}

	int l[n+3];
	for(i=0;i<n;i++)
		l[i] = v[i].length();

	int mx = 0;
	for(i=0;i<n;i++){
		mx = max(mx, l[i]);
	}

	int done[n+2];
	for(i=0;i<n;i++){
		done[i] = 0;
	}

	for(j=1;j<mx;j++){
		//for each character
		for(i=n-1;i>0;i--){
			//moving from bottom to up
			if(j < l[i] && j < l[i-1] && v[i][j] < v[i-1][j] && !done[i]){
				//problem
				//delete the i-1 string from this location
				l[i-1] = j;
				done[i] = 1;
				v[i-1][j] = '\0';
			}
			else if(j < l[i] && j < l[i-1] && v[i][j] > v[i-1][j]){
				done[i] = 1;
			}
			else if(j < l[i] && j < l[i-1] && v[i][j] == v[i-1][j]){
				//kuch nhi
			}
			else if(done[i] == 0 && l[i] < l[i-1]){
				done[i] = 1;
				l[i-1] = l[i];
			}
		}
	}

	for(i=n-1;i>1;i--){
		if(done[i] == 0){
			l[i] = min(l[i-1],l[i]);
		}
	}

	for(i=0;i<n;i++){
		for(j=0;j<l[i];j++){
			printf("%c",v[i][j]);
		}
		printf("\n");
	}

}


#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cassert>
#include<string>
#include<sstream>
#include<fstream>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<set>
#include<bitset>
#include<iomanip>
#include<utility>
#include<functional>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cwchar>
#include<cwctype>
#include<exception>
#include<locale>
#include<numeric>
#include<new>
#include<stdexcept>
#include<limits>
using namespace std;

#define ll long long
#define INF 1e9
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
#define pii pair<int,int>

const int maxn=500005;
string s[maxn];
int n;

int main()
{
	cin>>n;
	rep(i,n)cin>>s[i];
	for(int i=n-2;i>=0;i--)
	{
		bool f=false;
		int j=0;
		while(j<s[i+1].size()&&j<s[i].size()&&s[i+1][j]==s[i][j])j++;
		if(j==s[i].size())continue;
		if(j==s[i+1].size()){
			s[i]=s[i+1];
			continue;
		}
		if(s[i+1][j]>s[i][j])continue;
		s[i]=s[i+1].substr(0,j);
	}
	rep(i,n)cout<<s[i]<<endl;
	return 0;
}


#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cassert>
#include<string>
#include<sstream>
#include<fstream>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<set>
#include<bitset>
#include<iomanip>
#include<utility>
#include<functional>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cwchar>
#include<cwctype>
#include<exception>
#include<locale>
#include<numeric>
#include<new>
#include<stdexcept>
#include<limits>
using namespace std;

#define ll long long
#define INF 1e9
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
#define pii pair<int,int>

const int maxn=500005;
string s[maxn];
int n;

int main()
{
	scanf("%d",&n);
	rep(i,n)
	{
		char str[maxn];
		scanf("%s",&str);
		s[i]=str;
	}
	for(int i=n-2;i>=0;i--)
	{
		bool f=false;
		int j=0;
		while(j<s[i+1].size()&&j<s[i].size()&&s[i+1][j]==s[i][j])j++;
		if(j==s[i].size())continue;
		if(j==s[i+1].size()){
			s[i]=s[i+1];
			continue;
		}
		if(s[i+1][j]>s[i][j])continue;
		s[i]=s[i+1].substr(0,j);
	}
	rep(i,n)printf("%s\n",s[i].c_str());
	return 0;
}


#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cassert>
#include<string>
#include<sstream>
#include<fstream>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<set>
#include<bitset>
#include<iomanip>
#include<utility>
#include<functional>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cwchar>
#include<cwctype>
#include<exception>
#include<locale>
#include<numeric>
#include<new>
#include<stdexcept>
#include<limits>
using namespace std;

#define ll long long
#define INF 1e9
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
#define pii pair<int,int>

const int maxn=500005;
string s[maxn];
int n;

int main()
{
	cin>>n;
	rep(i,n)cin>>s[i];
	for(int i=n-2;i>=0;i--)
	{
		bool f=false;
		if(s[i]<=s[i+1])continue;
		REP(j,s[i+1].size()-1)
		if(s[i][j]>s[i+1][j])
		{
			f=true;
			s[i]=s[i+1].substr(0,j);
			break;
		}
		if(f)continue;
		s[i]=s[i+1];
	}
	rep(i,n)cout<<s[i]<<endl;
	return 0;
}


#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cassert>
#include<string>
#include<sstream>
#include<fstream>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<set>
#include<bitset>
#include<iomanip>
#include<utility>
#include<functional>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cwchar>
#include<cwctype>
#include<exception>
#include<locale>
#include<numeric>
#include<new>
#include<stdexcept>
#include<limits>
using namespace std;

#define ll long long
#define INF 1e9
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
#define pii pair<int,int>

const int maxn=500005;
string s[maxn];
int n;

int main()
{
	scanf("%d",&n);
	rep(i,n)
	{
		char str[maxn];
		scanf("%s",&str);
		s[i]=str;
	}
	for(int i=n-2;i>=0;i--)
	{
		bool f=false;
		if(s[i]<=s[i+1])continue;
		REP(j,s[i+1].size()-1)
		if(s[i][j]>s[i+1][j])
		{
			f=true;
			s[i]=s[i+1].substr(0,j);
			break;
		}
		if(f)continue;
		s[i]=s[i+1];
	}
	rep(i,n)printf("%s\n",s[i].c_str());
	return 0;
}


#include <iostream>
using namespace std;
string s[500005];
int main()
{
	int n;
	cin.sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;i++) cin>>s[i];
	for(int i=n-1;i>=1;i--){
		if(s[i] > s[i+1])
		for(int j=0;j<s[i].size();j++)
			if(s[i][j] > s[i+1][j])
				s[i].resize(j);
	}
	for(int i=1;i<=n;i++) cout<<s[i]<<endl;
	return 0;
}


#include<stdio.h>
#include<vector>
#include<iostream>
using namespace std;
vector<int >a[100005],b[100005];
int maxn[100005];
int main()
{
	int n, m, t, i, j, l, r, T;
	scanf("%d%d", &n, &m);
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			scanf("%d", &t);
			a[i].push_back(t);
			if(i == 0) b[i].push_back(1);
			else if(t>=a[i-1][j])
			b[i].push_back(b[i-1][j]+1);
			else b[i].push_back(1);
			maxn[i] = max(maxn[i], b[i][j]);
		}
	}
	scanf("%d", &T);
	while(T--){
		scanf("%d%d", &l, &r);
//		cout<<"===="<<r<<"----"<<maxn[r-1]<<endl;
		if(maxn[r-1]>=r-l+1) printf("Yes\n");
		else printf("No\n");
	}
	return 0;
 }


#include <iostream>
using namespace std;
string s[500005];
int main()
{
	int n;char t;
	cin.sync_with_stdio(false);
	cin>>n;
	//for(int i=1;i<=n;i++) cin>>s[i];
	for(int i=1;i<=n;i++){
		while(1){
			t = getchar();
			if(t == '\n') break;
			s[i] += t;
		}
	}
	for(int i=n-1;i>=1;i--){
		if(s[i] > s[i+1])
		for(int j=0;j<s[i].size();j++)
			if(s[i][j] > s[i+1][j])
				s[i].resize(j);
	}
	for(int i=1;i<=n;i++) cout<<s[i]<<endl;
	return 0;
}


#include <iostream>
#include <stdio.h>
using namespace std;
string s[500005];
int main()
{
	int n;char t;
	cin.sync_with_stdio(false);
	cin>>n;
	//for(int i=1;i<=n;i++) cin>>s[i];
	for(int i=1;i<=n;i++){
		while(1){
			t = getchar();
			if(t == '\n') break;
			s[i] += t;
		}
	}
	for(int i=n-1;i>=1;i--){
		if(s[i] > s[i+1])
		for(int j=0;j<s[i].size();j++)
			if(s[i][j] > s[i+1][j])
				s[i].resize(j);
	}
	for(int i=1;i<=n;i++) cout<<s[i]<<endl;
	return 0;
}


#include<bits/stdc++.h>

#define X first
#define Y second
#define eb push_back
#define pb pop_back
#define siz(a) int(a.size())
//for traversing the container (bcoz we cannot access linked list etc with direct index)
//c stands for container and it for iterator
#define tr(c, it) \
		for(typeof(c.begin()) it=c.begin() ; it != c.end() ; it++)

#define all(c) c.begin(), c.end()
#define present(container, element) (container.find(element) != container.end()) //whether the element is present in the container

#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
#define scan(x) scanf("%lld", &x)
#define print(x) printf("%lld", x)
#define pN printf("\n");
using namespace std;

typedef long long int ll;
typedef vector < int > vi;
typedef vector < vi > vvi;
typedef vector < ll > vll;
typedef vector < vll > vvll;

typedef pair < int , int > ii;

const int mod=1e9+7;

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

	ll n, i, j;

	//scan(n);
	cin >> n;
	string s[n];
	vector<char> ans[n];

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

	ll size = siz(s[n-1]), currsize;

	for(i=0; i<size; i++)
		ans[n-1].eb(s[n-1][i]);

	for(i=n-2; i>=0; i--){

		size = siz(ans[i+1]);

		currsize = siz(s[i]);

		bool flag=false;

		for(j=0; j<size && j<currsize; j++){
			//trace5(i, size, currsize, ans[i+1][j], s[i][j]);

			if(ans[i+1][j] > s[i][j]){
				flag=true;
				break;
			}

			if(ans[i+1][j] < s[i][j]){

				break;
			}

			ans[i].eb(s[i][j]);
		}
		if(flag){
			for(; j<currsize; j++)
				ans[i].eb(s[i][j]);
		}
	}

	for(i=0; i<n; i++){
		size = siz(ans[i]);

		for(j=0; j<size; j++)
			cout << ans[i][j];

		cout << endl;
	}

	return 0;
}


#include<bits/stdc++.h>

#define X first
#define Y second
#define eb push_back
#define pb pop_back
#define siz(a) int(a.size())
//for traversing the container (bcoz we cannot access linked list etc with direct index)
//c stands for container and it for iterator
#define tr(c, it) \
		for(typeof(c.begin()) it=c.begin() ; it != c.end() ; it++)

#define all(c) c.begin(), c.end()
#define present(container, element) (container.find(element) != container.end()) //whether the element is present in the container

#define trace2(x, y)             cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)       cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define trace5(a, b, c, d, e)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<endl;
#define scan(x) scanf("%lld", &x)
#define print(x) printf("%lld", x)
#define pN printf("\n");
using namespace std;

typedef long long int ll;
typedef vector < int > vi;
typedef vector < vi > vvi;
typedef vector < ll > vll;
typedef vector < vll > vvll;

typedef pair < int , int > ii;

const int mod=1e9+7;

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

	ll n, i, j;

	//scan(n);
	cin >> n;
	string s[n];
	string ans[n];

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

	ll size = siz(s[n-1]), currsize;
	ans[n-1]="";
	for(i=0; i<size; i++)
		ans[n-1]+=s[n-1][i];
	ans[n-1]+="\0";
	for(i=n-2; i>=0; i--){

		size = siz(ans[i+1]);

		currsize = siz(s[i]);

		bool flag=false;
		ans[i]="";
		for(j=0; j<size && j<currsize; j++){
			//trace5(i, size, currsize, ans[i+1][j], s[i][j]);

			if(ans[i+1][j] > s[i][j]){
				flag=true;
				break;
			}

			if(ans[i+1][j] < s[i][j]){

				break;
			}

			ans[i] += s[i][j];
		}
		if(flag){
			for(; j<currsize; j++)
				ans[i]+=s[i][j];
		}
		ans[i]+="\0";
	}

	for(i=0; i<n; i++){
		//size = siz(ans[i]);

		//for(j=0; j<size; j++)
		//	cout << ans[i][j];
		cout << ans[i];
		cout << endl;
	}

	return 0;
}