#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int , int> II;
const int N = 1e5 + 3;
const ll MOD = 1e5;
const ll INF = 1e12;
int n , m , a[N] , b[N] , c[N] , ans[N] , ok[N] , t;
vector<int> g[N];
void process(){
    cin >> n >> m;
    for(int i = 1 ; i <= n ; i ++) g[i].clear() , ok[i] = 0;
    for(int i = 1 ; i <= m ; i ++) ans[i] = 0;
    for(int i = 1 ; i <= n ; i ++) cin >> a[i];
    for(int i = 1 ; i <= n ; i ++){
      cin >> b[i];
      if(a[i] != b[i]) g[b[i]].push_back(i);
      if(!ok[b[i]]) ok[b[i]] = i;
    }
    queue<int> qu;
    for(int i = 1 ; i <= m ; i ++){
      cin >> c[i];
      if(!g[c[i]].empty()){
         ans[i] = g[c[i]].back();
         while(!qu.empty()){
         ans[qu.front()] = g[c[i]].back();
         qu.pop();
         }
         g[c[i]].pop_back();
      }
      else if(ok[c[i]]){
         ans[i] = ok[c[i]];
         while(!qu.empty()){
            ans[qu.front()] = ok[c[i]];
            qu.pop();
         }
      }
      else qu.push(i);
    }
    for(int i = 1 ; i <= m ; i ++){
      if(!ans[i]){
         cout << "NO" << "\n";
         return;
      }
    }
    for(int i = 1 ; i <= n ; i ++){
      if(!g[i].empty()){
         cout << "NO" << "\n";
         return;
      }
    }
    cout << "YES" << "\n";
    for(int i = 1 ; i <= m ; i ++) cout << ans[i] << " ";
    cout << "\n";
}
int main(){
   ios_base::sync_with_stdio(false);
   cin.tie();
   cin >> t;
   while(t --) process();
   return 0;
}
