#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long MOD2 = 998244353;
const long long N = 2e5 + 5;
const long double pi = 3.14159265359;
long long n, k, x, cnt[N], p[N], dp[2][N], f[N], h[15], ans;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> k;
  for (long long i = 0; i < n * k; i++) cin >> x, cnt[x]++;
  for (long long i = 1; i <= n; i++) cin >> f[i], p[f[i]]++;
  for (long long i = 1; i <= k; i++) cin >> h[i];
  for (long long i = 1; i <= N; i++) {
    for (long long j = 1; j <= cnt[i]; j++) dp[0][j] = dp[1][j] = 0;
    for (long long g = 1; g <= p[i]; g++) {
      for (long long j = 1; j <= cnt[i]; j++) {
        dp[g & 1][j] = 0;
        for (long long z = 1; z <= k; z++) {
          if (j >= z)
            dp[g % 2][j] = max(dp[g % 2][j], dp[(g + 1) % 2][j - z] + h[z]);
        }
      }
    }
    ans += dp[p[i] % 2][cnt[i]];
  }
  cout << ans << "\n";
  return 0;
}
