#include <bits/stdc++.h>
using namespace std;
int cnt[5050 * 100], player[5050 * 100], n, k, h[5050];
long long dp[5050][5050];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> k;
  for (int i = (1); i <= (n * k); ++i) {
    int x;
    cin >> x;
    cnt[x]++;
  }
  for (int i = (1); i <= (n); ++i) {
    int x;
    cin >> x;
    player[x]++;
  }
  for (int i = (1); i <= (k); ++i) cin >> h[i];
  for (int i = (1); i <= (n); ++i) {
    for (int j = (1); j <= (n * k); ++j) {
      for (int z = (1); z <= (k); ++z)
        if (z <= j) {
          dp[i][j] = max(dp[i][j], dp[i - 1][j - z] + h[z]);
        }
    }
  }
  long long ans = 0;
  for (int i = (1); i <= (1e5); ++i) {
    ans += dp[player[i]][cnt[i]];
  }
  cout << ans;
}
