#include <bits/stdc++.h>
using namespace std;
long long fastSolution(const vector<pair<long long, long long> >& input) {
  long long m = input.size();
  vector<long long> toRight;
  toRight.resize(m);
  toRight[m - 1] = m - 1;
  stack<pair<long long, long long> > sRight;
  sRight.push(make_pair(m - 1, m - 1));
  for (long long i = m - 2; i >= 0; --i) {
    auto maxRight = i;
    auto move = min(m - 1, i + input[i].first - 1);
    while (!sRight.empty()) {
      auto top = sRight.top();
      if (move >= top.first) {
        maxRight = max(maxRight, top.second);
        sRight.pop();
      } else {
        break;
      }
    }
    while (!sRight.empty() && sRight.top().second < maxRight) {
      sRight.pop();
    }
    sRight.push(make_pair(i, maxRight));
    toRight[i] = maxRight;
  }
  vector<long long> dp;
  dp.resize(m);
  dp[0] = input[0].second;
  stack<pair<long long, long long> > toLeftStack;
  toLeftStack.push(make_pair(0, 0));
  stack<pair<long long, long long> > toRightStack;
  toRightStack.push(make_pair(toRight[0], input[0].second));
  for (long long i = 1; i < m; ++i) {
    auto curToLeft = max(i - (input[i].first - 1), (long long)0);
    auto toLeftMin = dp[i - 1];
    while (!toLeftStack.empty()) {
      auto top = toLeftStack.top();
      if (top.first < curToLeft) {
        break;
      } else {
        toLeftStack.pop();
        toLeftMin = min(toLeftMin, top.second);
      }
    }
    while (!toLeftStack.empty() && toLeftStack.top().second > toLeftMin) {
      toLeftStack.pop();
    }
    toLeftStack.push(make_pair(i, toLeftMin));
    dp[i] = toLeftMin + input[i].second;
    while (!toRightStack.empty() && toRightStack.top().first < i) {
      toRightStack.pop();
    }
    if (!toRightStack.empty()) {
      dp[i] = min(toRightStack.top().second, dp[i]);
    }
    if (input[i].first > 1) {
      auto newToRightValue = dp[i - 1] + input[i].second;
      if (toRightStack.empty() || newToRightValue < toRightStack.top().second) {
        toRightStack.push(make_pair(toRight[i], newToRightValue));
      }
    }
  }
  return dp[m - 1];
}
int main() {
  int n, m, q;
  scanf("%d %d", &n, &m);
  vector<pair<long long, long long> > blocks;
  vector<long long> heights;
  vector<long long> costs;
  blocks.resize(n);
  long long pointer = 0;
  for (long long i = 0; i < n; ++i) {
    int k;
    scanf("%d", &k);
    blocks[i].first = pointer;
    blocks[i].second = k;
    int h;
    for (long long j = 0; j < k; ++j) {
      scanf("%d", &h);
      heights.push_back(h);
    }
    int c;
    for (long long j = 0; j < k; ++j) {
      scanf("%d", &c);
      costs.push_back(c);
    }
    pointer += k;
  }
  scanf("%d", &q);
  vector<pair<long long, long long> > input;
  input.reserve(m);
  for (long long i = 0; i < q; ++i) {
    int id, mul;
    scanf("%d %d", &id, &mul);
    --id;
    for (long long j = 0; j < blocks[id].second; ++j) {
      long long c = blocks[id].first + j;
      input.push_back(make_pair(heights[c], costs[c] * mul));
    }
  }
  cout << fastSolution(input) << endl;
}
