#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int fa[100001];
inline int get(int x) { return fa[x] == x ? x : fa[x] = get(fa[x]); }
int main() {
  int m, n;
  cin >> m >> n;
  vector<int> a(m), b(n);
  for (int i = 0; i < (m); i++) cin >> a[i];
  for (int i = 0; i < (n); i++) cin >> b[i];
  vector<vector<int>> e(m);
  for (int i = 0; i < (m); i++) {
    int s;
    cin >> s;
    for (int j = 0; j < (s); j++) {
      int te;
      cin >> te;
      te--;
      e[i].push_back(te);
    }
  }
  for (int i = 0; i < (n); i++) fa[i] = i;
  vector<pair<int, P>> ppv;
  for (int i = 0; i < (m); i++)
    for (int j : e[i]) ppv.push_back(make_pair(a[i] + b[j], make_pair(i, j)));
  sort(ppv.rbegin(), ppv.rend());
  vector<int> par(m, -1);
  ll tot = 0;
  for (auto pp : ppv) {
    int c = pp.first, i = pp.second.first, j = pp.second.second;
    bool cut = false;
    if (par[i] == -1)
      par[i] = j;
    else {
      int u = get(par[i]), v = get(j);
      if (u != v)
        fa[v] = u;
      else
        cut = true;
    }
    if (cut) tot += c;
  }
  cout << tot << endl;
  return 0;
}
