#include <bits/stdc++.h>
using namespace std;
const long double pi = acosl(-1);
template <class T>
bool uax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool uin(T& a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
const int N = 250250;
const int M = 10000000;
int a[M];
long long c[M];
int al[M], ar[M];
long long dp[M];
void solve(int n, bool dbg = false) {
  if (dbg) {
    for (int i = 0; i < (int)(n); ++i) cout << a[i] << " \n"[i + 1 == n];
    for (int i = 0; i < (int)(n); ++i) cout << c[i] << " \n"[i + 1 == n];
  }
  {
    vector<int> st;
    for (int i = 0; i < (int)(n); ++i) {
      int x = max(i - a[i] + 1, 0);
      while (!st.empty() && st.back() >= x) {
        x = min(x, al[st.back()]);
        st.pop_back();
      }
      al[i] = x;
      st.push_back(i);
    }
    st.clear();
    for (int i = (int)(n)-1; i >= 0; --i) {
      int x = min(i + a[i] - 1, n - 1);
      while (!st.empty() && st.back() <= x) {
        x = max(x, ar[st.back()]);
        st.pop_back();
      }
      ar[i] = x;
      st.push_back(i);
    }
  }
  for (int i = 0; i < (int)(n); ++i) dp[i] = (long long)1e18;
  if (dbg) {
    for (int i = 0; i < (int)(n); ++i) cout << al[i] << " \n"[i + 1 == n];
    for (int i = 0; i < (int)(n); ++i) cout << ar[i] << " \n"[i + 1 == n];
  }
  vector<pair<long long, int>> st;
  for (int i = 0; i < (int)(n); ++i) {
    while (!st.empty() && st.back().second < i) st.pop_back();
    if (!st.empty()) uin(dp[i], st.back().first);
    uin(dp[i], c[i] + (al[i] ? dp[al[i] - 1] : 0));
    long long w = c[i] + (i ? dp[i - 1] : 0);
    while (!st.empty() && (st.back().first >= w && st.back().second <= ar[i]))
      st.pop_back();
    if (st.empty() || (st.back().first > w && st.back().second > ar[i]))
      st.emplace_back(w, ar[i]);
    if (dbg) {
      for (int j = 0; j < (int)(st.size()); ++j)
        cout << st[j].first << ' ' << st[j].second << " \n"[j + 1 == st.size()];
    }
  }
  if (dbg) {
    for (int i = 0; i < (int)(n); ++i) cout << dp[i] << " \n"[i + 1 == n];
  }
  cout << dp[n - 1] << endl;
}
void solve() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> a0(n), c0(n);
  for (int i = 0; i < (int)(n); ++i) {
    int k;
    cin >> k;
    a0[i].resize(k);
    c0[i].resize(k);
    for (int j = 0; j < (int)(k); ++j) cin >> a0[i][j];
    for (int j = 0; j < (int)(k); ++j) cin >> c0[i][j];
  }
  int q;
  cin >> q;
  int pos = 0;
  for (int _ = 0; _ < (int)(q); ++_) {
    int id, mx;
    cin >> id >> mx;
    --id;
    for (int j = 0; j < (int)(a0[id].size()); ++j) {
      a[pos] = a0[id][j];
      c[pos] = c0[id][j] * 1ll * mx;
      ++pos;
    }
  }
  solve(m);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed;
  cout.precision(15);
  cerr << fixed;
  cerr.precision(15);
  solve();
  return 0;
}
