#include <bits/stdc++.h>
using namespace std;
void func(void) {
  freopen("input.c", "r", stdin);
  freopen("output.c", "w", stdout);
}
long long n, k;
const int N = 1e5 + 100;
long long cardCount[N];
long long fav[N];
long long kCount[N];
long long dp[502][5002];
long long akhon;
long long given;
vector<long long> v, favNum, kk;
long long calc(int i, long long ache) {
  if (i == 0) return 0;
  if (dp[i][ache] != -1) return dp[i][ache];
  long long dau = min(k, ache);
  long long x = 0;
  for (int j = 1; j <= dau; j++) {
    x = max(x, kCount[j] + calc(i - 1, ache - j));
  }
  return dp[i][ache] = x;
}
int main() {
  long long q, i, j = 0, temp, t, ans = 0, sum = 0, x, y, z, cnt = 0, m, fg = 0,
                  mx = 0, mx1 = 0, mn = 8000000000000000000,
                  mn1 = 8000000000000000000;
  cin >> n >> k;
  for (int i = 0; i < n * k; i++) {
    cin >> x;
    v.push_back(x);
    cardCount[x]++;
  }
  for (int i = 0; i < n; i++) {
    cin >> x;
    favNum.push_back(x);
    fav[x]++;
  }
  for (int i = 0; i < k; i++) {
    cin >> x;
    kk.push_back(x);
    kCount[i + 1] = x;
  }
  memset((dp), -1, sizeof(dp));
  for (int i = 0; i < N; i++) {
    if (fav[i]) {
      given = fav[i];
      ans += calc(given, cardCount[i]);
    }
  }
  cout << ans << endl;
}
