#include <bits/stdc++.h>
using namespace std;
long long n, m;
long long val1[100010], val2[100010];
long long f[200010];
struct edge {
  long long x, y, val;
} a[200010];
long long tot;
long long sum;
bool cmp(const edge &a, const edge &b) { return a.val > b.val; }
void add(long long x, long long y, long long z) { a[++tot] = (edge){x, y, z}; }
long long getf(long long x) { return f[x] == x ? x : f[x] = getf(f[x]); }
signed main() {
  scanf("%lld%lld", &n, &m);
  for (long long i = 1; i <= n; i++) scanf("%lld", &val1[i]);
  for (long long i = 1; i <= m; i++) scanf("%lld", &val2[i]);
  for (long long i = 1; i <= n; i++) {
    long long tmp, tmp2;
    scanf("%lld", &tmp);
    for (long long j = 1; j <= tmp; j++) {
      scanf("%lld", &tmp2);
      add(i, n + tmp2, val1[i] + val2[tmp2]);
    }
  }
  sort(a + 1, a + 1 + tot, cmp);
  for (long long i = 1; i <= n + m; i++) f[i] = i;
  for (long long i = 1; i <= tot; i++) {
    if (getf(a[i].x) != getf(a[i].y))
      f[getf(a[i].x)] = getf(a[i].y);
    else
      sum += a[i].val;
  }
  printf("%lld\n", sum);
  return 0;
}
