// Arup Guha
// 6/20/2025
// Solution to Telephones
// https://open.kattis.com/problems/telephones

using namespace std;
#include <bits/stdc++.h>

bool intersect(pair<int,int>& call, pair<int,int>& q);

int main() {

    // Read calls, store as start to end.
    int n, q;
    cin >> n >> q;

    while (n > 0 || q > 0) {

        vector<pair<int,int>> calls(n);
        for (int i=0; i<n; i++) {
            int s, d, dummy;
            cin >> dummy >> dummy >> s >> d;
            calls[i].first = s;
            calls[i].second = s + d;
        }

        // Answer queries.
        for (int i=0; i<q; i++) {

            int s, d;
            pair<int,int> p;
            cin >> s >> d;
            p.first = s;
            p.second = s+d;

            // Go through each interval.
            int res = 0;
            for (int j=0; j<n; j++)
                if (intersect(calls[j], p))
                    res++;

            // Ta da!
            cout << res << endl;
        }

        // Get next.
        cin >> n >> q;
    }

    return 0;
}

// Returns true iff query duration q intersects with call. False otherwise.
bool intersect(pair<int,int>& call, pair<int,int>& q) {
    if (q.second <= call.first) return false;
    if (q.first >= call.second) return false;
    return true;
}
