#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  vector<long long> b(m);
  vector<vector<int>> x(n, vector<int>());
  vector<vector<int>> y(n, vector<int>());
  for (int i = 0; i < n; ++i) {
    int k;
    cin >> k;
    x[i].resize(k);
    y[i].resize(k);
    for (int j = 0; j < k; ++j) cin >> x[i][j];
    for (int j = 0; j < k; ++j) cin >> y[i][j];
  }
  int q;
  cin >> q;
  int nxt = 0;
  for (int i = 0; i < q; ++i) {
    int id, mul;
    cin >> id >> mul;
    --id;
    for (int j = 0; j < x[id].size(); ++j) {
      a[nxt] = x[id][j];
      b[nxt] = (long long)y[id][j] * mul;
      ++nxt;
    }
  }
  vector<int> pos(m);
  vector<int> stk;
  for (int i = 0; i < m; ++i) {
    int r = max(i - a[i] + 1, 0);
    while (stk.size() > 0 && stk.back() >= r) {
      r = min(r, pos[stk.back()]);
      stk.pop_back();
    }
    stk.push_back(i);
    pos[i] = r;
  }
  vector<int> pos2(m);
  stk.clear();
  for (int i = m - 1; i >= 0; --i) {
    int r = min(i + a[i] - 1, m - 1);
    while (stk.size() > 0 && stk.back() <= r) {
      r = max(r, pos2[stk.back()]);
      stk.pop_back();
    }
    stk.push_back(i);
    pos2[i] = r;
  }
  vector<long long> dp(m);
  stk.clear();
  vector<long long> right(m);
  for (int i = 0; i < m; ++i) {
    while (stk.size() > 0 && pos2[stk.back()] < i) stk.pop_back();
    long long t = b[i];
    if (i > 0) t += dp[i - 1];
    if (stk.size() > 0) {
      if (t < right[stk.back()]) {
        stk.push_back(i);
      } else {
        t = right[stk.back()];
      }
    } else {
      stk.push_back(i);
    }
    right[i] = t;
    t = min(t, (pos[i] == 0 ? 0 : dp[pos[i] - 1]) + b[i]);
    dp[i] = t;
  }
  cout << dp[m - 1] << endl;
  return 0;
}
