#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 6;
const long long inc = 1e5;
const long long mod = 1e9;
long long n, m, a[N], b[N], i, lab[N], sum, ans, k, x;
long long Find(long long u) {
  if (lab[u] < 0) return u;
  return lab[u] = Find(lab[u]);
}
void Union(long long r, long long s) {
  if (lab[r] > lab[s]) swap(r, s);
  lab[r] += lab[s];
  lab[r] = s;
}
struct Edge {
  long long u, v, val;
};
bool lf(Edge x, Edge y) { return x.val > y.val; }
vector<Edge> v;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  if (fopen("tst"
            ".inp",
            "r")) {
    freopen(
        "tst"
        ".inp",
        "r", stdin);
  }
  cin >> m >> n;
  memset(lab, -1, sizeof(lab));
  for (i = 1; i <= m; i++) cin >> a[i];
  for (i = 1; i <= n; i++) cin >> b[i];
  long long cc = m + n;
  for (i = 1; i <= m; i++) {
    cin >> k;
    while (k--) {
      cin >> x;
      v.push_back({i + inc, x, a[i] + b[x]});
      ans += a[i] + b[x];
    }
  }
  sort(v.begin(), v.end(), lf);
  for (auto i : v) {
    long long r = Find(i.u), s = Find(i.v), val = i.val;
    if (r != s) {
      Union(r, s);
      ans -= val;
    }
  }
  cout << ans;
}
