#include <bits/stdc++.h>
using namespace std;
int n, k, cnt[100015], a[500], p[15], f[515][100015], res;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  for (int i = 0, x; i < n * k; i++) cin >> x, cnt[x]++;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  for (int i = 1; i <= k; i++) cin >> p[i];
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n * k; j++)
      for (int x = 0; x <= min(j, k); x++)
        f[i][j] = max(f[i][j], f[i - 1][j - x] + p[x]);
  for (int i = 0, j; i < n; i = j) {
    for (j = i + 1; j < n && a[i] == a[j]; j++)
      ;
    res += f[j - i][cnt[a[i]]];
  }
  cout << res;
}
