#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;


int main(){
    int t;
    cin >> t;
    while (t--){
        int n, m;
        cin >> n >> m;
        vector<int> a(n), b(n), init(n+1, -1), stack, ans(m);
        vector<vector<int> > need_to_redo(n+1);
        for (int i = 0; i < n; ++i)
            cin >> a[i];
        for (int i = 0; i < n; ++i){
            cin >> b[i];
            if (a[i] != b[i]) need_to_redo[b[i]].push_back(i);
            init[b[i]] = i;
        }
        for (int i = 0; i < m; ++i){
            int x;
            cin >> x;
            if (init[x] == -1) stack.push_back(i);
            else{
                int pos;
                if (need_to_redo[x].empty()) pos = init[x]+1;
                else{
                    pos = need_to_redo[x].back()+1;
                    need_to_redo[x].pop_back();
                }
                while (!stack.empty()){
                    ans[stack.back()] = pos;
                    stack.pop_back();
                }
                ans[i] = pos;
            }
        }
        bool spoiled = false;
        if (!stack.empty()) spoiled = true;
        for (int i = 0; i <= n; ++i){
            if (!need_to_redo[i].empty()) spoiled = true;
        }
        if (spoiled){
            cout << "NO\n";
        }else{
            cout << "YES\n";
            for (int i:ans){
                cout << i << ' ';
            }
            cout << '\n';
        }
    }
    return 0;
}
