#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll mod = 1e9 +  7;
ll fast(ll n,ll k, ll mod){
    ll res = 1;
    n = n % mod;
    while(k > 0){
        if ((k&1) == 1)
            res = (res * n) % mod;
        k = k>>1;
        n = (n * n) % mod;
    }
    return res % mod;
}
int go(vector<int>& a, vector<int>& b){
	ll ans = 0, id = 0;
	vector<int> rev(b.size()+1 , 0);
	
	for(int i = b.size() - 1; i >= 0; i--){
		if(binary_search(a.begin(), a.end(), b[i])) rev[i] = 1;
		rev[i] += rev[i+1];
	}

	for(int i = 0; i < b.size(); i++){
		ll val = upper_bound(a.begin(), a.end(), b[i]) - a.begin();
		ll tmp = b[i] - val;
		ll tt = upper_bound(b.begin(), b.end(), tmp) - b.begin();
		tt = i + 1 - tt;
		ans = max(ans, tt + rev[i+1]);
	}
	//~ cerr << "->";
	//~ for(auto i: a) cerr << i << " ";
	//~ cerr << "\n->";
	//~ for(auto i: b) cerr << i << " ";
	//~ cerr << ans << " ans\n";
	return ans;
}
		
void solve(){
	ll n, m;
	cin >> n >> m;
	vector<int> a(n), b(m);
	for(auto &i: a) cin >> i;
	for(auto &i: b) cin >> i;
	vector<int> pos, neg;
	for(auto i: a){
		if(i < 0) neg.push_back(-i);
		else pos.push_back(i);
	}
	vector<int> pp, nn;
	for(auto i: b){
		if(i < 0) nn.push_back(-i);
		else pp.push_back(i);
	}
	reverse(neg.begin(), neg.end());
	reverse(nn.begin(), nn.end());
	cerr << "ans = ";
	cout << go(pos, pp) +  go(neg, nn);
}

int main(){
	int t;
	cin >> t;
	for(int i = 1; i <= t; i++){
		solve();
		cout << '\n';
	}
}


//~ 10 9
//~ -29 -26 -25 -18 -17 -15 -13 -9 -6 21
//~ -29 -26 -12 -2 3 12 18 21 22
