#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
#define int ll

void scan(int n, vector<int> &vec) {
    int val;
    for (int i = 0; i < n; ++i) {
        cin >> val;
        vec.push_back(val);
    }
}

int32_t main() {
    ios_base::sync_with_stdio(0); // remove in interactive problems
    cin.tie(0);

    int t;
    cin >> t;
    while (t--) {
        int n, m;
        bool ok = true;
        cin >> n >> m;
        vector<vector<int>> col(n + 5);
        vector<int> a, b, c, exists(n + 5), wntd(n + 5), ind(n + 5, -1);
        scan(n, a);
        scan(n, b);
        scan(m, c);
        for (int i = 0; i < n; ++i) {
            if (ind[b[i]] == -1 && a[i] != b[i])
                ind[b[i]] = i;
            if (a[i] != b[i]) {
                ++wntd[b[i]];
                col[b[i]].push_back(i);
            }
        }
        for (int i = 0; i < n; ++i)
            if (ind[b[i]] == -1)
                ind[b[i]] = i;
        for (int i = 0; i < m; ++i)
            ++exists[c[i]];
        for (int i = 1; i <= n; ++i)
            if (wntd[i] > exists[i])
                ok = false;
        if (ind[c[m - 1]] == -1)
            ok = false;
        cout << (ok ? "YES" : "NO") << '\n';
        if (ok) {
            int lstInd = ind[c[m - 1]];
            for (int i = 0; i < m - 1; ++i)
                if (ind[c[i]] == -1 || col[c[i]].empty())
                    cout << lstInd + 1 << " ";
                else {
                    cout << col[c[i]].back() + 1 << " ";
                    col[c[i]].pop_back();
                }
            cout << lstInd + 1 << '\n';
        }
    }
}