#include <iostream>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <queue>
#include <iomanip>
#include <numeric>
#include <cmath>
using namespace std;

int main() {
	int t;
	cin >> t;
	for (int tt = 0; tt < t; tt++) {
		int n, m;
		cin >> n >> m;
		vector<int> va(n, 0), vb(n, 0);
		unordered_map<int, vector<int>> tofix;
		unordered_map<int, int> fixed;
		for (int i = 0; i < n; i++) {
			cin >> va[i];
		}
		for (int i = 0; i < n; i++) {
			cin >> vb[i];
			if (va[i] == vb[i]) {
				fixed[va[i]] = i;
			} else {
				tofix[vb[i]].push_back(i);
			}
		}
		vector<int> res(m, 0);
		vector<pair<int, int>> redundant;
		for (int i = 0; i < m; i++) {
			int x;
			cin >> x;
			if (tofix.count(x) > 0 and tofix[x].size() > 0) {
				res[i] = tofix[x].back();
				fixed[x] = tofix[x].back();
				tofix[x].pop_back();
				if (tofix[x].size() == 0) {
					tofix.erase(x);
				}

				if (redundant.size() > 0) {
					for (auto p : redundant) {
						res[p.first] = fixed[x];
					}
					redundant.clear();
				}
			} else {
				if (fixed.count(x) > 0) {
					if (redundant.size() > 0) {
						for (auto p : redundant) {
							res[p.first] = fixed[x];
						}
						redundant.clear();
						res[i] = fixed[x];
					} else {
						res[i] = fixed[x];
					}
				} else {
					redundant.emplace_back(i, x);
				}
			}
		}
		if (redundant.empty() and tofix.size() == 0) {
			cout << "YES" << endl;
			for (auto r : res) {
				cout << r + 1 << " ";
			}
			cout << endl;
		} else {
			cout << "NO" << endl;
		}
	}
}



