#include "bits/stdc++.h"
using namespace std;
#define int long long
#define eb emplace_back
#define mp make_pair
typedef pair<int,int> pii;
#define f first
#define s second

#define min(a,b) ((a<b)?a:b)

//const int mod=1000000007;

vector<int>a[2],b[2];
int suff[200005];

int32_t main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int tc,aa,bb,l,r,maxi[2];
  cin>>tc;
  int n,m;
  while(tc--){
    cin>>n>>m;
    a[0].clear();a[1].clear();
    b[0].clear();b[1].clear();
    for(int i=0;i<n;i++){
      cin>>aa;
      if(aa<0)a[0].push_back(-aa);
      else a[1].push_back(aa);
    }
    for(int i=0;i<m;i++){
      cin>>bb;
      if(bb<0)b[0].push_back(-bb);
      else b[1].push_back(bb);
    }
    reverse(b[0].begin(),b[0].end());
    reverse(a[0].begin(),a[0].end());
    for(int t=0;t<2;t++){//+'ve or -'ve
      maxi[t]=0;

      if(b[t].size()==0)continue;
      a[t].push_back(2e9);//inf basically...
      sort(a[t].begin(),a[t].end());
      sort(b[t].begin(),b[t].end());

      suff[a[t].size()]=0;
      l=b[t].size()-1;
      for(int i=a[t].size()-1;i>=0;i--){;
        suff[i]=suff[i+1];
        while(l>0 && b[t][l-1]>=a[t][i]){
          l--;
        }
        if(l<0 || b[t][l]<a[t][i])continue;
        if(b[t][l]==a[t][i])suff[i]++;
      }
      //maxi[t]=suff[0];

      l=r=0;//iterating on b
      for(int i=0;i<a[t].size()-1;i++){
        //(i+1) boxes, rightmost box at a[t][i]...
        while(r+1<b[t].size() && b[t][r]<a[t][i]){
          r++;
        }
        if(b[t][r]<a[t][i])break;//give up...
        if(b[t][r]>=a[t][i+1])continue;
        while(b[t][r]-b[t][l]>i)l++;//not enough current boxes to cover it...
        if(b[t][r]<a[t][i+1])maxi[t]=max(maxi[t],r-l+1+suff[i+1]);
//        else maxi[t]=max(maxi[t],r-l+1);

        while(r+1<b[t].size() && b[t][r+1]<a[t][i+1]){
          r++;
          while(b[t][r]-b[t][l]>i)l++;
          if(b[t][r]<a[t][i+1])maxi[t]=max(maxi[t],r-l+1+suff[i+1]);
        }
      }
    }
    cout<<maxi[0]+maxi[1]<<'\n';
  }
  return 0;
}
/*

*/
