#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
const double pi = acos(-1);
const double eps = 1e-10;
const int INF = 0x3f3f3f3f;
const long long int INFLL = 0x3f3f3f3f3f3f3f3f;
struct Edge {
  long long u, v;
  long long w;
  bool operator>(Edge s) const { return w > s.w; }
  Edge() {}
  Edge(long long u, long long v, long long w) : u(u), v(v), w(w) {}
};
vector<Edge> s;
long long a[200010];
long long b[200010];
int fa[200010];
int find(int x) {
  if (x == fa[x]) return x;
  fa[x] = find(fa[x]);
  return fa[x];
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int m, n;
  cin >> m >> n;
  for (int i = (1); i <= (m + n); i++) fa[i] = i;
  for (int i = (1); i <= (m); i++) cin >> a[i];
  for (int i = (1); i <= (n); i++) cin >> b[i];
  for (int i = (1); i <= (m); i++) {
    int sz;
    cin >> sz;
    for (int j = (1); j <= (sz); j++) {
      int v;
      cin >> v;
      s.emplace_back(i, m + v, a[i] + b[v]);
    }
  }
  sort(s.begin(), s.end(), greater<Edge>());
  long long ans = 0;
  for (auto it : s) {
    if (find(it.u) != find(it.v))
      fa[find(it.u)] = find(it.v);
    else
      ans += it.w;
  }
  cout << ans;
}
