#include <bits/stdc++.h>
#define int long long
using namespace std;
int T , n , m , L , V;
struct node{
int d , v , a , d1 , l , r;
}t[100010];
int p[100010];
int ans1 , ans2;
void init()
{
for(int i = 1 ; i <= n ; ++i)
{
if(t[i].v <= V && t[i].a <= 0) continue;
else if(t[i].v > V && t[i].a >= 0) t[i].d1 = L;
else if(t[i].a > 0){
t[i].d1 = t[i].d + (V*V-t[i].v*t[i].v) / (2 * t[i].a) ;
bool md = (V*V-t[i].v*t[i].v) % (2 * t[i].a) ;
t[i].d = t[i].d1+md;
t[i].d1 = L;
if(t[i].d > L) continue;
}
else
{
t[i].d1 = t[i].d + (t[i].v*t[i].v-V*V)/(-2*t[i].a);
}
t[i].l = lower_bound(p+1,p+n+1,t[i].d)-p;
t[i].r = upper_bound(p+1,p+n+1,t[i].d1)-p-1;
if(t[i].l > t[i].r) continue;
else ans1++;
}
}
bool cmp(node x , node y)
{
if(x.r == y.r) return x.l < y.l;
else return x.r < y.r;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cin >> T;
while(T--)
{
ans1 = ans2 = 0;
cin >> n >> m >> L >> V;
for(int i = 1 ; i <= n ; ++i)
{
cin >> t[i].d >> t[i].v >> t[i].a;
}
for(int i = 1 ; i <= m ; ++i)
{
cin >> p[i];
}
sort(p+1,p+m+1);
init();
int pos = 0;
for(int i = 1 ; i <= n ; ++i)
{
if(pos < t[i].l) pos = t[i].r , ans2++;
}
cout << ans1 << " " << m-ans2;
}
return 0;
}