#include
#include
#include<unordered_map>
#include
#include
using namespace std;
int main() {
// your code goes here
int t;
cin>>t;
while(t–)
{
int n;
cin>>n;
string a,b;
cin>>a;
cin>>b;
int not_ans=0;
int count=0;
unordered_map<int,int> m1;
for(int i=0;i<n;i++)
{
m1.insert(make_pair(a[i],i));
if(a[i]<b[i])
{
not_ans=1;
break;
}
}
unordered_map<char,int> m[26];
if(not_ans==0)
{
for(int i=25;i>=0;i–)
{
char ch=97+i;
for(int j=0;j<n;j++)
{
if(b[j]==ch && a[j]!=b[j])
{
auto ite1=m1.find(b[j]);
if(ite1==m1.end())
{
not_ans=1;
break;
}
m[i].insert(make_pair(j,1));
//cout<<ch<<" “<<m[i][b[j]]<<endl;
}
}
if(m[i].size()>0)
{
count++;
}
}
}
if(not_ans==0)
{
cout<<count<<”\n";
int temp=0;
for(int i=25;i>=0;i–)
{
char ch=i+97;
vector v;
for(int j=0;j<n;j++)
{
if(m[i].empty()==false && a[j]==ch)
{
v.push_back(j);
}
auto ite=m[i].find(j);
if(ite!=m[i].end())
{
a[j]=b[j];
v.push_back(j);
}
}
if(v.size()>0)
{
cout<<v.size()<<" “;
for(int i=0;i<v.size();i++)
{
cout<<v[i]<<” “;
}
cout<<”\n";
}
}
}
else
{
cout<<"-1\n";
}
}
return 0;
}
please provide the inputs for which it will show wrong answers.