#include <bits/stdc++.h>
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(lli i=s;i<n;i++)
#define INF (1LL<<62)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
 
template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

void solve(){

	lli n,m;
	cin>>n>>m;
	vector<lli> a(n),p(m);
	vector<lli> plA,plP,miA,miP;
	REP(i,0,n){
		cin>>a[i];
		if(a[i]>0)plA.push_back(a[i]);
		else miA.push_back(-a[i]);
	}
	REP(i,0,m){
		cin>>p[i];
		if(p[i]>0)plP.push_back(p[i]);
		else miP.push_back(-p[i]);
	}

	lli ans = 0;
	auto func = [](vector<lli> &a,vector<lli> &p)
	{
		a.push_back(INF);
		SORT(a);
		SORT(p);
		set<lli> sp;
		for(auto e:p)sp.insert(e);
		map<lli,lli> sumP;
		lli now = 0;
		for(lli i=a.size()-1;i>=0;i--){
			if(sp.find(a[i]) != sp.end())now++;
			sumP[a[i]] = now; 
		}
		lli ans = 0;
		lli cnt = 0;
		for(auto e:p)
		{
			LOG(e);
			lli index = (lli)(upper_bound(a.begin(),a.end(),e) - a.begin());
			if(index == 0){
				cnt++;
				continue;
			}
			lli lefP = e - (index-1);
			lli lefPIndex = (lli)(lower_bound(p.begin(),p.end(),lefP) - p.begin());
			LOG4(index,lefP,cnt,lefPIndex);
			lli nowAns = min(index,cnt-lefPIndex+1)+sumP[a[index]];
			chmax(ans,nowAns);
			cnt++;
			LOG2(ans,nowAns);
		}
		LOG(ans);
		return ans;
	};
	ans += func(plA,plP);
	ans += func(miA,miP);
	cout<<ans<<endl;
}
 
int main(){
 
	ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
 
	lli t = 1;
	cin>>t;
	while(t--)solve();
 
	return 0;
}