#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
inline long long read1() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
const int N = 1e6 + 10;
int a[N], b[N], num, f[N];
pair<int, pair<int, int> > p[N];
int find(int x) {
  if (f[x] == x) return x;
  return f[x] = find(f[x]);
}
int main() {
  int n = read();
  int m = read();
  for (int i = 1; i <= n; i++) a[i] = read();
  for (int i = 1; i <= m; i++) b[i] = read();
  for (int i = 1; i <= n + m; i++) f[i] = i;
  for (int i = 1; i <= n; i++) {
    int ss = read();
    while (ss--) {
      int x = read();
      p[++num] = make_pair(a[i] + b[x], make_pair(i, x + n));
    }
  }
  sort(p + 1, p + num + 1);
  long long ans = 0;
  for (int i = num; i >= 0; i--) {
    int d = p[i].first, x = p[i].second.first, y = p[i].second.second;
    int u = find(x);
    int v = find(y);
    if (u == v) {
      ans += d;
      continue;
    }
    f[f[x]] = f[y];
  }
  printf("%I64d\n", ans);
  return 0;
}
