#include<bits/stdc++.h>

using namespace std;

int calc(vector<int> a,vector<int> b){
    if(a.size()==0||b.size()==0) return 0;
    int ret=0;

    int c=0;
    for(int i=b.size()-1;i>=0;i--){
        auto it3=lower_bound(a.begin(),a.end(),0);
        auto it4=lower_bound(a.begin(),a.end(),b[i]+1);
        int n2=it4-it3;
        auto it1=lower_bound(b.begin(),b.end(),b[i]-n2+1);
        auto it2=lower_bound(b.begin(),b.end(),b[i]+1);
        int n=it2-it1;

        //cout<<i<<","<<n<<","<<n2<<endl;
        ret=max(ret,n+c);
        if(binary_search(a.begin(),a.end(),b[i])) c++;
    }
    return ret;
}
int main(){
    int t;
    cin>>t;
    while(t-->0){
        int n,m;
        cin>>n>>m;
        vector<int> ap,am,bp,bm;
        for(int i=0;i<n;i++) {
            int a;
            cin>>a;
            if(a<0) am.push_back(-a);
            else ap.push_back(a);
        }
        for(int i=0;i<m;i++) {
            int b;
            cin>>b;
            if(b<0) bm.push_back(-b);
            else bp.push_back(b);
        }
        sort(ap.begin(),ap.end());
        sort(am.begin(),am.end());
        sort(bp.begin(),bp.end());
        sort(bm.begin(),bm.end());
        cout<<calc(ap,bp)+calc(am,bm)<<endl;

    }
}
