#include using namespace std; typedef signed long long ll; #undef _P #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x<(to);x++) #define FORR(x,arr) for(auto& x:arr) #define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++) #define ALL(a) (a.begin()),(a.end()) #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,0xff,sizeof(a)) //------------------------------------------------------- int N; string S[101010]; int R[101010][4]; int tim[2][65536]; void solve() { int i,j,k,l,r,x,y; string s; cin>>N; if(N>52) return _P("Impossible\n"); FOR(i,N) { cin>>S[i]; R[i][0]=S[i][0]; R[i][1]=S[i][1]*(int)256+S[i][2]; R[i][2]=S[i][2]; R[i][3]=S[i][0]*(int)256+S[i][1]; } double start=clock(); srand(clock()); x=1; while(clock()-start<1.9*CLOCKS_PER_SEC) { int A[52]={}; x++; FOR(i,N) { A[i]=rand()%2; if(A[i]==0) { if(tim[0][R[i][0]]==x) goto out; if(tim[1][R[i][1]]==x) goto out; tim[0][R[i][0]]=x; tim[1][R[i][1]]=x; } else { if(tim[0][R[i][2]]==x) goto out; if(tim[1][R[i][3]]==x) goto out; tim[0][R[i][2]]=x; tim[1][R[i][3]]=x; } } FOR(i,N) { if(A[i]==0) cout<