#include <bits/stdc++.h>
using namespace std;
const int N = 4e5 + 5;
int m, n, a[N], b[N], fa[N], sz[N];
vector<int> v[N];
struct Edge {
  int u, v;
  long long w;
};
vector<Edge> e, e1, e2;
int Find(int x) { return x == fa[x] ? x : fa[x] = Find(fa[x]); }
void Merge(int x, int y) {
  x = Find(x), y = Find(y);
  if (x == y) return;
  if (sz[x] < sz[y]) swap(x, y);
  fa[y] = x, sz[x] += sz[y];
}
int main() {
  scanf("%d%d", &m, &n);
  for (int i = 0; i < m; i++) scanf("%d", &a[i]);
  for (int i = 0; i < n; i++) scanf("%d", &b[i]);
  for (int i = 0, s, x; i < m; i++) {
    scanf("%d", &s);
    for (int j = 0; j < s; j++) {
      scanf("%d", &x), x--, v[i].push_back(x);
      e.push_back((Edge){i, x + m, a[i] + b[x]});
    }
  }
  sort(e.begin(), e.end(), [&](Edge x, Edge y) { return x.w > y.w; });
  for (int i = 0; i < m + n; i++) fa[i] = i, sz[i] = 1;
  long long ans = 0;
  for (auto i : e) {
    int u = i.u, v = i.v;
    long long w = i.w;
    if (Find(u) == Find(v)) {
      ans += w;
      e2.push_back(i);
      continue;
    }
    Merge(u, v);
    e1.push_back(i);
  }
  printf("%lld\n", ans);
  return 0;
}
