#include using namespace std; using ll = long long; const ll MOD = 1000000007; using P = pair; #define rep(i, n) for(int i = 0; i < n; i++) #define all(x) (x).begin(),(x).end() int main(){ int n,m,x,k; cin >> n >> m >> x; vector

ab(n); rep(i,n) cin >> ab[i].first >> ab[i].second; sort(all(ab)); reverse(all(ab)); priority_queue pq; set se; rep(i,n){ ll p = 0; if(!se.count(ab[i].second)) p += x; p += ab[i].first; pq.push(p); se.insert(ab[i].second); } vector pls(n+1); pls[0] = 0; ll tot = 0, ans = 0; rep(i,n){ tot += pq.top(); pq.pop(); pls[i+1] = tot; } cin >> k; rep(i,k){ int c; cin >> c; ans += pls[c]; } cout << ans << endl; return 0; }