include<iostream>
include<cstring>
using namespace std;
long long t = 1;
int main()
{
long long n;
cin >> n;
while (n--)
{
long long c, s = 0; cin >> c;
char s1[1050], s2[1050], s12[2100], s112[2100], s1112[2100];
cin >> s1 >> s2>>s12;
for (int i = 0, j = 0; i < c; i++)
{
s1112[j++] = s2[i];
s1112[j++] = s1[i];
s1112[j] = '\0';
}
while (1)
{
for (int i = 0, j = 0; i < c; i++)
{
s112[j++]= s2[i];
s112[j++] = s1[i];
s112[j] = '\0';
} s++;
if (!strcmp(s112, s12))
{
cout << t << ' ' << s << endl; t++; break;
}
if (!strcmp(s112, s1112)&&s>1)
{
cout << t << ' ' << -1 << endl; t++;
break;
}
for (long long i = 0; i < c; i++)
{
s1[i] = s112[i]; s1[i+1] = '\0';
}
for (long long k = 0, i = c; i < 2 * c; i++, k++)
{
s2[k] = s112[i];
s2[k + 1] = '\0';
}
}
}
}
网友评论