#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 50;
int n, k, num, ans = 0;
int c[maxn];
int f[maxn];
int h[15];
int dp[maxn][505];
int main() {
  cin >> n >> k;
  memset(dp, 0, sizeof(dp));
  memset(c, 0, sizeof(c));
  memset(f, 0, sizeof(f));
  for (int i = 1; i <= n * k; i++) {
    cin >> num;
    c[num]++;
  }
  for (int i = 1; i <= n; i++) {
    cin >> num;
    f[num]++;
  }
  for (int i = 1; i <= k; i++) {
    cin >> h[i];
  }
  for (int i = 1; i <= n * k; i++) {
    dp[i][1] = h[min(k, i)];
    for (int j = 2; j <= n; j++) {
      for (int z = 1; i - z >= 0 && z <= k; z++) {
        dp[i][j] = max(dp[i][j], dp[i - z][j - 1] + h[z]);
      }
    }
  }
  for (int i = 1; i < maxn; i++) {
    if (f[i] != 0 && c[i] != 0) {
      ans += dp[c[i]][f[i]];
    }
  }
  cout << ans << endl;
  return 0;
}
