#include <bits/stdc++.h>
using namespace std;
template <typename T>
vector<T>& operator--(vector<T>& v) {
  for (auto& i : v) --i;
  return v;
}
template <typename T>
vector<T>& operator++(vector<T>& v) {
  for (auto& i : v) ++i;
  return v;
}
template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
  for (auto& i : v) is >> i;
  return is;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
  for (auto& i : v) os << i << ' ';
  return os;
}
template <typename T, typename U>
istream& operator>>(istream& is, pair<T, U>& p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& p) {
  os << p.first << ' ' << p.second;
  return os;
}
template <typename T, typename U>
pair<T, U> operator-(pair<T, U> a, pair<T, U> b) {
  return make_pair(a.first - b.first, a.second - b.second);
}
template <typename T, typename U>
pair<T, U> operator+(pair<T, U> a, pair<T, U> b) {
  return make_pair(a.first + b.first, a.second + b.second);
}
template <typename T, typename U>
void umin(T& a, U b) {
  if (a > b) a = b;
}
template <typename T, typename U>
void umax(T& a, U b) {
  if (a < b) a = b;
}
struct DSU {
  vector<int> rk;
  vector<int> p;
  int n;
  DSU(int n = 1) : n(n) { reset(n); }
  void reset(int n) {
    p.resize(n);
    iota(p.begin(), p.end(), 0);
    rk.assign(n, 1);
  }
  int par(int v) { return v == p[v] ? v : p[v] = par(p[v]); }
  bool un(int u, int v) {
    u = par(u);
    v = par(v);
    if (u == v) return false;
    if (rk[u] > rk[v]) swap(u, v);
    p[u] = v;
    rk[v] += rk[u];
    return true;
  }
  bool check(int u, int v) { return par(u) == par(v); }
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m;
  cin >> n >> m;
  vector<long long> a(n + m);
  cin >> a;
  vector<vector<int>> g(n + m);
  vector<pair<long long, pair<int, int>>> e;
  for (int i = 0; i < n; ++i) {
    int k;
    cin >> k;
    for (int j = 0; j < k; ++j) {
      int u;
      cin >> u;
      --u;
      e.emplace_back(a[i] + a[u + n], make_pair(i, u + n));
    }
  }
  sort(e.rbegin(), e.rend());
  DSU d(n + m);
  long long ans = 0;
  for (auto [c, p] : e) {
    auto [u, v] = p;
    if (d.check(u, v)) {
      ans += c;
    }
    d.un(u, v);
  }
  cout << ans << '\n';
  return 0;
}
