#include <cstdio>
#include <iostream>
#include <algorithm>
#include <queue>
#include <cmath>
#include <functional>
#include <cstring>
#include <unordered_map>
#include <map>
#include <stack>
#include <vector>
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
int const maxn = 200010;
int const maxm = maxn * 2;
int const mod = 1e9 + 7;
int aa[maxn], bb[maxn];
vector<int> a1, b1, a2,b2;
map<int, int> mp;
int match[maxn];
int ans1[maxn], ans2[maxn];
int n, m, N, M, res1, res2;
int finda(int x, vector<int>& a) {
    int l = 0, r = n;
    while (l < r) {
        int mid = (l + r+1) >> 1;
        if (a[mid] <= x) l = mid;
        else r = mid - 1;
    }
    return l;
}
int findb(int x, vector<int>& b) {
    int l = 0, r = m;
    while (l < r) {
        int mid = (l + r+1) >> 1;
        if (b[mid] <= x) l = mid;
        else r = mid - 1;
    }
    return l;
}
void solve(vector<int>& a, vector<int>& b, int* ans, int& val) {
    mp.clear();
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    n = a.size() - 1;
    m = b.size() - 1;
    for (int i = 1; i <= M + 1; i++) match[i] = 0;
    for (int i = 1; i <= n; i++) mp[a[i]] = 1;
    for (int i = m; i >= 1; i--)
        if (mp[b[i]] == 1)
            match[i] = match[i + 1] + 1;
        else
            match[i] = match[i+1];
    int len;
    int j;
    for (int i = 1; i <= m; i++) {
        len = finda(b[i], a);
        j = findb(b[i] - len, b);       
        ans[i] = i - j + match[i + 1];
    }
    val = 0;
    for (int i = 1; i <= m; i++) val = max(val , ans[i]);
}
int main() {
    int t;
    cin >> t;
    while (t--) {   
        a1.clear(), a2.clear(), b1.clear(), b2.clear();
        a1.push_back(0), a2.push_back(0), b1.push_back(0), b2.push_back(0);
        cin >> N >> M;      
        for (int i = 1; i <= N; i++) cin >> aa[i];
        for (int i = 1; i <= M; i++) cin >> bb[i];
       
        for (int i = 1; i <= N; i++) {
            if (aa[i] >= 0)
                a1.push_back(aa[i]);
            else
                a2.push_back(-aa[i]);
        }
       
        for (int i = 1; i <= M; i++) {
            if (bb[i] >= 0)
                b1.push_back(bb[i]);
            else
                b2.push_back(-bb[i]);
        }
        solve(a1, b1, ans1, res1);
        solve(a2, b2, ans2, res2);
        int res = res1 + res2;
        cout << res << endl;

    }
    return 0;
}
