/*
	Coded with Leachim's ACM Template.
	No errors. No warnings. ~~
*/
#include <bits/stdc++.h>
#pragma GCC diagnostic ignored "-Wunused-const-variable"
#pragma GCC diagnostic ignored "-Wsign-conversion"
#pragma GCC diagnostic ignored "-Wsign-compare"
#define LL long long
using namespace std;
const int inf=0x3f3f3f3f;
const LL INF=0x3f3f3f3f3f3f3f3f;
const double eps=1e-7;
const int dx[4]={1,-1,0,0};
const int dy[4]={0,0,1,-1};
const int RT=3;
const int MOD=998244353;
const int MAXN=2000005;

int a[MAXN],b[MAXN],c[MAXN];
vector<int> s[MAXN],d[MAXN];
int ans[MAXN];

void solve() {
	int n,m;
	scanf("%d %d", &n, &m);
	for(int i=1;i<=n;i++) s[i].clear(),d[i].clear();
	for(int i=1;i<=n;i++) scanf("%d", &a[i]);
	for(int i=1;i<=n;i++) scanf("%d", &b[i]);

	for(int i=1;i<=n;i++) {
		if(a[i]==b[i]) {
			s[a[i]].push_back(i);
		} else d[b[i]].push_back(i);
	}
	vector<int> wt;
	for(int i=1;i<=m;i++) {
		scanf("%d", &c[i]);
		if(d[c[i]].size()) {
			ans[i]=d[c[i]].back();
			s[c[i]].push_back(ans[i]);
			d[c[i]].pop_back();
			while(wt.size()) {
				ans[wt.back()]=ans[i];
				wt.pop_back();
			}
		} else if(s[c[i]].size()) {
			ans[i]=s[c[i]].back();
			while(wt.size()) {
				ans[wt.back()]=ans[i];
				wt.pop_back();
			}
		} else {
			wt.push_back(i);
		}
	}
	if(wt.size()) {
		printf("NO\n");
		return;
	}
	for(int i=1;i<=n;i++)
		if(d[i].size()) {
			printf("NO\n");
			return;
		}
	printf("YES\n");
	for(int i=1;i<=m;i++)
		printf("%d%c", ans[i], " \n"[i==m]);
}

int main() {
	int T=1,cas=1;(void)(cas);
	scanf("%d", &T);
	while(T--) {
		// printf("Case #%d: ", cas++);
		solve();
	}
	return 0;
}