#include <bits/stdc++.h>
#pragma GCC optimize("O3", "unroll-all-loops")
#pragma GCC target("sse4.2")
using namespace std;
ifstream in;
ofstream out;
const long long kk = 1000;
const long long ml = kk * kk;
const long long mod = ml * kk + 7;
const long long inf = ml * ml * ml + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
long long n, m, ans;
vector<long long> a, b;
set<pair<long long, pair<long long, long long>>> e;
vector<long long> p, sz;
bool viv = false;
long long pp(long long v) {
  if (v == p[v]) return v;
  return p[v] = pp(p[v]);
}
void unit(long long v, long long u, long long to_add) {
  v = pp(v);
  u = pp(u);
  if (v == u) {
    ans -= to_add;
    return;
  }
  if (sz[v] < sz[u]) swap(v, u);
  sz[v] += sz[u];
  p[u] = v;
}
void adder() {
  auto mini = *e.begin();
  e.erase(mini);
  unit(mini.second.first, mini.second.second, mini.first);
}
void solve() {
  cin >> m >> n;
  a.resize(m);
  b.resize(n);
  for (auto &i : a) cin >> i;
  for (auto &i : b) cin >> i;
  for (int i = 0; i < m; i++) {
    long long k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      long long v = i;
      long long u;
      cin >> u;
      u--;
      e.insert({-(a[v] + b[u]), {v, u + m}});
    }
  }
  p.resize(n + m);
  sz.resize(n + m, 1);
  for (int i = 0; i < p.size(); i++) p[i] = i;
  while (e.size()) adder();
  cout << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) solve();
  return 0;
}
