#include <bits/stdc++.h>
namespace LIXUEAN{
using namespace LIXUEAN ;
typedef long long ll ;
const ll T = 20,N = 100005,M = 100005,L = 1000005,V = 1005 ;
struct jgt{ int d,v,a ; } a[N] ;
struct lin{ int l,r ; } b[N] ;
bool cmp(lin a,lin b) { return (a.r == b.r) ? (a.l > b.l) : (a.r < b.r) ; }
int min(int a,int b) { return (a < b) ? (a) : (b) ; }
int max(int a,int b) { return (a > b) ? (a) : (b) ; }
int t,n,m,l,v,p[M],ans1,ans2 ;
int myRead(){
char ch ;
bool pd = false ;
while((ch = getchar()) > '9' || ch < '0')pd = (ch == '-') ;
int num = ch ^ '0' ;
while((ch = getchar()) <= '9' && ch >= '0')num = (num << 1) + (num << 3) + (ch ^ '0') ;
ungetc(ch,stdin) ;
return (pd) ? (-num) : (num) ;
}
int Main(){
freopen("detect.in","r",stdin) ;
freopen("detect.out","w",stdout) ;
t = myRead() ;
while(t --){
n = myRead() ; m = myRead() ; l = myRead() ; v = myRead() ;
for(int i = 1;i <= n;++ i){
a[i].d = myRead() ;
a[i].v = myRead() ;
a[i].a = myRead() ;
}
for(int i = 1;i <= m;++ i)
p[i] = myRead() ;
ans1 = 0 ;
for(int i = 1;i <= n;++ i){
int start = max(1LL,std::lower_bound(p + 1,p + m + 1,a[i].d) - p),end = 0 ;
if(a[i].a >= 0)end = m ;
else{
double t = a[i].v * 1.0 / a[i].a ;
double sum = a[i].d + a[i].a * t + 0.5 * a[i].a * t * t ;
end = std::upper_bound(p + 1,
p + m + 1,ll((sum - 1e-10 + 1) - 1)) - p ;
end = min(end,m) ;
}
int l = start,r = m ;
int mid = 0,ans = (a[i].a > 0) ? (m + 1) : (0) ;
while(l <= r){
mid = (l + r) >> 1 ;
int speed = a[i].v * a[i].v +
2 * a[i].a * (p[mid] - a[i].d) ;
if(speed > v * v){
if(a[i].a > 0)ans = min(ans,mid),r = mid - 1 ;
else ans = max(ans,mid),l = mid + 1 ;
}else if(a[i].a > 0)l = mid + 1 ;
else r = mid - 1 ;
}
if(a[i].a > 0 && ans != m + 1)b[i].l = ans,b[i].r = end,++ ans1 ;
else if(a[i].a <= 0 && ans)b[i].l = start,b[i].r = ans,++ ans1 ;
}
std::sort(b + 1,b + n + 1,cmp) ;
int l = 0,r = 0,ans = 0 ;
for(int i = 1;i <= n;++ i)
if(b[i].l > r)++ ans,l = b[i].l,r = b[i].r ;
else l = std::max(l,b[i].l),r = std::min(r,b[i].r) ;
ans2 = m - ans ;
printf("%d %d\n",ans1,ans2) ;
for(int i = 1;i <= n;++ i)a[i].d = a[i].v = a[i].a = b[i].l = b[i].r = 0 ;
for(int i = 1;i <= m;++ i)p[i] = 0 ;
n = m = l = v = ans1 = ans2 = 0 ;
}
return 0 ;
}
}
int main(){
LIXUEAN::Main() ;
return 0 ;
}