#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
const lli mod=1e9+7;
const lli mod1=998244353;
#define fi first
#define se second
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree<lli, null_type,less<lli>, rb_tree_tag,tree_order_statistics_node_update>
/*
lli power(lli a, lli b) {
lli res = 1;
while (b > 0) {
if (b & 1)
res = res * a;
a = a * a;
b >>= 1;
}
return res;
}
lli powermod(lli a, lli b)
{
lli res = 1;
while (b > 0) {
if (b & 1)
res = ((res%mod)*(a%mod))%mod;
a = (a * a)%mod;
b >>= 1;
}
return res;
}*/
const lli N=100001;
bool vis[N]={false};
lli cnt[N]={0},cnt1[N]={0};
vector<lli> v[N];
lli po[N]={0};
int main()
{
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
lli T;T=1;
cin>>T;
while(T--)
{
lli n,m,i,j;
cin>>n>>m;
lli a[n],b[n],c[m];
for(i=0;i<n;i++)
{
cin>>a[i];
}
for(i=0;i<n;i++)
{
cin>>b[i];
vis[b[i]]=true;
}
for(i=0;i<m;i++)
{
cin>>c[i];
cnt[c[i]]--;
}
if(vis[c[m-1]]==false)
{
cout<<"NO\n";
for(i=0;i<n;i++)
vis[b[i]]=false;
for(i=0;i<=n;i++)
cnt[i]=cnt1[i]=po[i]=0;
for(i=0;i<n;i++)
{
v[b[i]].clear();
}
continue;
}
for(i=0;i<n;i++)
{
if(a[i]!=b[i])
{
cnt[b[i]]++;
v[b[i]].pb(i+1);
}
}
lli flag=0;
for(i=1;i<=n;i++)
{
if(cnt[i]>0)
flag=1;
}
if(flag)
{
cout<<"NO\n";
for(i=0;i<n;i++)
vis[b[i]]=false;
for(i=0;i<=n;i++)
cnt[i]=cnt1[i]=po[i]=0;
for(i=0;i<n;i++)
{
v[b[i]].clear();
}
continue;
}
lli ans=-1;
cout<<"YES\n";
for(i=0;i<n;i++)
{
if(b[i]==c[m-1])
{ans=i+1;break;}
}
for(i=0;i<m-1;i++)
{
if(v[c[i]].empty())
{
cout<<ans<<" ";
}
else
{
cout<<v[c[i]].back()<<" ";
v[c[i]].pop_back();
}
}
cout<<ans<<"\n";
for(i=0;i<n;i++)
vis[b[i]]=false;
for(i=0;i<=n;i++)
cnt[i]=cnt1[i]=po[i]=0;
for(i=0;i<n;i++)
{
v[b[i]].clear();
}
}
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKI2RlZmluZSBsbGkgbG9uZyBsb25nIGludAojZGVmaW5lIHBiIHB1c2hfYmFjawpjb25zdCBsbGkgbW9kPTFlOSs3Owpjb25zdCBsbGkgbW9kMT05OTgyNDQzNTM7CiNkZWZpbmUgZmkgZmlyc3QKI2RlZmluZSBzZSBzZWNvbmQKLy8gICNpbmNsdWRlIDxib29zdC9tdWx0aXByZWNpc2lvbi9jcHBfaW50LmhwcD4gCi8vICB1c2luZyBuYW1lc3BhY2UgYm9vc3Q6Om11bHRpcHJlY2lzaW9uOyAKLy8gICNpbmNsdWRlIDxleHQvcGJfZHMvYXNzb2NfY29udGFpbmVyLmhwcD4gCi8vICAjaW5jbHVkZSA8ZXh0L3BiX2RzL3RyZWVfcG9saWN5LmhwcD4gCi8vICB1c2luZyBuYW1lc3BhY2UgX19nbnVfcGJkczsgCi8vICAjZGVmaW5lIG9yZGVyZWRfc2V0IHRyZWU8bGxpLCBudWxsX3R5cGUsbGVzczxsbGk+LCByYl90cmVlX3RhZyx0cmVlX29yZGVyX3N0YXRpc3RpY3Nfbm9kZV91cGRhdGU+IAovKgpsbGkgcG93ZXIobGxpIGEsIGxsaSBiKSB7CiAgICBsbGkgcmVzID0gMTsKICAgIHdoaWxlIChiID4gMCkgewogICAgICAgIGlmIChiICYgMSkKICAgICAgICAgICAgcmVzID0gcmVzICogYTsKICAgICAgICBhID0gYSAqIGE7CiAgICAgICAgYiA+Pj0gMTsKICAgIH0KICAgIHJldHVybiByZXM7Cn0KbGxpIHBvd2VybW9kKGxsaSBhLCBsbGkgYikgCnsKICAgIGxsaSByZXMgPSAxOwogICAgd2hpbGUgKGIgPiAwKSB7CiAgICAgICAgaWYgKGIgJiAxKQogICAgICAgICAgICByZXMgPSAoKHJlcyVtb2QpKihhJW1vZCkpJW1vZDsKICAgICAgICBhID0gKGEgKiBhKSVtb2Q7CiAgICAgICAgYiA+Pj0gMTsKICAgIH0KICAgIHJldHVybiByZXM7Cn0qLwpjb25zdCBsbGkgTj0xMDAwMDE7CmJvb2wgdmlzW05dPXtmYWxzZX07CmxsaSBjbnRbTl09ezB9LGNudDFbTl09ezB9Owp2ZWN0b3I8bGxpPiB2W05dOwpsbGkgcG9bTl09ezB9OwppbnQgbWFpbigpCnsKICAgIC8vaW9zX2Jhc2U6OnN5bmNfd2l0aF9zdGRpbyhmYWxzZSk7CiAgICAvL2Npbi50aWUoTlVMTCk7CiAgICBsbGkgVDtUPTE7CiAgICBjaW4+PlQ7CiAgICB3aGlsZShULS0pCiAgICB7CiAgICAgICAgbGxpIG4sbSxpLGo7CiAgICAgICAgY2luPj5uPj5tOwogICAgICAgIGxsaSBhW25dLGJbbl0sY1ttXTsKICAgICAgICBmb3IoaT0wO2k8bjtpKyspCiAgICAgICAgewogICAgICAgICAgICBjaW4+PmFbaV07CiAgICAgICAgfQogICAgICAgIGZvcihpPTA7aTxuO2krKykKICAgICAgICB7CiAgICAgICAgICAgIGNpbj4+YltpXTsKICAgICAgICAgICAgdmlzW2JbaV1dPXRydWU7CiAgICAgICAgfQogICAgICAgIGZvcihpPTA7aTxtO2krKykKICAgICAgICB7CiAgICAgICAgICAgIGNpbj4+Y1tpXTsKICAgICAgICAgICAgY250W2NbaV1dLS07CiAgICAgICAgfQogICAgICAgIGlmKHZpc1tjW20tMV1dPT1mYWxzZSkKICAgICAgICB7CiAgICAgICAgICAgIGNvdXQ8PCJOT1xuIjsKICAgICAgICAgICAgZm9yKGk9MDtpPG47aSsrKQogICAgICAgICAgICAgICAgdmlzW2JbaV1dPWZhbHNlOwogICAgICAgICAgICBmb3IoaT0wO2k8PW47aSsrKQogICAgICAgICAgICAgICAgY250W2ldPWNudDFbaV09cG9baV09MDsKICAgICAgICAgICAgZm9yKGk9MDtpPG47aSsrKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICB2W2JbaV1dLmNsZWFyKCk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgfQogICAgICAgIGZvcihpPTA7aTxuO2krKykKICAgICAgICB7CiAgICAgICAgICAgIGlmKGFbaV0hPWJbaV0pCiAgICAgICAgICAgIHsgICAKICAgICAgICAgICAgICAgIGNudFtiW2ldXSsrOwogICAgICAgICAgICAgICAgdltiW2ldXS5wYihpKzEpOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGxsaSBmbGFnPTA7CiAgICAgICAgZm9yKGk9MTtpPD1uO2krKykKICAgICAgICB7CiAgICAgICAgICAgIGlmKGNudFtpXT4wKQogICAgICAgICAgICAgICAgZmxhZz0xOwogICAgICAgIH0KICAgICAgICBpZihmbGFnKQogICAgICAgIHsKICAgICAgICAgICAgY291dDw8Ik5PXG4iOwogICAgICAgICAgICBmb3IoaT0wO2k8bjtpKyspCiAgICAgICAgICAgICAgICB2aXNbYltpXV09ZmFsc2U7CiAgICAgICAgICAgIGZvcihpPTA7aTw9bjtpKyspCiAgICAgICAgICAgICAgICBjbnRbaV09Y250MVtpXT1wb1tpXT0wOwogICAgICAgICAgICBmb3IoaT0wO2k8bjtpKyspCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIHZbYltpXV0uY2xlYXIoKTsKICAgICAgICAgICAgfQogICAgICAgICAgICBjb250aW51ZTsKICAgICAgICB9CiAgICAgICAgbGxpIGFucz0tMTsKICAgICAgICBjb3V0PDwiWUVTXG4iOwogICAgICAgIGZvcihpPTA7aTxuO2krKykKICAgICAgICB7CiAgICAgICAgICAgIGlmKGJbaV09PWNbbS0xXSkKICAgICAgICAgICAgICAgIHthbnM9aSsxO2JyZWFrO30KICAgICAgICB9CiAgICAgICAgZm9yKGk9MDtpPG0tMTtpKyspCiAgICAgICAgewogICAgICAgICAgICBpZih2W2NbaV1dLmVtcHR5KCkpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGNvdXQ8PGFuczw8IiAiOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGVsc2UKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgY291dDw8dltjW2ldXS5iYWNrKCk8PCIgIjsKICAgICAgICAgICAgICAgIHZbY1tpXV0ucG9wX2JhY2soKTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBjb3V0PDxhbnM8PCJcbiI7CiAgICAgICAgZm9yKGk9MDtpPG47aSsrKQogICAgICAgICAgICB2aXNbYltpXV09ZmFsc2U7CiAgICAgICAgZm9yKGk9MDtpPD1uO2krKykKICAgICAgICAgICAgY250W2ldPWNudDFbaV09cG9baV09MDsKICAgICAgICBmb3IoaT0wO2k8bjtpKyspCiAgICAgICAgewogICAgICAgICAgICB2W2JbaV1dLmNsZWFyKCk7CiAgICAgICAgfQogICAgfQogICAgcmV0dXJuIDA7Cn0KCgoKCgoKCgoKCsKg