#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cout.tie(nullptr);
  cin.tie(nullptr);
  int64_t n, m;
  cin >> n >> m;
  vector<vector<pair<int64_t, int64_t>>> blocks(n);
  for (int64_t i = 0; i < n; ++i) {
    int64_t k;
    cin >> k;
    blocks[i].resize(k);
    for (int64_t j = 0; j < k; ++j) {
      cin >> blocks[i][j].first;
    }
    for (int64_t j = 0; j < k; ++j) {
      cin >> blocks[i][j].second;
    }
  }
  vector<int64_t> height(m);
  vector<int64_t> cost(m);
  int64_t q;
  cin >> q;
  for (int64_t i = 0; q--;) {
    int64_t k, p;
    cin >> k >> p;
    --k;
    for (int64_t j = 0; j < blocks[k].size(); ++j, ++i) {
      height[i] = blocks[k][j].first;
      cost[i] = blocks[k][j].second * p;
    }
  }
  vector<int64_t> left(m);
  vector<int64_t> mn(m);
  vector<int64_t> right(m);
  for (int64_t i = m - 1; i >= 0; --i) {
    right[i] = i + 1;
    while (right[i] < m && right[i] - i < height[i]) {
      right[i] = right[right[i]];
    }
  }
  vector<int64_t> dp(m + 1, 1e17);
  for (int64_t i = 0; i < m; ++i) {
    left[i] = i - 1;
    mn[i] = i == 0 ? 0 : dp[i - 1];
    while (left[i] >= 0 && i - left[i] < height[i]) {
      mn[i] = min(mn[i], left[i] == -1 ? 0 : mn[left[i]]);
      left[i] = left[left[i]];
    }
    dp[i] = min(dp[i], cost[i] + (left[i] == -1 ? 0 : mn[i]));
    dp[right[i] - 1] =
        min(dp[right[i] - 1], (i == 0 ? 0 : dp[i - 1]) + cost[i]);
  }
  cout << dp[m - 1] << endl;
  return 0;
}
