#include <iostream>
#include <bits/stdc++.h>
#define ll long long
#define inf INT_MAX
#define minf INT_MIN
using namespace std;

void solve(){
    ll n,m;
    cin>>n>>m;
    
    vector<ll> a(n);
    vector<ll> b(n);
    vector<ll> c(m);
    vector<ll> f1(n+1);
    vector<ll> f2(n+1);
    for(ll i=0;i<n;i++)
    cin>>a[i];
    for(ll i=0;i<n;i++)
    cin>>b[i];
    for(ll i=0;i<m;i++)
    cin>>c[i];
    vector<vector<ll> >adj(n+1);
    vector<ll> pos(n+1);
    for(ll i=0;i<n;i++){
        if(a[i]!=b[i]){
            f1[b[i]]++;
            adj[b[i]].push_back(i+1);
        }
        pos[b[i]]=i+1;
        
    }
    for(ll i=0;i<m;i++){
        f2[c[i]]++;
    }

    for(ll i=1;i<=n;i++){
        if(f2[i]<f1[i]){
            cout<<"NO"<<endl;
            return;
        }
    }
    bool x=0;
    for(ll i=0;i<n;i++){
        if(c[m-1]==b[i]){
            x=1;
            break;
        }
    }
    if(!x){
        cout<<"NO"<<endl;
        return;
    }
    vector<ll> ans(m);
    if(adj[c[m-1]].size()==0){
        ans[m-1]=pos[c[m-1]];
    }
    else
    {
        ans[m-1]=adj[c[m-1]].back();
        adj[c[m-1]].pop_back();
    }
    for(ll i=0;i<m-1;i++){
        if(adj[c[i]].size()==0){
            ans[i]=ans[m-1];
        }
        else
        {
            ans[i]=adj[c[i]].back();
            adj[c[i]].pop_back();
        }
    }
    cout<<"YES"<<endl;
    for(ll i=0;i<m;i++)
    cout<<ans[i]<<" ";
    cout<<endl;    
    
    
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t;
    cin>>t;
    while(t--) solve();
} 