/*
4 1234 3421
4 1234 2314
5 12345 32541
6 123456 134562
6 123456 256431
*/
#include
#include
int main ()
{
intn,i,f[100000];
chara[2][100000];
while(scanf("%d",&n)==1)
{
getchar ();
for (i=0;i