#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios {
  fast_ios() {
    cin.tie(nullptr), ios::sync_with_stdio(false),
        cout << fixed << setprecision(20);
  };
} fast_ios_;
template <typename T, typename V>
void ndarray(vector<T>& vec, const V& val, int len) {
  vec.assign(len, val);
}
template <typename T, typename V, typename... Args>
void ndarray(vector<T>& vec, const V& val, int len, Args... args) {
  vec.resize(len),
      for_each(begin(vec), end(vec), [&](T& v) { ndarray(v, val, args...); });
}
template <typename T>
bool chmax(T& m, const T q) {
  return m < q ? (m = q, true) : false;
}
template <typename T>
bool chmin(T& m, const T q) {
  return m > q ? (m = q, true) : false;
}
template <typename T1, typename T2>
pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) {
  return make_pair(l.first + r.first, l.second + r.second);
}
template <typename T1, typename T2>
pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) {
  return make_pair(l.first - r.first, l.second - r.second);
}
template <typename T>
vector<T> srtunq(vector<T> vec) {
  return sort(vec.begin(), vec.end()),
         vec.erase(unique(vec.begin(), vec.end()), vec.end()), vec;
}
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
  return for_each(begin(vec), end(vec), [&](T& v) { is >> v; }), is;
}
template <typename T, typename V>
ostream& dmpseq(ostream&, const T&, const string&, const string&,
                const string&);
template <typename T1, typename T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& p) {
  return os << '(' << p.first << ',' << p.second << ')';
}
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& x) {
  return dmpseq<vector<T>, T>(os, x, "[", ",", "]");
}
template <typename T>
ostream& operator<<(ostream& os, const deque<T>& x) {
  return dmpseq<deque<T>, T>(os, x, "deq[", ",", "]");
}
template <typename T>
ostream& operator<<(ostream& os, const set<T>& x) {
  return dmpseq<set<T>, T>(os, x, "{", ",", "}");
}
template <typename T, typename TH>
ostream& operator<<(ostream& os, const unordered_set<T, TH>& x) {
  return dmpseq<unordered_set<T, TH>, T>(os, x, "{", ",", "}");
}
template <typename T>
ostream& operator<<(ostream& os, const multiset<T>& x) {
  return dmpseq<multiset<T>, T>(os, x, "{", ",", "}");
}
template <typename TK, typename T>
ostream& operator<<(ostream& os, const map<TK, T>& x) {
  return dmpseq<map<TK, T>, pair<TK, T>>(os, x, "{", ",", "}");
}
template <typename TK, typename T, typename TH>
ostream& operator<<(ostream& os, const unordered_map<TK, T, TH>& x) {
  return dmpseq<unordered_map<TK, T, TH>, pair<TK, T>>(os, x, "{", ",", "}");
}
template <typename T, typename V>
ostream& dmpseq(ostream& os, const T& seq, const string& pre, const string& sp,
                const string& suf) {
  return os << pre, for_each(begin(seq), end(seq), [&](V x) { os << x << sp; }),
         os << suf;
}
template <typename T>
void print(const vector<T>& x) {
  dmpseq<vector<T>, T>(cout, x, "", " ", "\n");
}
struct UnionFind {
  std::vector<int> par, cou;
  UnionFind(int N = 0) : par(N), cou(N, 1) { iota(par.begin(), par.end(), 0); }
  int find(int x) { return (par[x] == x) ? x : (par[x] = find(par[x])); }
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if (x == y) return false;
    if (cou[x] < cou[y]) std::swap(x, y);
    par[y] = x, cou[x] += cou[y];
    return true;
  }
  int count(int x) { return cou[find(x)]; }
  bool same(int x, int y) { return find(x) == find(y); }
};
int main() {
  int M, N;
  cin >> M >> N;
  vector<int> a(M), b(N);
  cin >> a >> b;
  vector<vector<int>> S(M);
  lint total_cost = 0;
  vector<pair<int, pint>> ws;
  for (int m = (0), m_end_ = (M); m < m_end_; m++) {
    int sz;
    cin >> sz;
    S[m].resize(sz);
    cin >> S[m];
    for (auto& x : S[m]) x--;
    for (auto i : S[m]) {
      ws.emplace_back(b[i] + a[m], make_pair(i, N + m));
      total_cost += b[i] + a[m];
    }
  }
  {};
  {};
  sort(ws.rbegin(), ws.rend());
  UnionFind uf(N + M);
  for (auto [w, p] : ws) {
    auto [i, j] = p;
    if (uf.unite(i, j)) total_cost -= w;
  }
  cout << total_cost << '\n';
}
