#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
#define ar array<int,2>
#define inf 1000000000000000000 
#define deb(x) cerr << "\n" << (#x) << " is " << (x) << endl
int mod=1e9+7;
int min(int a,int b){return (a<b)?a:b;}
int max(int a,int b){return (a>b)?a:b;}
int fp(int a,int b){if(b==0) return 1;int x=fp(a,b/2);x=(x*x)%mod;if(b&1) x=(x*a)%mod;return x;}
auto random_add = [] { char *p = new char; delete p; return uint64_t(p); };
const uint64_t SEED = chrono::steady_clock::now().time_since_epoch().count() * (random_add() | 1);
mt19937_64 rng(SEED);


const int N=2e5+5;

int get(int x)
{
    if(x==0)
        x=-1;
    return x;
}

int solve(vector<int> a,vector<int> b){
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    // for(auto i:a)
    // {
    //     cout<<i<<" ";
    // }
    // cout<<endl;
    // for(auto i:b)
    //     cout<<i<<" ";
    // cout<<endl;
    if(b.size()==0)
        return 0;
    int tot=0;
    map<int,int> mp2,mp;
    for(auto i:a)
        mp[i]++;
    int p=0,cur=0;
    for(auto i:b){
        cur+=mp[i];
        mp2[i]=1;
    }
    int k=0,ans=0;
    vector<int> tmp;
    int i=0,inter=0;

    for(int j=0;j<b.size();j++)
    {
        while(i<a.size()&&a[i]<=b[j])
        {
            if(mp2[a[i]]==1)
            cur--;

            i++;
            tot++;
        }
        // tmp.push_back(a[j]);
       
        // if(mp2[a[j]]==1)
        //     cur--;
       
       
        // tot++;
       // cout<<j<<" "<<tot<<" "<<cur<<endl;
        int lw=0,hg=j,pos=0;
        while(lw<=hg)
        {
            int mid=(lw+hg)/2;
            if(b[j]-b[mid]<tot)
            {
                ans=max(ans,j-mid+1+cur);
                hg=mid-1;
            }
            else{
                lw=mid+1;
            }
        }

        // lw=0;
        // hg=j;
        // while(lw<=hg)
        // {
        //     int mid=(lw+)
        // }


        // ans=max(min(pos,tot)+cur,ans);

    }
    return ans;
}



void solve()
{
    int n,m,x;
    cin>>n>>m;
    vector<int> a1,a2,b1,b2;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        if(x>0)
        a1.push_back(x);
        else
        a2.push_back(-x);
    }
    for(int i=0;i<m;i++)
    {
        cin>>x;
        if(x>0)
        b1.push_back(x);
        else
        b2.push_back(-x);
    }

    cout<<solve(a1,b1)+solve(a2,b2)<<endl;


   
}

signed main() {
 ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
 srand(time(0));
 int t=1;
 cin>>t;
 for(int i=1;i<=t;i++)
 {
   solve();
 }
}
