clear()
substr(0,len)
s12.compare(s)==0
map<string,int>
#include<iostream>
#include<map>
#include<cstring>
using namespace std;
const int maxn=1e6+5;
typedef long long ll;
#define rep(i,a,n) for(int i=a;i<=n;i++)
int len,T,cnt;
string s1,s2,s12,s;
map<string,int> vis;
int main()
{
cin>>T;
rep(i,1,T){
cnt=0;
cin>>len;
cin>>s1>>s2>>s12;
while(true){
s.clear();
for(int i=0;i<len;i++){
s+=s2[i];
s+=s1[i];
}
cnt++;
if(s12.compare(s)==0){
cout<<i<<" "<<cnt<<endl;
break;
}
else if(vis[s]) //构造出来的子串原来也被构造过 死循环
{
cout<<i<<" "<<-1<<endl;
break;
}
vis[s]=1;
s1.clear();s2.clear();
s1=s.substr(0,len);
s2=s.substr(len,len);
}
}
return 0;
}