#include "bits/stdc++.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define task ""
#define ll long long
#define endl '\n'
#define fi first
#define se second
#define vall(a) (a).begin(), (a).end()
#define sze(a) (int)a.size()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ep emplace_back
#define pb push_back
#define pf push_front
const ll mod = 1e9 + 7;
const int N = 2e5 + 5;
const ll oo = 1e18;
bool START;
int n, q;
vector<int> arr;
pii a[N];
struct node {
	int c, a, b, id;
	node(int c_, int a_, int b_, int id_) : c(c_), a(a_), b(b_), id(id_) {}
	bool operator<(const node &other) const {
		if (c == other.c) return id < other.id;
		return c > other.c;
	}
};
vector<node> sw;
int m;
struct BIT {
	int id = 0;
	ordered_set<pii> bit[N];
	void add(int idx, int val) {
		idx = lower_bound(vall(arr), idx) - arr.begin() + 1; 
		for (; idx <= m; idx += idx & -idx) bit[idx].insert(make_pair(val, id++));
	}
	int get(int idx, int val) {
		int ans = 0;
		idx = lower_bound(vall(arr), idx) - arr.begin() + 1; 
		for (; idx > 0; idx -= idx & -idx) ans += (sze(bit[idx]) - bit[idx].order_of_key(make_pair(val, -1)));
		return ans;
	}
	int get(int l, int r, int val) {
		return get(r, val) - get(l - 1, val);
	}
} bit;
int ans[N];
inline void solve() {
	sort(vall(arr));
	arr.erase(unique(vall(arr)), arr.end());
	m = sze(arr);
	sort(vall(sw));
	
	for (auto[c, a, b, id] : sw) {
		if (!id) {
			bit.add(a, b);
			continue;
		}
		ans[id] = bit.get(a, arr.back(), b);
	}
	for (int i = 1; i <= q; ++i) cout << ans[i] << endl;
}
inline void input() {
    cin >> n >> q;
    for (int i = 1; i <= n; ++i) {
    	cin >> a[i].fi >> a[i].se;
    	arr.pb(a[i].fi);
    	sw.pb(node(a[i].fi + a[i].se, a[i].fi, a[i].se, 0));
    }
    for (int i = 1; i <= q; ++i) {
    	int a, b, c;
    	cin >> a >> b >> c;
    	sw.pb(node(c, a, b, i));
    	arr.pb(a - 1);
    }
    return solve();
}
bool END;
int main() {
    if(fopen(task ".inp", "r")) {
        freopen(task ".inp", "r", stdin);
        freopen(task ".out", "w", stdout);
    }
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    input();
    
    
    cerr << endl << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << 's' << endl;
    cerr << "Memory: " << fabs ((&END - &START)) / 1048576.0 << "MB\n";
    return 0;
}
Compilation message (stderr)
examination.cpp: In function 'int main()':
examination.cpp:105:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  105 |         freopen(task ".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
examination.cpp:106:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
  106 |         freopen(task ".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |