#include <bits/stdc++.h>
using namespace std;
template <class T1, class T2>
bool umin(T1& a, T2 b) {
  return a > b ? (a = b, true) : false;
}
template <class T1, class T2>
bool umax(T1& a, T2 b) {
  return a < b ? (a = b, true) : false;
}
template <class T>
void clear(T& a) {
  T().swap(a);
}
const int N = 1e5 + 5;
int n, m, _, k, t;
int a[N], b[N], f[N << 1], high[N << 1], tot;
pair<int, pair<int, int> > edge[N << 1];
int find(int x) { return f[x] == x ? x : f[x] = find(f[x]); }
bool unit(int x, int y) {
  x = find(x), y = find(y);
  if (x == y) return 0;
  if (high[x] > high[y])
    f[y] = x;
  else if (high[x] < high[y])
    f[x] = y;
  else
    f[y] = x, ++high[x];
  return 1;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cin >> m >> n;
  tot = 0;
  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)
    for (cin >> k; k; --k) cin >> t, edge[++tot] = {a[i] + b[t], {i, m + t}};
  sort(edge + 1, edge + 1 + tot);
  for (int i = (1); i <= (m + n); ++i) f[i] = i, high[i] = 1;
  long long ans = 0;
  for (int i = (tot); i >= (1); --i)
    if (find(edge[i].second.first) != find(edge[i].second.second))
      unit(edge[i].second.first, edge[i].second.second);
    else
      ans += edge[i].first;
  cout << ans << '\n';
  return 0;
}
