#include<fstream>
#include<algorithm>

using namespace std;

ifstream cin("mountain.in");
ofstream cout("mountain.out");

int vec(int a, int b, int c, int d){
    return b * c - a * d;
}

bool h(pair<pair<int, int>, pair<int, int>> a, pair<pair<int, int>, pair<int, int>> b){
    int k = vec(a.second.first - a.first.first, a.second.second - a.first.second, b.first.first - a.first.first, b.first.second - a.first.second);
    int k1 = vec(a.second.first - a.first.first, a.second.second - a.first.second, b.second.first - a.first.first, b.second.second - a.first.second);
    int k2 = vec(b.second.first - b.first.first, b.second.second - b.first.second, a.first.first - b.first.first, a.first.second - b.first.second);
    int k3 = vec(b.second.first - b.first.first, b.second.second - b.first.second, a.second.first - b.first.first, a.second.second - b.first.second);
    return k * k1 >= 0 || k2 * k3 >= 0;
}

int main(){
    int n, q;
    cin >> n >> q;
    pair<int, int> v[n + 1];
    pair<int, int> v1[n + 1];
    v[0] = {0, 0};
    v1[n] = {0, 0};
    for (int i = 1; i < n + 1; ++i){
        int a, b;
        cin >> a >> b;
        v[i].first = v[i - 1].first + a;
        v[i].second = v[i - 1].second + a * b;
        v1[n - i] = v[i];
    }
    for (int j1 = 0; j1 < q; ++j1){
        int x, y;
        cin >> x >> y;
        bool f = false;
        bool pr = false;
        for (int i = 0; i < n + 1; ++i){
            bool f1 = true;
            for (int j = 0; j < n; ++j){
                if (j == i || j == i - 1) continue;
                if (!h({{x, y}, {v1[i].first, v1[i].second}}, {{v1[j].first, v1[j].second}, {v1[j + 1].first, v1[j + 1].second}})){
                    f1 = false;
                    //cout << i << endl;
                    break;
                }
            }
            if (!f1 && f) cout << v1[i - 1].first << " ";
            if (!f1 && f){
                pr = true;
                break;
            }
            if (f1) f = true;
        }
        if (!pr) cout << v1[n].first << " ";
        f = false;
        pr = false;
        for (int i = 0; i < n + 1; ++i){
            bool f1 = true;
            for (int j = 0; j < n; ++j){
                if (j == i || j == i - 1) continue;
                if (!h({{x, y}, {v[i].first, v[i].second}}, {{v[j].first, v[j].second}, {v[j + 1].first, v[j + 1].second}})){
                    f1 = false;
                    //cout << i << endl;
                    break;
                }
            }
            if (!f1 && f) cout << v[i - 1].first << endl;
            if (!f1 && f){
                pr = true;
                break;
            }
            if (f1) f = true;
        }
        if (!pr) cout << v[n].first << endl;
    }
}
