#include <bits/stdc++.h>
using namespace std;

#define int long long

const long double PI = 3.14159265359;

void solve()
{
    int n, m;
    cin >> n >> m;
    string p, q;
    cin >> p >> q;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            if (p[i] == q[j])
            {
                p[i] = '?', q[j] = '.';
                break;
            }
        }
    }

    int s = 0, ic = 0, x = 0, total = 0;
    for (int i = 0; i < n; i++)
    {
        if (p[i] == 's')
            s++;
        if (p[i] == 'i')
            ic++;
        if (p[i] == 'x')
            x++;
        if (p[i] != '?')
            total++;
    }

    if (total == 3 && s == 1 && x == 1 && ic == 1 && count(q.begin(), q.end(), '.') == m)
        cout << "YES" << '\n';
    else
        cout << "NO" << '\n';
}

signed main(void)
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    if (fopen("input.txt", "r"))
    {
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    }
    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}