WA on 8 10
#include <bits/stdc++.h>
using namespace std;
#define N 100005
int n,m,L,V,p[N],book[1000005];
struct car{
int d,v,a;
}b[N];
struct node{
int l,r;
}c[N];
bool cmp(node x,node y){
return x.r<y.r || x.l<y.l && x.r==y.r;
}
int main()
{
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int T; cin>>T;
while(T--){
memset(c,0,sizeof c);
memset(book,0,sizeof book);
cin>>n>>m>>L>>V;
for(int i=1;i<=n;i++) cin>>b[i].d>>b[i].v>>b[i].a;
for(int i=1;i<=m;i++) cin>>p[i];
p[m+1]=1000001;
int ans=0,cnt=0,res=0;
for(int i=1;i<=n;i++){
int l=0,r=0;
if(b[i].a==0) {if(b[i].v>V) l=b[i].d,r=L;
}else if(b[i].a>0){
if(b[i].v==V) l=b[i].d+1,r=L;
else if(b[i].v>V) l=b[i].d,r=L;
else{
double v0=b[i].v,vt=V,a1=b[i].a;
double x=(vt*vt-v0*v0)/(2.0*a1);
l=b[i].d+((int)x)+1,r=L;
}
}else{
if(b[i].v<=V) continue;
else{
double v0=V,vt=b[i].v,a1=(-1)*b[i].a;
double x=(vt*vt-v0*v0)/(2.0*a1);
l=b[i].d,r=b[i].d+((int)x);
}
}
if(!l && !r) continue;
int lt=lower_bound(p+1,p+m+1,l)-p;
if(p[lt]>r) continue;
int rt=lower_bound(p+1,p+m+1,r)-p;
if(p[rt]>r) rt--;
c[++ans]=node{lt,rt};
}
sort(c+1,c+ans+1,cmp);
for(int i=1;i<=ans;i++){
if(c[i].l<=res && res<=c[i].r) continue;
res=c[i].r,cnt++;
}
cout<<ans<<' '<<m-cnt<<endl;
} return 0;
}