#include<bits/stdc++.h>
#define int long long
#define l first
#define r second
using namespace std;
const int N=1e5+10;
typedef pair<int,int> PII;
namespace io
{
char buf[1<<20],*p1,*p2;
#define gc() (p1==p2 && (p2=(p1=buf)+fread(buf,1,1<<20,stdin),p1==p2)?0:*p1++)
template<typename T> inline void read(T &x)
{
T w=1;x=0;
char c=gc();
while(!isdigit(c))
{
if(c=='-') w=-1;
c=gc();
}
while(isdigit(c))
{
x=(x<<1)+(x<<3)+(c^48);
c=gc();
}
x=x*w;
}
template<typename T,typename...Args> inline void read(T &x,Args&...x_)
{
read(x),read(x_...);
}
template<typename T> inline void write(T x)
{
if(x<0) putchar('-'),x=-x;
if(x>9) write(x/10);
putchar(x%10+'0');
return;
}
};
using namespace io;
struct Data
{
int d,v,a;
int l,r;
}q[N];
PII It[N];
int p[N];
int n,m,L,T,Lim;
int ans1,ans2;
int calc(int p1,int p2,int v,int a)
{
int s=p2-p1;
int w=v*v+2*a*s;
return w;
}
void solve()
{
read(n,m,L,Lim);
for(int i=1,d,v,a;i<=n;i++)
{
read(d,v,a);
q[i]={d,v,a,0,0};
}
for(int i=1;i<=m;i++)
{
read(p[i]);
}
for(int i=1;i<=n;i++)
{
int d=q[i].d,v=q[i].v,a=q[i].a;
int x=lower_bound(p+1,p+1+m,d)-p;
if(x>m)
{
q[i].l=q[i].r=-1;
continue;
}
if(a==0)
{
if(v>Lim) q[i].l=x,q[i].r=m;
else q[i].l=-1,q[i].r=-1;
}
else if(a>0)
{
int l=x,r=m,ans=-1;
while(l<=r)
{
int mid=l+r>>1;
int pos=p[mid];
if(calc(d,pos,v,a)>Lim*Lim) ans=mid,r=mid-1;
else l=mid+1;
}
if(ans==-1) q[i].l=q[i].r=-1;
else q[i].l=ans,q[i].r=m;
}
else
{
int l=x,r=m,ans=-1;
while(l<=r)
{
int mid=l+r>>1;
int pos=p[mid];
if(calc(d,pos,v,a)>Lim*Lim) ans=mid,l=mid+1;
else r=mid-1;
}
if(ans==-1) q[i].l=q[i].r=-1;
else q[i].l=x,q[i].r=ans;
}
}
int tot=0;
for(int i=1;i<=n;i++)
{
int l=q[i].l,r=q[i].r;
if(l==-1 || r==-1) continue;
It[++tot]={l,r};
}
n=tot;
sort(It+1,It+n+1,[](PII A,PII B)
{
if(A.r!=B.r) return A.r<B.r;
return A.l>B.l;
});
ans1=n;
int mx=-1;
tot=0;
for(int i=1;i<=n;i++)
{
if(It[i].l>mx) It[++tot]=It[i],mx=It[i].l;
}
n=tot;
int now=-1,cnt=0;
for(int i=1;i<=n;i++)
{
int l=It[i].l,r=It[i].r;
if(l>now) now=r,cnt++;
}
ans2=cnt;
write(ans1),putchar(' ');
write(m-ans2);
putchar('\n');
}
signed main()
{
freopen("detect.in","r",stdin);
freopen("detect.out","w",stdout);
read(T);
while(T--) solve();
return 0;
}