#include <bits/stdc++.h>
using namespace std;
int dp[5001][501];
int main() {
  for (int j = 0; j <= 500; j++) {
    dp[0][j] = 0;
  }
  int n, k;
  cin >> n >> k;
  int card_count[100005] = {0};
  for (int i = 0; i < n * k; i++) {
    int z;
    cin >> z;
    card_count[z]++;
  }
  int favorite_count[100005] = {0};
  for (int i = 1; i <= n; i++) {
    int z;
    cin >> z;
    favorite_count[z]++;
  }
  int h[k + 1];
  for (int i = 1; i <= k; i++) {
    int x;
    cin >> x;
    h[i] = x;
  }
  h[0] = 0;
  for (int i = 1; i <= k; i++) {
    dp[i][1] = h[i];
  }
  for (int i = k + 1; i <= n * k; i++) {
    dp[i][1] = h[k];
  }
  for (int i = 1; i <= 500; i++) {
    dp[1][i] = h[1];
  }
  for (int i = 2; i <= n * k; i++) {
    for (int j = 2; j <= n; j++) {
      for (int l = 0; l <= min(k, i); l++) {
        dp[i][j] = max(dp[i - l][j - 1] + h[l], dp[i][j]);
      }
    }
  }
  int happiness = 0;
  for (int i = 1; i <= 100000; i++) {
    happiness += dp[card_count[i]][favorite_count[i]];
  }
  cout << happiness;
}
