#include <bits/stdc++.h>
using namespace std;
struct DisjointSet {
  vector<int> p;
  DisjointSet(int size) {
    for (int i = 0; i < size; ++i) p.push_back(i);
  }
  int find(int x) {
    if (x == p[x]) {
      return x;
    } else {
      return p[x] = find(p[x]);
    }
  }
  void merge(int x, int y) { p[find(x)] = find(y); }
};
long long Kruskal(vector<vector<tuple<long long, int, int> > > vertices) {
  DisjointSet set(vertices.size());
  priority_queue<tuple<long long, int, int> > que;
  for (auto edges : vertices) {
    for (auto edge : edges) {
      que.push(edge);
    }
  }
  long long res = 0;
  while (!que.empty()) {
    tuple<long long, int, int> edge = que.top();
    que.pop();
    if (set.find(get<1>(edge)) != set.find(get<2>(edge))) {
      set.merge(get<1>(edge), get<2>(edge));
      res += get<0>(edge);
    }
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int m, n;
  cin >> m >> n;
  vector<long long> 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<tuple<long long, int, int> > > s(
      m + n, vector<tuple<long long, int, int> >());
  long long t = 0;
  for (int i = 0; i < m; i++) {
    int si;
    cin >> si;
    for (int j = 0; j < si; j++) {
      int v;
      cin >> v;
      v--;
      s[i].push_back(make_tuple(a[i] + b[v], i, v + m));
      t += a[i] + b[v];
    }
  }
  cout << t - Kruskal(s) << '\n';
}
