#include <iostream>
#include <vector>
#include <string>
#include <array>
#include <functional>
#include <algorithm>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <queue>
#include <bitset>
#include <cassert>
#include <math.h>
#include <complex>
#include <iomanip>
#include <unordered_map>
using namespace std;
#define ll long long
#define pb(x) push_back(x)
#ifdef _OLIMPOLOCAL
    #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 1337
#endif
void debug_out() { cout << "\n";}
template<typename T1, typename... T2> void debug_out(T1 A, T2... B) { cout << " " << A; debug_out(B...); }
int test = 1;
#define out(x) {cout << x << "\n";return;}
#define all(N) N.begin(),N.end()
#define allr(N) N.rbegin(),N.rend()
template<typename T1> 
void print(vector<T1> V, int add = 0, int start = -1, int end = -1) {
    if (start < 0) start = 0;
    if (end < 0) end = V.size() - 1;
    for (int i = start; i <= end; i++) {
        cout << V[i] + add << ((i == end) ? "\n" : " ");
    }
}
template<typename T1> 
T1 chmin(T1 &x, const T1 v) { return x = min(x,v); }
template<typename T1> 
T1 chmax(T1 &x, const T1 v) { return x = max(x,v); }
#define rep(i, n) for (int i = 0; i < n; i++)
#define reps(i, s, n) for (int i = s; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define repsr(i, s, n) for (int i = n-1; i >= s; i--)
//-------------------------- ^ DONT TOUCH ^-----------------------------------------------------------------
#define MAX 100001
#define MOD 1000000007ll

#define PI pair<int,int>

vector<int> N[MAX];
void solve() {
    int n,  m;
    cin >> n >> m;
    vector<int>A(n), B(n), C(m), L(n, -1);
    rep(i,n) {
        cin >> A[i];
        N[i].clear();
    }
    int c = 0;
    rep(i,n) {
        cin >> B[i];
        A[i]--;B[i]--;
        if (A[i] != B[i]) {
            N[ B[i] ].push_back(i);
            c++;
        }
        if (L[B[i]]  == -1)
            L[B[i]] = i;
    }
    rep(i,m) {
        cin >> C[i];
        C[i]--;
    }
    vector<int>P(m);
    // P.back() = l;
    // N[C.back()].pop_back();
    for(int i = m-1; i >= 0; i--) {
        if (N[C[i]].size() > 0) {
            P[i] = N[C[i]].back();
            N[C[i]].pop_back();
            c--;
        } else {
            P[i] = -1;
        }
    }
    if (P.back() == -1) 
        P.back() = L[C.back()];
    if (c != 0 || P.back() == -1) {
        out("NO");
    }
    rep(i,m) if (P[i] == -1)
        P[i] = P.back();
    cout << "YES\n";
    print(P, 1);
}

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int test = 1;
    cin >> test;    
    rep(testCase, test) {
        #ifdef _OLIMPOLOCAL
            cout << "------------------ TESTCASE: " << testCase << " -------------\n";
        #endif
        solve();
    }
    return 0;
}


/*
13 13 13 13 13 2 13 13 13 13 13 13 10 23 13 13 13 13 13 13 13 13 13 22
22 22 22 22 22 2 22 22 22 22 22 22 10 23 22 22 22 22 22 22 22 22 22 22
*/