#include <bits/stdc++.h>

using namespace std;

const int N = 1e5 + 5;

int a[N], b[N], c[N], ans[N], n, m, maxb;
//vector<int> vt[N];
queue<int> que[N];

bool ok () {
    for (int i = 1; i <= m; ++i) {
        if (que[c[i]].size() > 0) {
            ans[i] = que[c[i]].front();
            que[c[i]].pop();
            que[c[i]].push(ans[i]);
        }
    }
    for (int i = m; i >= 1; --i) {
        if (ans[i] > 0 && ans[i - 1] == 0) {
            ans[i - 1] = ans[i];
        }
    }

    for (int i = 1; i <= m; ++i) {
        if (ans[i] > 0)
            a[ans[i]] = c[i];
        else return false;
    }
    for (int i = 1; i <= n; ++i) {
        if (a[i] != b[i]) return false;
    }
    return true;
}

void Swap (queue<int>& qq) {
    queue<int> q;
    swap(q, qq);
}

int main () {
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int _; cin >> _;
    while (_--) {
         cin >> n >> m;
        for (int i = 1; i <= n; ++i)
            cin >> a[i];
        for (int i = 1; i <= n; ++i)
            cin >> b[i];
        for (int i = 1; i <= m; ++i) {
            cin >> c[i];
            ans[i] = 0;
        }
        maxb = max(*max_element(b + 1, b + n + 1), *max_element(c + 1, c + n + 1));

        for (int i = 1; i <= n; ++i) {
            if (b[i] != a[i])
                que[b[i]].push(i);
        }
        for (int i = 1; i <= n; ++i) {
            if (b[i] == a[i])
                que[b[i]].push(i);
        }
        if (ok()) {
            cout << "YES\n";
            for (int i = 1; i <= m; ++i) cout << ans[i] << ' ';
            cout << '\n';
        } else {
            cout << "NO\n";
        }

        for (int i = 1; i <= maxb; ++i) {
            Swap(que[i]);
        }
    }
    return 0;
}
