#include <bits/stdc++.h>
using namespace std;
const long long ThaoNguyen = 1e5 + 5, mod = 1e9 + 7;
long long dp[5005][15], n, k, h[12], getmax[505][5005];
long long cnt[ThaoNguyen], cntfav[ThaoNguyen];
signed main() {
  cin >> n >> k;
  for (long long i = 1; i <= n * k; i++) {
    long long temp;
    cin >> temp;
    cnt[temp]++;
  }
  for (long long i = 1; i <= n; i++) {
    long long temp;
    cin >> temp;
    cntfav[temp]++;
  }
  for (long long i = 1; i <= k; i++) {
    cin >> h[i];
  }
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= i * k; j++) {
      for (long long cnt = 0; cnt <= min(k, j); cnt++) {
        dp[j][cnt] = getmax[i - 1][j - cnt] + h[cnt];
        getmax[i][j] = max(getmax[i][j], dp[j][cnt]);
      }
    }
  }
  long long ans = 0;
  for (long long i = 1; i < ThaoNguyen; i++) {
    if (cntfav[i] > 0) {
      ans += getmax[cntfav[i]][min(cnt[i], cntfav[i] * k)];
    }
  }
  cout << ans;
}
