#include <iostream>
#include <fstream>
#include <vector>

#define ll long long
#define ld long double

using namespace std;

struct vertex {

    ll x, y;
};

vertex make_vertex (ll x, ll y) {

    vertex v;
    v.x = x;
    v.y = y;

    return v;
}

int binSearch ( vector <vertex> &v, ll x ) {

    int l, r;
    l = 0;
    r = v.size();

    while (r - l > 1) {

        int c = (r + l) / 2;

        (v[c].x > x ? r : l) = c;
    }

    int a = (v[l].x > x ? l : r);

    if (v[a].x == x) {

        return ( a < v.size() - 1 ? a + 1 : a );

    } else {

        return a;
    }
}

int main () {

    ios_base::sync_with_stdio(0);

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

    ll n, q;
    cin >> n >> q;

    vector <vertex> v(n + 1);
    v[0] = make_vertex(0, 0);

    for (int i = 1; i <= n; i++) {

        ld d, k;
        cin >> d >> k;

        v[i] = make_vertex( v[i - 1].x + d, v[i - 1].y + d * k );
    }

    for (int j = 0; j < q; j++) {

        ll x, y;
        cin >> x >> y;

        int l, r, i;
        ld k, _k;
        r = binSearch(v, x);

        if ( r > 0 && v[r - 1].x == x) {

            l = r - 2;

        } else {

            l = r - 1;
        }

        k = -1000000000, _k = -1000000000;
        for (i = l; i >= 0 && _k >= k; i--) {

            k = _k;
            _k =  (- (y - v[i].y) ) * 1.0 / (x - v[i].x);

            //cout << v[i].x << ' ' << _k << ' ' << k << '\n';
        }

        if (_k >= k) {

            cout << v[i + 1].x << ' ';

        } else {

            cout << v[i + 2].x << ' ';
        }

        //cout << '\n';

        k = 1000000000, _k = 1000000000;
        for (i = r; i < v.size() && _k <= k; i++) {

            k = _k;
            _k =  (- (y - v[i].y) ) * 1.0 / (x - v[i].x);

            //cout  << v[i].x << ':' << v[i].y << ' ' << _k << ' ' << k << '\n';
        }

        if (_k <= k) {

            cout << v[i - 1].x << '\n';

        } else {

            cout << v[i - 2].x << '\n';
        }
    }
}
