#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
int m, n, a[100005], b[100005], P, f[200005];
pair<int, pair<int, int> > p[200005];
int get(int x) { return x == f[x] ? x : f[x] = get(f[x]); }
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) scanf("%d", a + i);
  for (int i = 1; i <= m; ++i) scanf("%d", b + i);
  for (int i = 1; i <= n + m; ++i) f[i] = i;
  for (int i = 1; i <= n; ++i) {
    int k;
    scanf("%d", &k);
    for (int j = 1; j <= k; ++j) {
      int x;
      scanf("%d", &x);
      p[++P] = make_pair(a[i] + b[x], make_pair(i, x + n));
    }
  }
  sort(p + 1, p + P + 1);
  long long ans = 0;
  for (int i = P; i; --i) {
    int d = p[i].first, x = p[i].second.first, y = p[i].second.second;
    if (get(x) == get(y)) {
      ans += d;
      continue;
    }
    f[f[x]] = f[y];
  }
  printf("%I64d\n", ans);
  return 0;
}
