#include using namespace std; int n, k; long long m, x, s, t, z = 0; vector a[200000]; long long c[200000], d[200001]; priority_queue> Q1, Q2; int main() { cin >> n >> m >> x; for (int i = 0; i < n; i++) { cin >> s >> t; t--; a[t].push_back(s); } for (int i = 0; i < m; i++) { sort(a[i].begin(), a[i].end()); Q2.push({ a[i].back(), i }); a[i].pop_back(); } cin >> k; for (int i = 0; i < k; i++) cin >> c[i]; sort(c, c + k); int j = 0, u = k; for (int i = 0; i < k; i++) { while (j <= c[i]) { d[j] = u; j++; } u--; } long long p1 = 0, p2 = 0, z1 = -1, z2 = -1; int w = 1, y = 0, q1, q2; while (!Q1.empty() || !Q2.empty()) { if (!Q1.empty()) { p1 = Q1.top().first; q1 = Q1.top().second; Q1.pop(); z1 = p1; } if (!Q2.empty()) { p2 = Q2.top().first; q2 = Q2.top().second; Q2.pop(); z2 = p2 + x; } if (z1 >= z2) { z += z1 * d[w]; z1 = 0; if(z2 > 0) Q2.push({ p2, q2 }); } else { z += z2 * d[w]; y++; z2 = 0; for(auto pq : a[q2]){ Q1.push({ pq, q2 }); a[q2].clear(); } if(z1 > 0) Q1.push({ p1, q1 }); } w++; } cout << z << endl; }