#include <bits/stdc++.h>
using namespace std;
using LL = long long;
const int M = 1e7 + 5;
const int N = 3e5 + 5;
struct node {
  vector<int> h, c;
  node() {
    h.clear();
    c.clear();
  }
  void read(int n) {
    int ans;
    for (int i = 0; i < n; i++) {
      scanf("%d", &ans);
      h.push_back(ans);
    }
    for (int i = 0; i < n; i++) {
      scanf("%d", &ans);
      c.push_back(ans);
    }
  }
};
vector<node> a;
int h[M];
LL c[M];
int tl[M], tr[M];
LL dp[M];
stack<int> sk;
void reads(int &n) {
  int m, k, q;
  LL mul;
  scanf("%d%d", &m, &n);
  for (int i = 1; i <= m; i++) {
    scanf("%d", &k);
    node tmp;
    tmp.read(k);
    a.push_back(tmp);
  }
  scanf("%d", &q);
  n = 0;
  while (q--) {
    scanf("%d%I64d", &k, &mul);
    k--;
    for (int i = 0; i < a[k].h.size(); i++) {
      h[++n] = a[k].h[i];
      c[n] = mul * a[k].c[i];
    }
  }
}
void make_tl(int n) {
  for (int i = n; i >= 1; i--) {
    while (!sk.empty() && h[sk.top()] <= sk.top() - i) {
      tl[sk.top()] = i + 1;
      sk.pop();
    }
    sk.push(i);
  }
  while (!sk.empty()) {
    tl[sk.top()] = 1;
    sk.pop();
  }
}
void make_tr(int n) {
  for (int i = 1; i <= n; i++) {
    while (!sk.empty() && h[sk.top()] <= i - sk.top()) {
      tr[sk.top()] = i - 1;
      sk.pop();
    }
    sk.push(i);
  }
  while (!sk.empty()) {
    tr[sk.top()] = n;
    sk.pop();
  }
}
int main() {
  int n;
  reads(n);
  make_tl(n);
  make_tr(n);
  for (int i = 1; i <= n; i++) {
    dp[i] = dp[tl[i] - 1] + c[i];
    while (!sk.empty() && tr[sk.top()] < i) sk.pop();
    if (!sk.empty()) dp[i] = min(dp[i], dp[sk.top() - 1] + c[sk.top()]);
    if (sk.empty() || dp[sk.top() - 1] + c[sk.top()] > dp[i - 1] + c[i])
      sk.push(i);
  }
  printf("%I64d\n", dp[n]);
  return 0;
}
