#include<bits/stdc++.h>

using namespace std;

#define task "sol"
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define zs(v) ((int)(v).size())
#define BIT(x, i) (((x) >> (i)) & 1)
#define CNTBIT __builtin_popcountll
#define ALL(v) (v).begin(),(v).end()
#define endl '\n'

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;

const int dx[8] = {0, -1, 0, 1, 1, -1, -1, 1};
const int dy[8] = {-1, 0, 1, 0, -1, -1, 1, 1};

const ll mod=1000000007; /// 998244353
const int base=311;
const int N=2e5+5;

int n,m;
int pos[N],box[N];
int pre[N],suf[N];

int calc(vector<int> a, vector<int> b)
{
    sort(ALL(a));
    sort(ALL(b));


    int ans=0;
    b.pb(1e9+5);
    int suf=0;
    for(int i=0;i<zs(b);++i)
    {
        if(binary_search(ALL(a),b[i])) ++suf;
    }
    for(int i=0,j=0;i<zs(b)-1;++i)
    {
        if(binary_search(ALL(a),b[i])) --suf;
        while(j<zs(a)&&a[j]<b[i+1])
        {
            if(a[j]>=b[i])
            {
                int l=0, r=j, id=-1;
                while(l<=r)
                {
                    int mid=(l+r)>>1;
                    if(a[j]-i<=a[mid])
                    {
                        r=mid-1;
                        id=mid;
                    }
                    else l=mid+1;
                }
                if(id==-1) continue;
                ans=max(ans,j-id+1+suf);
            }
            ++j;
        }
    }
    return ans;
}
void gogo()
{
    cin>>n>>m;
    for(int i=1;i<=n;++i) cin>>box[i];
    for(int i=1;i<=m;++i) cin>>pos[i];

    vector<int> lt1,rt1,lt2,rt2;

    for(int i=1;i<=m;++i)
    {
        if(pos[i]<0) lt1.pb(-pos[i]);
        else rt1.pb(pos[i]);
    }
    for(int i=1;i<=n;++i)
    {
        if(box[i]<0) lt2.pb(-box[i]);
        else rt2.pb(box[i]);
    }

    cout<<calc(lt1,lt2)+calc(rt1,rt2)<<endl;
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    if(fopen(task".inp","r"))
    {
        freopen(task".inp","r",stdin);
        freopen(task".out","w",stdout);
    }
    int t;
    cin>>t;
    while(t--) gogo();
}






