#include<cstdio>
#include<algorithm>
#define N 100010
using namespace std;
inline int read()
{ char ch=getchar();bool f=true;int p=0;
for(;ch<'0'||'9'<ch;f&=(ch!='-'),ch=getchar());
for(;'0'<=ch&&ch<='9';p=(p<<3)+(p<<1)+ch-'0',ch=getchar());
return (f?1:-1)*p;
}
inline void print(const int &x)
{ if(x<10) { putchar(x+'0'); return; }
print(x/10),putchar(x%10+'0');
}
struct Car
{ int d,v,a;
#define d(x) car[x].d
#define v(x) car[x].v
#define a(x) car[x].a
}car[N];
int p[N];
struct node
{ int l,r;
#define l(x) mac[x].l
#define r(x) mac[x].r
}mac[N];
int num;
inline void check(const int &x,const int &m,const int &V)
{ int l=1,r=m,ans=0;
if(a(x)==0)
{ if(v(x)<=V) return;
while(l<=r)
{ int mid=(l+r)>>1;
if(p[mid]<d(x)) l=mid+1;
else ans=mid,r=mid-1;
}
}
else
if(a(x)>0)
while(l<=r)
{ int mid=(l+r)>>1;
if(p[mid]<d(x)) l=mid+1;
else
if((v(x)*v(x))+((a(x)*(p[mid]-d(x)))<<1)>V*V)
ans=mid,r=mid-1;
else l=mid+1;
}
else
while(l<=r)
{ int mid=(l+r)>>1;
if(p[mid]<d(x)) l=mid+1;
else
if((v(x)*v(x))<((a(x)*(d(x)-p[mid]))<<1)) r=mid-1;
else
if((v(x)*v(x))+((a(x)*(p[mid]-d(x)))<<1)>V*V)
ans=mid,l=mid+1;
else r=mid-1;
}
if(!ans) return;
num++;
if(a(x)>=0) l(num)=ans,r(num)=m;
else
{ r(num)=ans;
l=1,r=m;
while(l<=r)
{ int mid=(l+r)>>1;
if(p[mid]<d(x)) l=mid+1;
else ans=mid,r=mid-1;
}
l(num)=ans;
}
}
inline bool cmp(const node &A,const node &B)
{ return A.l==B.l?A.r<B.r:A.l<B.l;
}
int ans;
inline void update()
{ if(!num) return;
sort(mac+1,mac+num+1,cmp);
int L=l(1),R=r(1);
for(int i=2;i<=num;i++)
if(l(i)>R) ans++,L=l(i),R=r(i);
else L=max(L,l(i)),R=min(R,r(i));
ans++;
}
inline void clear(const int &n,const int &m)
{ for(int i=1;i<=n;i++) d(i)=v(i)=a(i)=0;
for(int i=1;i<=m;i++) p[i]=0;
for(int i=1;i<=num;i++) l(i)=r(i)=0;
num=ans=0;
}
int main()
{ freopen("detect.in","r",stdin);
freopen("detect.out","w",stdout);
int T=read();
while(T--)
{ int n=read(),m=read(),L=read(),V=read();
for(int i=1;i<=n;i++) d(i)=read(),v(i)=read(),a(i)=read();
for(int i=1;i<=m;i++) p[i]=read();
for(int i=1;i<=n;i++) check(i,m,V);
update();
print(num),putchar(' '),print(m-ans),putchar('\n');
clear(n,m);
}
}