#include <bits/stdc++.h>
using namespace std;
mt19937_64 rng(
    (unsigned)chrono::system_clock::now().time_since_epoch().count());
const long double error = 1e-7;
const long double PI = acosl(-1);
const int nmax = 2e5 + 10;
int master[nmax];
int sz[nmax];
void init(int u) {
  master[u] = u;
  sz[u] = 1;
  return;
}
int fnd(int u) {
  if (master[u] == u) return u;
  return master[u] = fnd(master[u]);
}
bool unite(int u, int v) {
  u = fnd(u);
  v = fnd(v);
  if (u == v) return false;
  if (sz[u] < sz[v]) swap(u, v);
  sz[u] += sz[v];
  master[v] = u;
  return true;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int n, m;
  cin >> n >> m;
  vector<long long int> A(n + 1), B(m + 1);
  for (int i = 1; i <= n; i++) {
    cin >> A[i];
  }
  for (int i = 1; i <= m; i++) {
    cin >> B[i];
  }
  vector<pair<long long int, pair<int, int>>> edges;
  long long int totcost = 0;
  for (int i = 1; i <= n; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int x;
      cin >> x;
      edges.emplace_back(A[i] + B[x], make_pair(i, n + x));
      totcost += A[i] + B[x];
    }
  }
  for (int i = 1; i <= n + m; i++) init(i);
  sort(edges.begin(), edges.end());
  reverse(edges.begin(), edges.end());
  long long int ans = 0;
  for (auto e : edges) {
    if (unite(e.second.first, e.second.second)) ans += e.first;
  }
  ans = totcost - ans;
  cout << ans << endl;
  return 0;
}
