#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("O3")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("Ofast")
using namespace std;
const int INF = 1e9 + 10;
const long long INFll = 2e18;
const int BASE1 = 179;
const int BASE2 = 653;
const long long MOD = 998244353;
const int MAXA = 2000001;
const int MAXN = 2e5 + 1;
const int MAXLOG = 22;
const long long COST = 1000 * 1000 * 1000;
const long double PI = 3.1415926535;
const long double EPS = 1e-15;
struct edge {
  long long u, v, cost;
  edge(long long a, long long b, long long c) {
    u = a;
    v = b;
    cost = c;
  }
};
bool cmp(edge& a, edge& b) { return a.cost < b.cost; }
struct dsu {
  vector<int> p, d;
  dsu(int n) {
    p.resize(n);
    d.resize(n);
    for (int i = 0; i < (n); i++) p[i] = i;
  }
  int getp(int v) {
    if (p[v] == v) return v;
    return p[v] = getp(p[v]);
  }
  void unite(int u, int v) {
    u = getp(u), v = getp(v);
    if (d[u] < d[v]) swap(u, v);
    p[v] = u;
    if (d[u] == d[v]) d[u]++;
  }
};
void solve() {
  long long m, n;
  cin >> m >> n;
  vector<long long> a(m), b(n);
  for (int i = 0; i < (m); i++) cin >> a[i];
  for (int j = 0; j < (n); j++) cin >> b[j];
  vector<edge> edges;
  long long allcost = 0;
  for (int v = 0; v < (m); v++) {
    long long s;
    cin >> s;
    for (int i = 0; i < (s); i++) {
      long long u;
      cin >> u;
      u--;
      allcost += a[v] + b[u];
      edges.emplace_back(edge(u, v + n, a[v] + b[u]));
    }
  }
  sort((edges).rbegin(), (edges).rend(), cmp);
  dsu d(n + m);
  long long res = 0;
  for (edge e : edges) {
    if (d.getp(e.u) != d.getp(e.v)) {
      res += e.cost;
      d.unite(e.u, e.v);
    }
  }
  cout << allcost - res << "\n";
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) solve();
  return 0;
}
