#include "bits/stdc++.h"
using namespace std;

#define dbg(x)      cout << #x << " is " << x << endl;
#define all(x)      x.begin(), x.end()
#define pb          push_back
#define sz(x)       (int)(x.size())
#define ll          long long
#define fi          first
#define se          second

const int MOD = 1e9 + 7;
const double eps = 1e-10;
const long long INF = 1e18;
const int N = 2e5 + 10;


void solve() {
	int n, m;
	cin >> n >> m;
	int a[n], b[n], c[m];
	vector<priority_queue<int>> v(n + 1);
	vector<int> pos(n + 1);
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) {
		cin >> b[i];
		if (b[i] != a[i]) v[b[i]].push(i + 1);
		pos[b[i]] = i + 1;
	}
	for (int i = 0; i < m; i++) cin >> c[i];

	vector<int> ans;
	for (int i = 0; i < m; i++) {
		if (v[c[i]].empty()) {
			if (!pos[c[i]] && i == m - 1) {
				cout << "NO\n";
				return;
			}
			else if (!pos[c[i]]) {
				if (v[c[m - 1]].empty())
					ans.pb(pos[c[m - 1]]);
				else ans.pb(v[c[m - 1]].top());
			}
			else ans.pb(pos[c[i]]);
		}
		else {
			ans.pb(v[c[i]].top());
			v[c[i]].pop();
		}
	}

	for (int i = 1; i <= n; i++) {
		if (!v[i].empty()) {
			cout << "NO\n";
			return;
		}
	}
	cout << "YES\n";
	for (auto it : ans) cout << it << ' ';
	cout << '\n';
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	int tt = 1;
	cin >> tt;
	while (tt--) {
		solve();
	}
	return 0;
}