#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0;
  char ch = getchar();
  bool positive = 1;
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') positive = 0;
  for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
  return positive ? x : -x;
}
inline void write(long long a) {
  if (a >= 10) write(a / 10);
  putchar('0' + a % 10);
}
inline void writesp(long long a) {
  if (a >= 10) write(a / 10);
  putchar('0' + a % 10);
  printf(" ");
}
inline void writeln(long long a) {
  if (a < 0) {
    a = -a;
    putchar('-');
  }
  write(a);
  puts("");
}
long long n, m, a[500005], b[500005], p, tp, tot, now, now1, dis, now2, ans,
    f[500005];
vector<long long> p1[500005];
pair<long long, long long> c[500005];
bool Cmp(pair<long long, long long> x, pair<long long, long long> y) {
  return a[x.first] + b[x.second] > a[y.first] + b[y.second];
}
long long gf(long long k) { return (f[k] == k) ? k : (f[k] = gf(f[k])); }
void merge(long long x, long long y) { f[f[x]] = f[y]; }
signed main() {
  n = read(), m = read();
  for (long long i = 1; i <= n; i++) a[i] = read();
  for (long long i = 1; i <= m; i++) b[i] = read(), f[i] = i;
  for (long long i = 1; i <= n; i++) {
    p = read();
    for (long long j = 1; j <= p; j++)
      tp = read(), tot++, c[tot] = make_pair(i, tp);
  }
  sort(c + 1, c + tot + 1, Cmp);
  for (long long i = 1; i <= tot; i++) {
    now = c[i].first, now1 = c[i].second;
    dis = a[now] + b[now1];
    if (p1[now].size() > 0) {
      now2 = p1[now][p1[now].size() - 1];
      if (gf(now2) == gf(now1)) {
        ans += dis;
      } else {
        merge(now2, now1);
        p1[now].push_back(now1);
      }
    } else
      p1[now].push_back(now1);
  }
  writeln(ans);
}
