#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<vector> 
#include<cstring>
#include<string>
#define mp make_pair
#define scn second
#define frs first
#define pb push_back
#define NAME "hotels"
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pi;
void dout() { cerr << endl; }
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
  cerr << H << ' ';
  dout(T...);
}
struct abc {
    ll k, b;
    abc() {k = b = 0;}
    abc(ll K, ll B) {
        k = K, b = B;
    }
};
const ll INF = 1000000000000000000ll;

abc line[100010];


ll n, l, r, k;
ll dp[100][1100];

int main(){
	freopen(NAME ".in", "r", stdin); 
	freopen(NAME".out", "w", stdout);
	scanf("%I64d", &n);
	for (int i = 0; i < n; ++i)
		scanf("%I64d%I64d", &line[i].b, &line[i].k);
	ll t1;	
	scanf("%I64d", &t1);                                     
	while (t1 --> 0) {
	    scanf("%I64d%I64d%I64d", &l, &r, &k);
	    --l;
	    for (int i = 0; i < 100; ++i)
			for (int j = 0; j < 1000; ++j)
				dp[i][j] = INF;
		dp[l][0] = 0;
		for (int i = l; i < r; ++i) {
			for (int have = 0; have <= 100; ++have)
				dp[i + 1][have] = dp[i][have];
			for (int have = 0; have <= 100; ++have)
				for (int now = 1; now <= 100; ++now) {				
					dp[i + 1][have + now] = min(min(dp[i + 1][have + now], dp[i][have] + have * line[i].k + line[i].k * (now-1) + line[i].b), dp[i][have + now]);		 
		    	} 
    	}		
	    printf("%I64d\n", dp[r][k]);		
	}	 
	return 0;
}