#include<bits/stdc++.h>
using namespace std;
typedef double db;
const int N=1e5+5;
const db ex=1e-9;
int T,n,m,L,V,p[N],tot,tott,ans1,ans2;
struct node{
int l,r;
bool operator <(const node &x)const{
if(r==x.r) return l>x.l;
return r<x.r;
}
}b[N],bb[N];
struct car{
int d,v,a;
}c[N];
db calc(int d,int v,int a,int x){
return sqrt(1.0*v*v+2.0*a*(x-d));
}
int find1(int d,int v,int a){
int pos=lower_bound(p+1,p+m+2,d)-p;
if(pos==m+1) return -1;
int l=pos-1,r=m,mid;
while(l+1<r){
mid=(l+r)>>1;
if(calc(d,v,a,p[mid])-V>ex) r=mid;
else l=mid;
}
if(calc(d,v,a,p[r])-V>ex) return r;
return -1;
}
int find2(int d,int v,int a){
int pos=lower_bound(p+1,p+m+2,d)-p;
if(pos==m+1) return -1;
int tmp=v*v/(-a*2),pos2=upper_bound(p+1,p+m+2,d+tmp)-p-1;
int l=pos,r=pos2+1,mid;
while(l+1<r){
mid=(l+r)>>1;
if(calc(d,v,a,p[mid])-V>ex) l=mid;
else r=mid;
}
if(calc(d,v,a,p[l])-V>ex) return l;
return -1;
}
int main(){
freopen("detect.in","r",stdin);
freopen("detect.out","w",stdout);
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
cin>>T;
while(T--){
cin>>n>>m>>L>>V;
for(int i=1;i<=n;i++) cin>>c[i].d>>c[i].v>>c[i].a;
for(int i=1;i<=m;i++) cin>>p[i];
p[m+1]=10000000;
tot=tott=ans1=ans2=0;
for(int i=1;i<=n;i++){
int d=c[i].d,v=c[i].v,a=c[i].a;
if(a>=0){
int pos=find1(d,v,a);
if(pos==-1) continue;
b[++tot]=(node){pos,m},ans1++;
}
else{
int pos=find2(d,v,a);
if(pos==-1) continue;
int poss=lower_bound(p+1,p+m+2,d)-p;
b[++tot]=(node){poss,pos},ans1++;
}
}
sort(b+1,b+tot+1);
int mx=-1;
for(int i=1;i<=tot;i++){
if(b[i].l<=mx) continue;
bb[++tott]=b[i],mx=b[i].l;
}
mx=-1;
for(int i=1;i<=tott;i++){
if(bb[i].l<=mx) continue;
ans2++,mx=bb[i].r;
}
cout<<ans1<<' '<<m-ans2<<'\n';
}
return 0;
}