#include using namespace std; int main() { int N, M; long long X; cin >> N >> M >> X; typedef pair P; vector

ab( N ); for( int i = 0; i < N; i++ ) { int A, B; cin >> A >> B; ab[i] = P( A, B ); } sort( ab.begin(), ab.end(), greater

() ); set st; for( int i = 0; i < N; i++ ) { if( i == 0 ) st.insert( ab[i].second ); else if( (int)st.size() < M ) { for( int j = i + 1; j < N; j++ ) { if( st.count( ab[j].second ) == 0 ) { if( ab[i].first + X * st.size() < ab[j].first + X * (st.size() + 1) ) { st.insert( ab[j].second ); swap( ab[i], ab[j] ); i = j; break; } } } } } vector acc( N + 1 ); vector b( N + 1 ); st.clear(); for( int i = 0; i < N; i++ ) { acc[i + 1] = acc[i] + ab[i].first; st.insert( ab[i].second ); b[i + 1] = st.size(); } long long ans = 0; int K; cin >> K; for( int i = 0; i < K; i++ ) { int C; cin >> C; ans += acc[C] + X * b[C]; } cout << ans << endl; }