#include #include using namespace std; pair p[200009]; bool vs[200009]; long long s[200009]; int main() { ios::sync_with_stdio(false); cin.tie(0); int n, m, x; cin >> n >> m >> x; for (int i = 1; i <= n; i++) cin >> p[i].first >> p[i].second; sort(p + 1, p + n + 1); reverse(p + 1, p + n + 1); for (int i = 1; i <= n; i++) { if (!vs[p[i].second]) { vs[p[i].second] = true; p[i].first += x; } } sort(p + 1, p + n + 1); reverse(p + 1, p + n + 1); for (int i = 1; i <= n; i++) s[i] = s[i - 1] + p[i].first; long long ans = 0; int k; cin >> k; for (int i = 0; i < k; i++) { int a; cin >> a; ans += s[a]; } cout << ans << '\n'; return 0; }