#include <bits/stdc++.h>
using namespace std;
const int N = 555;
int n, k;
int h[20];
map<int, pair<int, int>> m;
long long ans = 0;
int dp[N][10 * N];
int dpsolve(int people, int cards) {
  if (people == 0 || cards == 0) return 0;
  cards = min(people * k, cards);
  if (dp[people][cards] != 0) return dp[people][cards];
  int &ref = dp[people][cards];
  for (int i = 0; i <= min(cards, k); i++) {
    ref = max(ref, h[i] + dpsolve(people - 1, cards - i));
  }
  return ref;
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n * k; i++) {
    int c;
    scanf("%d", &c);
    m[c].second++;
  }
  for (int i = 0; i < n; i++) {
    int f;
    scanf("%d", &f);
    m[f].first++;
  }
  for (int i = 1; i <= k; i++) {
    scanf("%d", &h[i]);
  }
  for (auto &p : m) {
    ans += dpsolve(p.second.first, p.second.second);
  }
  cout << ans << endl;
  return 0;
}
