#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007


void solve(){
    //C. Fence Painting
    int n,m; cin>>n>>m;
    vector<int> a(n),b(n),c(m),ans(m,0);
    for(int i=0; i<n; i++) cin>>a[i]; for(int i=0; i<n; i++) cin>>b[i]; for(int i=0; i<m; i++) cin>>c[i];
    //last painter c[m-1];
    auto it = find (b.begin(), b.end(), c[m-1]);
    if(it == b.end()){
        cout<<"NO\n";
        return ;
    }
    else{
        ans[m-1] = it - b.begin();
        ans[m-1]++;
    }
    //other painters
    for(int i=0; i<n; i++){
        if(b[i] != a[i]){
            auto itr = find(c.begin(),c.end(),b[i]);
            if(itr == c.end()){
                cout<<"NO\n"; return ;
            }
            else{
                int idx = itr - c.begin();
                ans[idx] = i+1;
                b[i] = a[i];
                c[idx] = 0;
            }
        }
    }
    cout<<"YES\n";
    for(int i=0; i<m; i++){
        if(ans[i] != 0) cout<<ans[i]<<" ";
        else
            cout<<ans[m-1]<<" ";
    }
    cout<<"\n";
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    cin>>t;
    while(t--){
        solve();
    }
    return 0;
}
