/*
* =====================================================================================
*
* Filename: y.cpp
*
* Description:
*
* Version: 1.0
* Created: 2011¿?10¿?29¿? 12¿?59¿?36¿?
* Revision: none
* Compiler: gcc
*
* Author: YOUR NAME (),
* Company:
*
* =====================================================================================
*/
#include<iostream>
#include<ctype.h>
#include<map>
#include<string>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<memory.h>
#include<cstring>
using namespace std;
string s= "the quick brown fox jumps over the lazy dog";
int a[110];//由明文到密文
int b[110];//由密文到明文
int flag;//记录是否存在一个转换
bool isfind(string& dest)
{
for( int i=0; i<110 ; i++ )
{
a[i]=30;
b[i]=30;
}
for(int i=0; i<dest.size() ; i++ )
{
if( s[i]==' '&&dest[i]!=' ' )
{
//cout<<"e1"<<endl;
return false;
}
if( s[i]!=' '&&dest[i]==' ' )
{
//cout<<"e2"<<endl;
return false;
}
if( s[i]==' '&&dest[i]==' ' )
{
continue;
}
if( dest[i]<'a'||dest[i]>'z' )
{
//cout<<"e3"<<endl;
return false;
}
//cout<< a[s[i]-'a']<<endl;
if( a[s[i]-'a']==30&&b[dest[i]-'a']==30 )
{
//cout<<"ok"<<endl;
a[s[i]-'a']=dest[i]-'a';
b[dest[i]-'a']=s[i]-'a';
}
if( (a[s[i]-'a']==(dest[i]-'a'))&&(b[dest[i]-'a']==(s[i]-'a')) )
{
continue;
}
else
{
//cout<<"e4"<<endl;
return false;
}
}
return true;
}
int main(int argc, char *argv[])
{
int cs;
cin>>cs;
getchar();
getchar();
while( cs-- )
{
string str[110];
int i=0;
flag=0;
while( true )
{
getline(cin,str[i],'\n');
if( str[i]=="" )
{
break;
}
else
{
if( str[i].size()==s.size()&&flag!=1 )
{
bool tmp=isfind(str[i]);
if( tmp )
{
flag=1;
}
}
i++;
}
}
if( flag==0 )
{
cout<<"No solution."<<endl;
}
else
{
for( int j=0; j<i ; j++ )
{
for( int k=0; k<str[j].size() ; k++ )
{
if(isspace( str[j][k]) )
{
cout<<" ";
}
else
{
cout<<(char)(b[str[j][k]-'a']+'a');
}
}
cout<<endl;
}
}
if(cs>=1 )
{
cout<<endl;
}
}
return 0;
}
* =====================================================================================
*
* Filename: y.cpp
*
* Description:
*
* Version: 1.0
* Created: 2011¿?10¿?29¿? 12¿?59¿?36¿?
* Revision: none
* Compiler: gcc
*
* Author: YOUR NAME (),
* Company:
*
* =====================================================================================
*/
#include<iostream>
#include<ctype.h>
#include<map>
#include<string>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<memory.h>
#include<cstring>
using namespace std;
string s= "the quick brown fox jumps over the lazy dog";
int a[110];//由明文到密文
int b[110];//由密文到明文
int flag;//记录是否存在一个转换
bool isfind(string& dest)
{
for( int i=0; i<110 ; i++ )
{
a[i]=30;
b[i]=30;
}
for(int i=0; i<dest.size() ; i++ )
{
if( s[i]==' '&&dest[i]!=' ' )
{
//cout<<"e1"<<endl;
return false;
}
if( s[i]!=' '&&dest[i]==' ' )
{
//cout<<"e2"<<endl;
return false;
}
if( s[i]==' '&&dest[i]==' ' )
{
continue;
}
if( dest[i]<'a'||dest[i]>'z' )
{
//cout<<"e3"<<endl;
return false;
}
//cout<< a[s[i]-'a']<<endl;
if( a[s[i]-'a']==30&&b[dest[i]-'a']==30 )
{
//cout<<"ok"<<endl;
a[s[i]-'a']=dest[i]-'a';
b[dest[i]-'a']=s[i]-'a';
}
if( (a[s[i]-'a']==(dest[i]-'a'))&&(b[dest[i]-'a']==(s[i]-'a')) )
{
continue;
}
else
{
//cout<<"e4"<<endl;
return false;
}
}
return true;
}
int main(int argc, char *argv[])
{
int cs;
cin>>cs;
getchar();
getchar();
while( cs-- )
{
string str[110];
int i=0;
flag=0;
while( true )
{
getline(cin,str[i],'\n');
if( str[i]=="" )
{
break;
}
else
{
if( str[i].size()==s.size()&&flag!=1 )
{
bool tmp=isfind(str[i]);
if( tmp )
{
flag=1;
}
}
i++;
}
}
if( flag==0 )
{
cout<<"No solution."<<endl;
}
else
{
for( int j=0; j<i ; j++ )
{
for( int k=0; k<str[j].size() ; k++ )
{
if(isspace( str[j][k]) )
{
cout<<" ";
}
else
{
cout<<(char)(b[str[j][k]-'a']+'a');
}
}
cout<<endl;
}
}
if(cs>=1 )
{
cout<<endl;
}
}
return 0;
}