#include <bits/stdc++.h>
using namespace std;
int n, k;
int cnt[100100], need[100100], gt[100];
int dp[505][5005];
int solve(int idx, int rem) {
  if (rem == 0 || idx == 0) return 0;
  int& ret = dp[idx][rem];
  if (~ret) return ret;
  ret = 0;
  for (int i = 1; i <= min(rem, k); ++i) {
    ret = max(ret, solve(idx - 1, rem - i) + gt[i]);
  }
  return ret;
}
int main() {
  cin >> n >> k;
  int m = n * k;
  for (int i = 0; i < m; ++i) {
    int x;
    scanf("%d", &x);
    cnt[x]++;
  }
  for (int i = 0; i < n; ++i) {
    int x;
    scanf("%d", &x);
    need[x]++;
  }
  for (int i = 1; i <= k; ++i) scanf("%d", &gt[i]);
  int N = 1e5;
  int ans = 0;
  memset(dp, -1, sizeof dp);
  for (int i = 1; i <= N; ++i) {
    int x = cnt[i];
    int y = need[i];
    if (y == 0 || x == 0) continue;
    ans += solve(y, x);
  }
  cout << ans << endl;
  return 0;
}
