#include <bits/stdc++.h>
using std::cerr;
using std::endl;
const int N = 1e5 + 5, INF = 1e9;
int n, m;
struct Horse {
  int s, m, r, t;
} A[N];
struct Node {
  std::vector<long long> sum, add;
  std::vector<int> ti;
  std::vector<Horse> h;
  int tag;
  inline void merge(const std::vector<Horse> &l, const std::vector<Horse> &r) {
    int n1 = l.size(), n2 = r.size(), p1 = 0, p2 = 0;
    while (p1 < n1 || p2 < n2) {
      if (p2 >= n2 || (p1 < n1 && l[p1].t <= r[p2].t)) {
        h.push_back(l[p1++]);
      } else {
        h.push_back(r[p2++]);
      }
    }
    long long s = 0, a = 0;
    for (int i = 0; i < n1 + n2; ++i) {
      s += h[i].m;
      sum.push_back(s);
      a += h[i].r;
      add.push_back(a);
      ti.push_back(h[i].t);
    }
  }
  inline long long calc(int t) {
    t -= tag;
    int p = std::lower_bound(ti.begin(), ti.end(), t) - ti.begin();
    long long ret = 0, tmp = 0;
    if (p > 0) ret += sum[p - 1], tmp -= add[p - 1];
    tmp += add.back();
    ret += tmp * t;
    return ret;
  }
} t[N * 4];
inline void pushup(int p) {
  t[p].tag = -1;
  if (t[(p << 1)].tag > 0 && t[(p << 1)].tag == t[((p << 1) | 1)].tag)
    t[p].tag = t[(p << 1)].tag;
}
inline void pushdown(int p) {
  if (t[p].tag > 0) {
    t[(p << 1)].tag = t[((p << 1) | 1)].tag = t[p].tag;
  }
}
void build(int p, int L, int R) {
  t[p].tag = -1;
  if (L == R) {
    t[p].h.push_back(A[L]);
    t[p].add.push_back(A[L].r);
    t[p].sum.push_back(A[L].m);
    t[p].ti.push_back(A[L].t);
    return;
  }
  build((p << 1), L, ((L + R) >> 1));
  build(((p << 1) | 1), ((L + R) >> 1) + 1, R);
  t[p].merge(t[(p << 1)].h, t[((p << 1) | 1)].h);
}
long long query(int p, int l, int r, int tm, int L, int R) {
  if (l <= L && r >= R && t[p].tag > 0) {
    long long ret = t[p].calc(tm);
    t[p].tag = tm;
    return ret;
  }
  if (L == R) {
    long long ret = A[L].s + 1ll * tm * A[L].r;
    ret = std::min(ret, (long long)A[L].m);
    t[p].tag = tm;
    return ret;
  }
  pushdown(p);
  long long ret = 0;
  if (l <= ((L + R) >> 1)) ret += query((p << 1), l, r, tm, L, ((L + R) >> 1));
  if (r > ((L + R) >> 1))
    ret += query(((p << 1) | 1), l, r, tm, ((L + R) >> 1) + 1, R);
  pushup(p);
  return ret;
}
int main() {
  std::ios::sync_with_stdio(0);
  std::cin.tie(0);
  std::cin >> n;
  for (int i = 1; i <= n; ++i) {
    std::cin >> A[i].s >> A[i].m >> A[i].r;
    A[i].t = A[i].r ? A[i].m / A[i].r : INF;
  }
  build(1, 1, n);
  std::cin >> m;
  while (m--) {
    int tm, l, r;
    std::cin >> tm >> l >> r;
    long long ans = query(1, l, r, tm, 1, n);
    std::cout << ans << '\n';
  }
  return 0;
}
