#include <bits/stdc++.h>
using namespace std;
vector<pair<long long, long long>> pol[300005];
long long cost_set[100005];
long long cost_num[100005];
bool odw[300005];
bool odw2[300005];
void dfs(long long a) {
  odw[a] = true;
  for (auto x : pol[a])
    if (!odw[x.first]) dfs(x.first);
}
priority_queue<pair<long long, long long>> q;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long a, b;
  cin >> a >> b;
  for (long long x = 1; x <= a; x++) cin >> cost_set[x];
  for (long long x = 1; x <= b; x++) cin >> cost_num[x];
  long long sum = 0;
  for (long long x = 1; x <= a; x++) {
    long long c;
    cin >> c;
    for (long long y = 0; y < c; y++) {
      long long d;
      cin >> d;
      pol[b + x].push_back(make_pair(d, cost_num[d] + cost_set[x]));
      pol[d].push_back(make_pair(b + x, cost_num[d] + cost_set[x]));
      sum += cost_num[d] + cost_set[x];
    }
  }
  for (long long x = b + 1; x <= b + a; x++)
    if (!odw[x]) {
      dfs(x);
      pol[x].push_back(make_pair(a + b + 1, 0));
      pol[a + b + 1].push_back(make_pair(x, 0));
    }
  q.push(make_pair(0, a + b + 1));
  while (!q.empty()) {
    long long pom = q.top().second;
    if (odw2[pom]) {
      q.pop();
      continue;
    }
    odw2[pom] = true;
    sum -= q.top().first;
    q.pop();
    for (auto x : pol[pom])
      if (!odw2[x.first]) q.push(make_pair(x.second, x.first));
  }
  cout << sum;
  return 0;
}
