#include <bits/stdc++.h>
using namespace std;
int M, N, s, a, b;
vector<int> A, B;
vector<vector<pair<int, int>>> S;
struct DSU {
  vector<int> p;
  DSU(int N) : p(N, -1) {}
  int get(int x) { return p[x] < 0 ? x : p[x] = get(p[x]); }
  bool sameSet(int a, int b) { return get(a) == get(b); }
  int size(int x) { return -p[get(x)]; }
  void unite(int x, int y) {
    if ((x = get(x)) == (y = get(y))) return;
    if (p[x] > p[y]) swap(x, y);
    p[x] += p[y], p[y] = x;
  }
};
int main() {
  cin >> M >> N;
  A.resize(M);
  for (int i = 0; i < (int)M; i++) cin >> A[i];
  B.resize(N);
  for (int i = 0; i < (int)N; i++) cin >> B[i];
  vector<pair<int, pair<int, int>>> E;
  for (int i = 0; i < (int)M; i++) {
    cin >> s;
    for (int _ = 0; _ < (int)s; _++) {
      cin >> a;
      a--;
      int c = A[i] + B[a];
      E.emplace_back(c, make_pair(a, i));
    }
  }
  sort(E.rbegin(), E.rend());
  DSU dsu(N + M);
  long long ans = 0;
  for (auto &e : E) {
    int i = e.second.first, j = e.second.second;
    if (!dsu.sameSet(i, N + j))
      dsu.unite(i, N + j);
    else
      ans += e.first;
  }
  cout << ans << '\n';
}
