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

bool find(vector<int> &v, int a)
{
	// return;
	int start = 0;
	int end = v.size()-1;
	if(start > end)
	{
		return false;
	}
	for(int i = 0; i < 100; ++i)
	{
		int mid = (start+end)/2;
		if(v[mid] == a)
		{
			return true;
		}
		else if(v[mid] > a)
		{
			end = mid;
		}
		else
		{
			start = mid;
		}
	}
	if(v[end] == a)
	{
		return true;
	}
	if(v[start] == a)
	{
		return true;
	}
	return false;
}

void solve()
{
	int n, m;
	cin>>n>>m;
	vector<int> pos1, pos2, neg1, neg2;
	for(int i = 0; i < n; ++i)
		{
			int a;
			cin>>a;
			if(a > 0)
			{
				pos1.push_back(a);
			}
			else
			{
				neg1.push_back(-1*a);
			}
		}
		for(int i = 0; i < m; ++i)
		{
			int a;
			cin>>a;
			if(a > 0)
			{
				pos2.push_back(a);
			}
			else
			{
				neg2.push_back(-1*a);
			}
		}
		// return;
		reverse(neg1.begin(), neg1.end());
		reverse(neg2.begin(), neg2.end());
		// for(int i = 0; i < pos1.size(); ++i)
		// 	{
		// 		cout<<pos1[i]<<" ";
		// 	}
		// 	cout<<endl;
		// 	for(int i = 0; i < pos2.size(); ++i)
		// 	{
		// 		cout<<pos2[i]<<" ";
		// 	}
		// 	cout<<endl;
			// cout<<"hello";
			// 	return;
			// return;
			int ans = 0;
			int curr_match = 0;
			for(int i = pos2.size()-1; i >= 0; --i)
			{
				int temp = 0;
				// cout<<"hello";
				// return;
				int a = upper_bound(pos1.begin(), pos1.end(), pos2[i])-pos1.begin();
				// cout<<"hello";
				// return;
				// cout<<a<<" "<<pos2[i]<<endl;
				int b = pos2[i]-a;
				if(b < 0)
				{
					continue;
				}
				int c = upper_bound(pos2.begin(), pos2.end(), b)-pos2.begin();
				// cout<<"hello";
				// return;
				ans = max(ans, i-c+1+curr_match);
				if(find(pos1, pos2[i]) == true)
				{
					curr_match++;
				}
				// if(pos2[i] == pos1[i])

			}
			// return;
			// for(int i = 0; i < neg1.size(); ++i)
			// {
			// 	cout<<neg1[i]<<" ";
			// }
			// cout<<endl;
			// for(int i = 0; i < neg2.size(); ++i)
			// {
			// 	cout<<neg2[i]<<" ";
			// }
			// cout<<endl;
			// cout<<neg2.size()<<endl;
			// cout<<"hello";
			// 	return;
			int ans1 = 0;
			int curr_match1 = 0;
			for(int i = neg2.size()-1; i >= 0; --i)
			{
				int temp = 0;
				int a = upper_bound(neg1.begin(), neg1.end(), neg2[i])-neg1.begin();
				// cout<<"hello";
				// return;
				// cout<<a<<" "<<pos2[i]<<endl;
				int b = neg2[i]-a;
				if(b < 0)
				{
					continue;
				}
				int c = upper_bound(neg2.begin(), neg2.end(), b)-neg2.begin();
				ans1 = max(ans1, i-c+1+curr_match1);
				if(find(neg1, neg2[i]) == true)
				{
					curr_match1++;
				}
				// if(pos2[i] == pos1[i])
			}
			// cout<<ans1<<endl;
			 cout<<ans+ans1<<endl;
}

int main()
{
	// freopen("input1.txt", "r", stdin);
	// freopen("txxx.txt", "w", stdout);

	int t;
	cin>>t;
	while(t--)
		solve();
}