#include "bits/stdc++.h"
using namespace std;
#define fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 
 
#define rep(i,a,b)               for(int i=a;i<b;i++)
 
#define pfy                       cout<<("YES")
#define pfn                      cout<<("NO")
 
typedef long long ll;
typedef long double ld;
#define nl                        cout<<("\n")
#define int ll
 
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
typedef vector< ii > vii;
 
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for( auto i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
 
#define F first
#define S second
 
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
 
const int hell=round(9e18);
 
/* */
int sol(vector<int> &a, vector<int> &b){

	int n=sz(a);
	int m=sz(b);

	if(n==0 || m==0) return 0;

	sort(all(a));
    sort(all(b));

	int i=0;
	int cnt=0;
	int mx=0;

	for(int j=0;j<m;j++){

		while(i<n && a[i]<b[j]) i++;

		int blk= n-i;

		int ben=b[j]+blk;

		int x=lower_bound(b.begin()+j,b.end(),ben)-(b.begin()+j);

		mx=max(mx,cnt+x);

		if(i<n && a[i]==b[j]) cnt++;


	}

	return mx;



}
 
signed solve(){

    int n,m; cin>>n>>m;

    vector<int> a1,b1;
    vector<int> a2,b2;

    for(int i=0;i<n;i++) {

    	int x; cin>>x;
    	if(x<0) a1.push_back(x);
    	else a2.push_back(-x);

    }

    for(int i=0;i<m;i++){

    	int x; cin>>x;
    	if(x<0) b1.push_back(x);
    	else b2.push_back(-x);

    }

    int y1=sol(a1,b1);
    int y2=sol(a2,b2);

    cout<<y1+y2<<endl;

    return 0;
}
 
signed main(){
 
	int t=1;
	 
    fast;            //  freopen("input.txt","r",stdin); freopen ("output.txt","w",stdout);
	cin>>t;
	 
	while(t--){
		solve();
	}
	 
	return 0;

}