#include <bits/stdc++.h>
using namespace std;
int gi() {
  char ch = '!';
  int res = 0, f = 0;
  while (ch < '0' || ch > '9') {
    ch = getchar();
    if (ch == '-') f = 1;
  }
  while (ch >= '0' && ch <= '9') res = res * 10 + ch - '0', ch = getchar();
  return f ? -res : res;
}
const int N = 2e5 + 100;
int n, m, a[N], b[N], ce, fa[N];
struct edge {
  int a, b;
} e[N];
bool cmp(edge A, edge B) { return a[A.a] + b[A.b] > a[B.a] + b[B.b]; }
long long ans = 0;
int getfa(int x) { return fa[x] == x ? x : fa[x] = getfa(fa[x]); }
int main() {
  m = gi(), n = gi();
  for (int i = 1; i <= m; ++i) a[i] = gi();
  for (int i = 1; i <= n; ++i) b[i] = gi();
  for (int i = 1; i <= n + m; ++i) fa[i] = i;
  for (int i = 1; i <= m; ++i) {
    int s = gi(), x;
    for (int j = 1; j <= s; ++j) x = gi(), e[++ce] = (edge){i, x};
  }
  sort(e + 1, e + ce + 1, cmp);
  for (int i = 1; i <= ce; ++i) {
    int u = e[i].a, v = e[i].b + m, fu = getfa(u), fv = getfa(v);
    if (fu == fv)
      ans += a[e[i].a] + b[e[i].b];
    else
      fa[fu] = fv;
  }
  cout << ans << endl;
  return 0;
}
