#include <bits/stdc++.h>
using namespace std;
struct node {
double lp,rp;
int typ;
} seg[100005];
int d[100005],v[100005],a[100005],p[100005];
bool pass[100005];
bool cmp(node x,node y) {
return x.rp < y.rp;
}
int main() {
// freopen("detect5.in","r",stdin);
ios::sync_with_stdio(false);
cin.tie(0);
int t; cin >> t;
while(t--) {
memset(pass,0,sizeof pass);
int n,m,L,V; cin >> n >> m >> L >> V;
for(int i = 1;i <= n;i++) cin >> d[i] >> v[i] >> a[i];
for(int i = 1;i <= m;i++) cin >> p[i];
int cnt = 0;
for(int i = 1;i <= n;i++) {
if(d[i] > p[m]) continue;
if(a[i] == 0) {
if(v[i] > V) {
cnt++; pass[i] = true;
}
}
if(a[i] < 0) {
int pos = lower_bound(p+1,p+m+1,d[i]) - p;
int s = p[pos] - d[i];
int speed_sqr = v[i] * v[i] + 2 * a[i] * s;
if(speed_sqr > (V * V)) {
cnt++; pass[i] = true;
}
}
if(a[i] > 0) {
int s = p[m] - d[i];
int speed_sqr = v[i] * v[i] + 2 * a[i] * s;
if(speed_sqr > (V * V)) {
cnt++; pass[i] = true;
}
}
}
cout << cnt << ' ';
int cur = 0;
for(int i = 1;i <= n;i++) {
if(!pass[i]) continue;
if(a[i] == 0) {
seg[++cur].lp = d[i]; seg[cur].rp = L; seg[cur].typ = 0;
}
if(a[i] < 0) {
seg[++cur].lp = d[i]; seg[cur].rp = d[i] + (V * V - v[i] * v[i]) * 1.0 / (2 * a[i]); seg[cur].typ = 1;
}
if(a[i] > 0) {
seg[++cur].lp = d[i] + (V * V - v[i] * v[i]) * 1.0 / (2 * a[i]); seg[cur].rp = L; seg[cur].typ = 2;
}
}
sort(seg+1,seg+cur+1,cmp);
// for(int i = 1;i <= cur;i++) {
// cout << seg[i].lp << ' ' << seg[i].rp << ' ' << seg[i].typ << endl;
// }
// for(int i = 1;i <= m;i++) {
// cout << p[i] << " \n"[i == m];
// }
int now1 = 1,now2 = 1,ans = 0,lst = -1;
//now1 表示当前处理到第几个线段,now2 表示现在处理到第几个点,ans 是点的个数,lst 是上一个
//被选出来的点的坐标
while(now1 <= cur) {
if(lst >= seg[now1].lp) {
now1++; continue;
}
if(seg[now1].typ == 0) {
while(p[now2] <= seg[now1].rp && now2 <= m) now2++;
now2--; ans++; lst = p[now2];
}
if(seg[now1].typ == 1) {
while(p[now2] < seg[now1].rp && now2 <= m) now2++;
now2--; ans++; lst = p[now2];
}
if(seg[now1].typ == 2) {
while(p[now2] <= seg[now1].rp && now2 <= m) now2++;
now2--; ans++; lst = p[now2];
}
now1++;
}
cout << m - ans << endl;
}
return 0;
}
WA On #10:Wrong Answer.wrong answer On line 6 column 11, read 4, expected 3.