#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
int main() {
int T;
cin >> T;
while (T--) {
int n, m, L, V;
cin >> n >> m >> L >> V;
vector<tuple<int, int, int>> cars(n);
for (int i = 0; i < n; ++i) {
int d, v, a;
cin >> d >> v >> a;
cars[i] = {d, v, a};
}
vector<int> positions(m);
for (int j = 0; j < m; ++j) {
cin >> positions[j];
}
int speedingCount = 0;
set<int> necessaryPositions;
for (auto [d, v, a] : cars) {
bool isSpeeding = false;
vector<int> currentNecessary;
for (int pos : positions) {
if (pos < d) continue;
int distance = pos - d;
if (a == 0) {
if (v > V) {
isSpeeding = true;
currentNecessary.push_back(pos);
}
} else {
int speedAtPos = v * v + 2 * a * distance;
if (speedAtPos > 0) {
int instantaneousSpeed = sqrt(speedAtPos);
if (instantaneousSpeed > V) {
isSpeeding = true;
currentNecessary.push_back(pos);
}
}
}
if (v <= 0) break;
}
if (isSpeeding) {
speedingCount++;
necessaryPositions.insert(currentNecessary.begin(), currentNecessary.end());
}
}
int canCloseCount = m - necessaryPositions.size();
cout << speedingCount << " " << canCloseCount << endl;
}
return 0;
}