#include <bits/stdc++.h>
#define fast ios::sync_with_stdio(0), cin.tie(nullptr)
#define all(v) (v).begin(), (v).end()
#define compress(v) sort(all(v)), (v).erase(unique(all(v)), (v).end());
#define sq(n) ((n)*(n))
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using tii = tuple<int, int, int>;
using tll = tuple<ll, ll, ll>;
const ll S = 1e5 + 5, MOD = 1e9 + 7, D = 607, MAX = 0x3f3f3f3f3f3f3f3f;
struct Qry{
int A, B, C, idx;
bool operator<(Qry& a){
return C > a.C;
}
};
struct st{
int a, b, idx;
};
struct fenwick{
int _t[200001];
int query(int x){
int ret = 0;
for (; x <= 200000; x += (x&-x))
ret += _t[x];
return ret;
}
void update(int x){
for (; x; x -= (x&-x))
_t[x]++;
}
} tree[105];
const int SZ = 2500;
int N, Q, ans[S];
vector<int> b_comp;
int main() {
fast;
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
#else
#define endl '\n'
#endif
cin >> N >> Q;
vector<st> stu(N), aa;
for (auto&[a,b,i] : stu){
cin >> a >> b;
b_comp.push_back(b);
}
vector<Qry> qs(Q);
for(int i = 0; i < Q; i++){
auto&[a,b,c,idx] = qs[i];
cin >> a >> b >> c;
b_comp.push_back(b);
idx = i;
}
compress(b_comp);
sort(all(qs));
sort(all(stu), [](st& a, st& b){ return a.a < b.a; });
aa = stu;
for (int i = 0; i < N; i++){
stu[i].idx = i;
}
sort(all(stu), [](st& a, st& b){ return a.a+a.b > b.a+b.b; });
int idx = 0;
for (auto&[a,b,c,i] : qs){
while (idx < stu.size() and stu[idx].a + stu[idx].b >= c){
int ii = lower_bound(all(b_comp), stu[idx].b) - b_comp.begin();
tree[stu[idx].idx/SZ].update(ii+1);
idx++;
}
st tmp = {a,0,0};
int a_idx = lower_bound(all(aa), tmp, [](st a, st b){ return a.a < b.a; }) - aa.begin();
for (; a_idx % SZ and a_idx < N; a_idx++) ans[i] += aa[a_idx].a + aa[a_idx].b >= c and aa[a_idx].b >= b;
int ii = lower_bound(all(b_comp), b) - b_comp.begin();
for (; a_idx < N; a_idx += SZ) ans[i] += tree[a_idx / SZ].query(ii+1);
}
for (int i = 0; i < Q; i++) cout << ans[i] << '\n';
}