#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mod 1000000007
#define inf 100000000000000000
#define ar array
#define send ios::sync_with_stdio(false);
#define help cin.tie(0);
#define setpres(x) fixed<<setprecision(x)
#define all(x) (x).begin(),(x).end()
using namespace std;
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v) { for(int i=0;i<v.size();i++) cout<<v[i]<<" "; cout<<"\n";}
template<typename A,typename B> ostream& operator<<(ostream &cout, map<A,B> const &v) { for(auto x:v) cout<<x.first<<": "<<x.second<<"\n";}
template<typename A> ostream& operator<<(ostream &cout, vector<ar<A,2>> const &v) { for(int i=0;i<v.size();i++) cout<<v[i][0]<<" "<<v[i][1]<<"\n";}


int32_t main()
{
    int t;
    cin>>t;
    while(t--)
    {
        int n,m;
        cin>>n>>m;
        vector<int> l1,l2,r1,r2;
        map<int,int> m1;
        for(int i=0;i<n;i++)
        {
            int x;
            cin>>x;
            m1[x]=1;
            if(x<0)
                l1.pb(x);
            else 
                r1.pb(x);
        }
        for(int i=0;i<m;i++)
        {
            int x;
            cin>>x;
            if(x<0)
                l2.pb(x);
            else 
                r2.pb(x);
        }
        int ansl=0,ansr=0;
        int l=l1.size();
        int already=0;
        for(int i=0;i<l2.size();i++)
        {
            int boxes=l-(lower_bound(all(l1),l2[i])-l1.begin());
            int next=lower_bound(all(l2),boxes+l2[i])-l2.begin();
            // cout<<"boxes: "<<boxes<<" next: "<<next<<" already: "<<already<<"\n";
            ansl=max(ansl,next-i+already);
            already+=(m1.find(l2[i])!=m1.end());
        }
        // cout<<"ansl: "<<ansl<<"\n";
        already=0;
        l=r2.size();
        for(int i=l-1;i>=0;i--)
        {
            int boxes=upper_bound(all(r1),r2[i])-r1.begin();
            int next=lower_bound(all(r2),r2[i]-boxes+1)-r2.begin();
            if(boxes==0)
                next++;
            // cout<<"boxes: "<<boxes<<" next: "<<next<<" already: "<<already<<"\n";
            ansr=max(ansr,i-next+1+already);
            already+=(m1.find(r2[i])!=m1.end());
        }
        // cout<<"ansr: "<<ansr<<"\n";
        cout<<ansl+ansr<<"\n";
    }
}