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

int a1[200005],a2[200005],b1[200005],b2[200005],S[200005];
map<int,int>V;
int get(int n,int a[],int m,int b[])
{
	int i,j,k,ans=0;
	if(!n||!m)return 0;
	V.clear();
	for(i=1;i<=n;i++)V[a[i]]=1;
	S[m+1]=0;
	for(i=m;i>=1;i--)
	{
		S[i]=S[i+1];
		if(V[b[i]])S[i]++;
	}
	for(i=1;i<=m;i++)
	{
		j=upper_bound(a+1,a+1+n,b[i])-a-1;
		k=lower_bound(b+1,b+1+m,b[i]-j+1)-b;
		if(k<=i)ans=max(ans,S[i+1]+i-k+1);
	}
	return ans;
}
int main()
{
	int i,x,n,m,n1,n2,m1,m2,T;
	scanf("%d",&T);
	while(T--)
	{
		scanf("%d%d",&n,&m);
		n1=n2=m1=m2=0;
		while(n--)
		{
			scanf("%d",&x);
			if(x<0)a1[++n1]=-x;
			else a2[++n2]=x;
		}
		while(m--)
		{
			scanf("%d",&x);
			if(x<0)b1[++m1]=-x;
			else b2[++m2]=x;
		}
		sort(a1+1,a1+1+n1),sort(b1+1,b1+1+m1);
		printf("%d\n",get(n1,a1,m1,b1)+get(n2,a2,m2,b2));
	}
	return 0;
}                                                                                                                                 