#include <bits/stdc++.h>
using namespace std;
const long long MOD = (long long)1e18 + 7;
const int inf = (int)1e9 + 7;
const double eps = 1e-7;
const double pi = 3.14159265359;
int n, k, c, f, h[11], ans;
int cnt_cards[100001], cnt_favorites[100001];
int dp[501][5001];
bool use_pos[501][5001];
int d(int people, int cards) {
  if (people == 0 || cards == 0) return 0;
  if (!use_pos[people][cards]) {
    use_pos[people][cards] = true;
    int res = 0;
    for (int i = 0; i < min(cards, k) + 1; ++i)
      res = max(res, h[i] + d(people - 1, cards - i));
    dp[people][cards] = res;
  }
  return dp[people][cards];
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n * k; ++i) {
    scanf("%d", &c);
    ++cnt_cards[c];
  }
  for (int i = 0; i < n; ++i) {
    scanf("%d", &f);
    ++cnt_favorites[f];
  }
  for (int i = 0; i < k; ++i) scanf("%d", &h[i + 1]);
  for (int i = 1; i <= 100000; ++i)
    ans += d(cnt_favorites[i], min(cnt_cards[i], cnt_favorites[i] * k));
  printf("%d", ans);
  return 0;
}
