#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define mp make_pair
#define mt make_tuple
#define sz size()
#define pb push_back
#define SPED ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cerr.tie(0)
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
#define inv(n) power((n), mod - 2)
#define ff(i,a,b) for (int (i) = (a); (i) < (b); (i)++)
#define fff(i,a,b) for (int (i) = (a); (i) <= b; (i)++)
#define bff(i,a,b) for (int (i) = (b)-1; (i) >= (a); (i)--)
#define bfff(i,a,b) for (int (i) = (b); (i) >= (a); (i)--)
#define sum_overflow(a,b) __builtin_add_overflow_p ((a), (b), (__typeof__ ((a) + (b))) 0)
#define mul_overflow(a,b) __builtin_mul_overflow_p ((a), (b), (__typeof__ ((a) * (b))) 0)
#define popcount(x) __builtin_popcountll(x)
#define PI 3.14159265358979323846

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef long long int ll;
typedef long double ld;
typedef unsigned long long int ull;
typedef pair<ll,ll> pll;
typedef vector<vector<ll>> graf;
typedef array<ll,3> all;
typedef array<double,3> add;

const ll mod = 1e9+7;
const ll MOD = 998244353;
const ll MAXN = 800005;
const ll INF = 1e18;

template <class T> using ordered_set = tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>;
template <class T> using ordered_multiset = tree<T, null_type,less_equal<T>, rb_tree_tag,tree_order_statistics_node_update>;

struct SegmentTree
{
    vector<vector<ll>> niz_levi = vector<vector<ll>>(MAXN,vector<ll>());
    vector<vector<ll>> niz_desni = vector<vector<ll>>(MAXN,vector<ll>());
    vector<pll> a;
    void build(ll v, ll l, ll r)
    {
        if(l==r){
            niz_levi[v].pb(a[l].first);
            niz_desni[v].pb(a[l].second+1);
        }
        else
        {
            ll mid = (l+r)/2;
            build(2*v,l,mid);
            build(2*v+1,mid+1,r);
            niz_levi[v]=vector<ll>(niz_levi[2*v].sz+niz_levi[2*v+1].sz);
            merge(all(niz_levi[2*v]),all(niz_levi[2*v+1]),niz_levi[v].begin());
            niz_desni[v]=vector<ll>(niz_desni[2*v].sz+niz_desni[2*v+1].sz);
            merge(all(niz_desni[2*v]),all(niz_desni[2*v+1]),niz_desni[v].begin());
        }
    }
    ll query(ll v, ll l, ll r, ll currl, ll currr, ll k)
    {
        if(l>currr || r<currl)
            return 0;
        if(currl>=l && currr<=r)
        {
            ll br1 = upper_bound(all(niz_levi[v]),k)-niz_levi[v].begin();
            ll br2 = upper_bound(all(niz_desni[v]),k)-niz_desni[v].begin();
            return br1-br2;
        }
        ll mid = (currl+currr)/2;
        return query(2*v,l,r,currl,mid,k)+query(2*v+1,l,r,mid+1,currr,k);
    }
};

int main()
{
    SPED;
    ll n,m;
    cin >> n >> m;
    vector<pll> a;
    ff(i,0,n)
    {
        ll x,y;
        cin >> x >> y;
        a.pb({x,y});
    }
    SegmentTree s;
    s.a=a;
    s.build(1,0,n-1);
    while(m--)
    {
        ll d,e,f;
        cin >> d >> e >> f;
        cout << s.query(1,d-1,e-1,0,n-1,f) << "\n";
    }
    return 0;
}