#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define fi first
#define se second
#define mset(a,b) memset(a, b, sizeof(a))
#define dbg(x) cout << "[" << #x << "]: " << x << endl;
#define forn(i,n) for(int i=0; i < n;i++)
#define forab(i,a,b) for(int i = a; i <= b; i++)
#define forba(i,b,a) for(int i = b; i >= a; i--)
#define each(val, v) for(auto val : v)
#define abs(u) (u >= 0 ? u : -u)

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

const int MAXN = 2e5 + 5;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;


int solve1(vi &a, vi &b){
    int n = a.size();
    int m = b.size();

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

    set<int> pos;
    set<int> boxs;

    forn(i,n){
        if(i == 0) continue;
        boxs.insert(a[i]);
    }

    forn(i,m){
        pos.insert( b[i] );
    }

    int cnt_certo = 0;

    forn(i,n){
        if( pos.find( a[i] ) != pos.end() ){
            cnt_certo++;
        }
    }

    int length = 1;

    int at = 1;

    int ans = cnt_certo;
    int ini = 0;

    forn(i,m){
        if(a[0] == b[i]){
            cnt_certo--;
            ini = i+1;
            break;
        }
    }

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

        if(b[i] < a[0]) continue;


        while(at < n &&  b[i] + length -1 >= a[at] ){
            

            if(pos.find(a[at]) != pos.end()){
                cnt_certo--;
            }

            at++;
            length++;
        }

        auto up = upper_bound( b.begin(), b.end(), b[i] + length - 1);

        up--;

        int j = up - b.begin();

        int at = j - i + 1 + cnt_certo;


        ans = max(at, ans);
    }

    return ans;
}

void solve(){

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

    vi pos_m;
    vi pos_n;
    vi neg_n;
    vi neg_m;

    forn(i,n){
        int aux;
        cin >> aux;

        if(aux < 0){
            neg_n.pb(-aux);
        }else{
            pos_n.pb(aux);
        }
    }

    forn(i,m){
        int aux;
        cin >> aux;

        if(aux < 0){
            neg_m.pb(-aux);
        }else{
            pos_m.pb(aux);
        }
    }

    sort(neg_m.begin(), neg_m.end());

    sort(neg_n.begin(), neg_n.end());

    int ans1 = solve1(neg_n, neg_m);
    int ans2 = solve1(pos_n, pos_m);
    int ans = ans1 + ans2;

    cout << ans << endl;

}

int main(){

    ios::sync_with_stdio(false); cin.tie(NULL);

    int t = 1;
    cin >> t;
    while(t--){
        solve();
    }

    return 0;
}