#include <bits/stdc++.h>
using namespace std;
#define REPP(i,a,b,d) for(int i=(a);i<=(int)(b);i+=(d))
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,d) for(int i=(a);i>=(int)(b);i-=(d))
#define REV(i,a,b) REVV(i,a,b,1)
#define FOR(i,a) for(int i=0; i<(int)(a); i++)
#define FORD(i,a) for(int i=(int)(a)-1; i>=0; i--)
#define pb push_back
typedef long long ll;

const int N = 1e5+5;
int n, m;
int a[N], b[N], c[N];
int ex[N];
vector<int> need[N];

void solve() {
	cin >> n >> m;
	FOR(i, n) cin >> a[i];
	REP(i, 1, n) ex[i] = -1;
	FOR(i, n) cin >> b[i], ex[b[i]] = i;
	FOR(i, m) cin >> c[i];
	REP(i, 1, n) need[i].clear();
	FOR(i, n) if(a[i] != b[i]) need[b[i]].pb(i);
	vector<int> ans;
	int idx = -1;
	FORD(i, m) {
		if(!need[c[i]].empty()) {
			idx = need[c[i]].back();
			ans.pb(idx+1);
			need[c[i]].pop_back();
		} else {
			if(idx == -1) {
				if(ex[c[i]] == -1) break;
				else idx = ex[c[i]], ans.pb(idx+1);
			} else {
				ans.pb(idx+1);
			}
		}
	}

	bool ok = 1;
	REP(i, 1, n) if(!need[i].empty()) ok = 0;

	if(ok && ans.size() == m) {
		cout << "YES" << '\n';
		FORD(i, m) cout << ans[i] << ' ';
		cout << '\n';
	} else {
		cout << "NO" << '\n';
	}
}

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	int t; cin >> t;
	while(t--) solve();
	return 0;
}