#include <bits/stdc++.h>
int c[100100], f[100100], h[11], dp[550][5050];
int n, k;
int solve(int x) {
  for (int i = 1; i <= f[x]; i++) {
    for (int j = 1; j <= c[x]; j++) {
      dp[i][j] = 0;
      for (int l = 1; l <= j && l <= k; l++)
        if (dp[i][j] < dp[i - 1][j - l] + h[l])
          dp[i][j] = dp[i - 1][j - l] + h[l];
    }
  }
  return dp[f[x]][c[x]];
}
int main() {
  scanf("%d%d", &n, &k);
  int x;
  for (int i = 1; i <= n * k; i++) {
    scanf("%d", &x);
    c[x]++;
  }
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x);
    f[x]++;
  }
  for (int i = 1; i <= k; i++) scanf("%d", &h[i]);
  int res = 0;
  for (int i = 1; i <= 100000; i++)
    if (f[i]) res += solve(i);
  printf("%d", res);
  return 0;
}
