#include <bits/stdc++.h>

using namespace std;

vector<pair<long long, long long> > v;

long long x, y;

long long cross_product(long long i, long long j){
    pair<long long, long long> f = {v[i].first - v[j].first, v[i].second - v[j].second};
    pair<long long, long long> se = {x - v[j].first, y - v[j].second};

    return f.first * se.second - f.second * se.first;
}

int main()
{
    ifstream cin("mountain.in");
    ofstream cout("mountain.out");
    long long n, q;
    v.push_back({0, 0});
    cin >> n >> q;
    for (long long i = 0; i < n; i++){
        x, y;
        cin >> x >> y;
        v.push_back({v[i].first + x, v[i].second + x * y});
    }
    n++;

    for (long long i = 0; i < q; i++){
        x, y;
        cin >> x >> y;
        long long si, sj;
        for (long long j = 0; j < n; j++)
            if (v[j].first <= x)
                si = j;
        for (long long j = n - 1; j >= 0; j--)
            if (v[j].first >= x)
                sj = j;

        long long it = si;
        while (it >= 0){
            bool fl = 0;
            for (long long j = it + 1; j < si; j++){
                if (cross_product(it, j) > 0){
                    fl = 1;
                    break;
                }
            }
            if (!fl)
                it--;
            else
                break;
        }
        it++;

        if (it != 0)
            cout << v[it].first << ' ';
        else
            cout << v[0].first << ' ';

        it = sj;
        while (it < n){
            bool fl = 0;
            for (long long j = it - 1; j > sj; j--){
                if (cross_product(it, j) < 0){
                    fl = 1;
                    break;
                }
            }
            if (!fl)
                it++;
            else
                break;
        }
        it--;

        if (it != n)
            cout << v[it].first << '\n';
        else
            cout << v[n - 1].first << '\n';
    }
    return 0;
}
