#include<bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int N = 1e5 + 10;
int d[N], v[N], a[N], p[N];
void solve() {
int n, m, L, V;
cin >> n >> m >> L >> V;
for (int i = 1; i <= n; ++i) {
cin >> d[i] >> v[i] >> a[i];
}
int P = -1;
for (int i = 1; i <= m; ++i) {
cin >> p[i];
P = max(P, p[i]);
}
int cnt = 0;
for (int i = 1; i <= n; ++i) {
double v1 = sqrt(v[i] * v[i] + 2 * a[i] * P);
if (v1 > 1.0 * V && d[i] <= P) cnt++;
}
cout << cnt << ' ';
if (cnt == 0) cout << m << '\n';
else cout << m - 1 << '\n';
}
signed main() {
freopen("1.in", "r", stdin);
freopen("1.out", "w", stdout);
int T;
cin >> T;
while (T--) {
solve();
}
}