#include <bits/stdc++.h>
using namespace std;
template <class S, class T>
pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) {
  return pair<S, T>(s.first + t.first, s.second + t.second);
}
template <class S, class T>
pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) {
  return pair<S, T>(s.first - t.first, s.second - t.second);
}
template <class S, class T>
ostream &operator<<(ostream &os, pair<S, T> p) {
  os << "(" << p.first << ", " << p.second << ")";
  return os;
}
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const long long inf = 1000000001;
const long long INF = 2e18;
const long long MOD = 1000000007;
const double pi = 3.14159265358979323846;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dx2[8] = {1, 1, 0, -1, -1, -1, 0, 1}, dy2[8] = {0, 1, 1, 1, 0, -1, -1, -1};
int main() {
  int n, k;
  cin >> n >> k;
  vector<long long> _c(k * n);
  vector<int> c_num(100010), p_num(100010);
  for (long long i = 0; i < (long long)(k * n); i++) {
    cin >> _c[i];
    _c[i]--;
    c_num[_c[i]]++;
  }
  vector<long long> f(n);
  for (long long i = 0; i < (long long)(n); i++) {
    cin >> f[i];
    f[i]--;
    p_num[f[i]]++;
  }
  vector<long long> h(k + 1);
  for (long long i = 1; i <= (long long)(k); i++) {
    cin >> h[i];
  }
  vector<vector<long long> > dp(n + 1, vector<long long>(n * k + 1, -INF));
  dp[0][0] = 0;
  for (long long i = 0; i < (long long)(n); i++) {
    for (long long j = 0; j < (long long)(n * k + 1); j++) {
      for (long long l = 0; l < (long long)(k + 1); l++) {
        if (j + l > n * k) {
          break;
        }
        chmax(dp[i + 1][j + l], dp[i][j] + h[l]);
      }
    }
  }
  int nokori = 0;
  long long ans = 0;
  for (long long i = 0; i < (long long)(100000); i++) {
    long long c = c_num[i], p = p_num[i];
    if (c == 0) {
      continue;
    }
    if (c >= p * k) {
      ans += h[k] * p;
      nokori += c - p * k;
      continue;
    }
    ans += dp[p][c];
  }
  cout << ans << endl;
}
