#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define mp make_pair
#define F first
#define S second
#define mod 1000000007
#define md 998244353 
#define INF INT_MAX
#define vl vector<ll>
#define vi vector<int>
#define pi pair<int,int>
#define pl pair<ll,ll>
#define vpl vector<pl>
#define vpi vector<pi>
#define ml map<ll,ll>
#define mi map<int,int>
#define m(a,b) map<a,b>
#define rep(i,n) for(int i=1;i<=n;i++)
#define mxn 100005
#define printfloat(y) cout<<fixed<<setprecision(9)<<y<<endl;
#define YesNo(f) if(f){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;continue;}
#define setval(a,val) memset(a,val,sizeof(a)) 
#define fastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
int solve(vi a, vi b){
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	int n=a.size(),m=b.size(),cnt=0,ans;
	set<int> all;
	for(int i=0;i<n;i++){
		all.insert(a[i]);
	}
	vi match;
	for(int j=0;j<m;j++){
		if(all.count(b[j])){
			cnt++;
			match.pb(b[j]);
		}
	}
	ans=cnt;
	for(int j=0;j<m;j++){
		// cout<<b[j]<<" bj ";
		int x=upper_bound(a.begin(), a.end(),b[j])-a.begin();
		// cout<<x<<" x ";
		int y=lower_bound(b.begin(), b.end(),b[j]-x+1)-b.begin();
		// cout<<y<<" y "<<j+1-y<<" j+1-y ";
		int z=upper_bound(match.begin(), match.end(),b[j])-match.begin();
		z=cnt-z;
		// cout<<z<<" z "<<endl;
		ans=max(ans,j+1-y+z);
	}
	// cout<<endl;
	return ans;
}
int main()
{
	fastIO;
//	freopen("input.txt","r",stdin);
//	freopen("output.txt","w",stdout);
	int t=1;
	cin>>t;
	while(t--){
		int n,m,ans=0,x;
		cin>>n>>m;
		vi a,b,c,d;
		for(int i=0;i<n;i++){
			cin>>x;
			if(x>0)a.pb(x);
			if(x<0)c.pb(-x);
		}
		for(int j=0;j<m;j++){
			cin>>x;
			if(x>0)b.pb(x);
			if(x<0)d.pb(-x);
		}
		cout<<solve(a,b)+solve(c,d)<<endl;
		
	}

return 0;
}