#define ll long long
#define fo(i , n) for(ll i = 0 ; i < n ; i++)
#include<bits/stdc++.h>
using namespace std ;


void solve()
{
    ll n ;
    cin >> n ;
    string a , b ;
    cin >> a >> b ;

    if(a == b)
    {
        cout << "YES\n" ;
        return ;
    }

    int flag = 0 ;
    for(int i = 0 ; i < n-1 ; i++)
    {
        if(a[i] == a[i+1])
            flag |= 1 ;
        if(b[i] == b[i+1])
            flag |= 2 ;
    }

    sort(a.begin() , a.end()) ;
    sort(b.begin() , b.end()) ;

    if(a == b && flag == 3)
        cout << "YES\n" ;
    else
        cout << "NO\n" ;
    return ;
}

 
int main()
{   
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("inputf.txt" , "r" , stdin) ;
    freopen("outputf.txt" , "w" , stdout) ;
    freopen("error.txt" , "w" , stderr) ;
    #endif
    ll t = 1 ;
    cin >> t ;
    while(t--)
    {
        solve() ;
    }
    
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
 
    return 0;
}