Number Sequence
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long LL;
LL n,m;
LL a[1000010],sumb;
LL p[1000010];
int main(){
int tx;
cin>>tx;
while(tx--){
cin>>n>>m;
int t;
memset(a,0,sizeof a);
sumb=0;
p[0]=1;
for(int i=0;i<n;i++){
scanf("%d",&t);
t+=1000001;
a[i+1]=a[i]*131+t;
p[i+1]=p[i]*131;
}
for(int i=0;i<m;i++){
scanf("%d",&t);
t+=1000001;
sumb=sumb*131+t;
}
int flag=-1;
for(int i=m;i<=n;i++){
if(sumb==(a[i]-a[i-m]*p[m])){
flag=i-m+1;
break;
}
}
if(flag==-1)
cout<<"-1"<<endl;
else
cout<<flag<<endl;
}
return 0;
}