#include <bits/stdc++.h>
using namespace std;
const int N = 250000 + 5;
const int M = 10000000 + 5;
struct dom {
  int k;
  vector<int> h, c;
} g[N];
int rl[M], rr[M], h[M];
long long c[M], resp[M];
int sz = 0;
long long get(int p) { return p == -1 ? 0ll : resp[p]; }
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d", &g[i].k);
    vector<int> ht(g[i].k), ct(g[i].k);
    for (int j = 0; j < g[i].k; j++) scanf("%d", &ht[j]);
    for (int j = 0; j < g[i].k; j++) scanf("%d", &ct[j]);
    g[i].h = ht;
    g[i].c = ct;
  }
  int q;
  scanf("%d", &q);
  while (q--) {
    int id;
    long long mul;
    scanf("%d %lld", &id, &mul);
    id--;
    for (int j = 0; j < g[id].k; j++) {
      h[sz] = g[id].h[j];
      c[sz] = (long long)g[id].c[j] * mul;
      sz++;
    }
  }
  long long inf = numeric_limits<long long>::max() / 10ll;
  for (int i = 0; i < sz; i++) resp[i] = c[i] + (i == 0 ? 0 : resp[i - 1]);
  stack<int> s({0});
  for (int i = 1; i < sz; i++) {
    while (s.size() && s.top() + h[s.top()] <= i) {
      rr[s.top()] = i;
      s.pop();
    }
    s.push(i);
  }
  while (s.size()) {
    rr[s.top()] = sz;
    s.pop();
  }
  s.push(sz - 1);
  for (int i = sz - 2; i >= 0; i--) {
    while (s.size() && s.top() - h[s.top()] >= i) {
      rl[s.top()] = i;
      s.pop();
    }
    s.push(i);
  }
  while (s.size()) {
    rl[s.top()] = -1;
    s.pop();
  }
  s.push(-1);
  for (int i = 0; i < sz; i++) {
    int rli = rl[i], rri = rr[i];
    int best = s.top();
    while (true) {
      int last = s.top();
      s.pop();
      long long r = get(last);
      if (rli <= last) {
        resp[i] = min(resp[i], r + c[i]);
        if (r < get(best)) best = last;
      } else {
        s.push(last);
        s.push(best);
        break;
      }
      if (s.size() == 0) {
        s.push(best);
        break;
      }
    }
    s.push(i);
    int nxt = rri - 1;
    resp[nxt] = min(resp[nxt], get(i - 1) + c[i]);
  }
  printf("%lld\n", resp[sz - 1]);
  return 0;
}
