#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int color[N], like[N], h[N], f[507][5007];
int n, k, x;
int main() {
  cin >> n >> k;
  for (int i = 1; i <= n * k; i++) {
    cin >> x;
    color[x]++;
  }
  for (int i = 1; i <= n; i++) {
    cin >> x;
    like[x]++;
  }
  for (int i = 1; i <= k; i++) {
    cin >> h[i];
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= i * k; j++) {
      for (int cur = 0; cur <= k; cur++) {
        if (j >= cur) f[i][j] = max(f[i][j], f[i - 1][j - cur] + h[cur]);
      }
    }
  }
  int ans = 0;
  for (int i = 1; i <= 100000; i++) {
    if (!like[i]) continue;
    int num = min(color[i], like[i] * k);
    ans += f[like[i]][num];
  }
  cout << ans << endl;
  return 0;
}
