#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int MOD = 1e9 + 7;
const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0};
const char dir[] = {'R', 'L', 'D', 'U'};
ll add(ll a, ll b) {
  a += b;
  if (a >= MOD) {
    a -= MOD;
  }
  return a;
}
int sub(int a, int b) {
  a -= b;
  if (a < 0) a += MOD;
  return a;
}
int mult(int a, int b) { return ((ll)a * b) % MOD; }
void setIO() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}
struct union_find {
  vector<int> par;
  vector<int> sz;
  union_find(int n) {
    par.resize(n);
    sz.assign(n, 1);
    iota(par.begin(), par.end(), 0);
  }
  int find(int u) {
    if (par[u] != u) {
      par[u] = find(par[u]);
    }
    return par[u];
  }
  bool unite(int u, int v) {
    u = find(u);
    v = find(v);
    if (u == v) return false;
    if (sz[u] > sz[v]) {
      swap(u, v);
    }
    par[u] = v;
    sz[v] += sz[u];
    return true;
  }
};
bool comp(pair<int, pii> a, pair<int, pii> b) { return a.first > b.first; }
int main() {
  setIO();
  int m, n;
  cin >> m >> n;
  vector<pair<int, pii>> edges;
  int a[m], b[n];
  for (int i = 0; i < m; ++i) {
    cin >> a[i];
  }
  for (int i = 0; i < n; ++i) {
    cin >> b[i];
  }
  ll totCost = 0;
  for (int i = 0; i < m; ++i) {
    int sz;
    cin >> sz;
    for (int j = 0; j < sz; ++j) {
      int nd;
      cin >> nd;
      --nd;
      totCost += a[i] + b[nd];
      edges.emplace_back(make_pair(a[i] + b[nd], make_pair(nd, i + n)));
    }
  }
  sort((edges).begin(), (edges).end(), comp);
  union_find uf(n + m);
  for (auto i : edges) {
    if (uf.unite(i.second.first, i.second.second)) {
      totCost -= i.first;
    }
  }
  cout << totCost << "\n";
}
