#include <bits/stdc++.h>

using namespace std;

const double EPS = 1e-4;
const int MX_SZ = 4e+5 + 42;

struct point
{
    double x, y;
    point() {}
    point(double x0, double y0) : x(x0), y(y0) {}
};

struct Vector
{
    double x, y;
    Vector() {}
    Vector(point a, point b) : x(b.x - a.x), y(b.y - a.y) {}
};

struct request
{
    double x, y;
    int nm;
    request(){}
    request(double x0, double y0, int nm0) : x(x0), y(y0), nm(nm0) {}
};

int n;
point tower;
point a[MX_SZ];

inline double cross_product(Vector v1, Vector v2)
{
    return v1.x * v2.y - v1.y * v2.x;
}

inline int sign(double x)
{
    if (x > 0)
    {
        return 1;
    }
    if (x < 0)
    {
        return -1;
    }
    if (x == 0)
    {
        return 0;
    }
}

inline bool intersect(point p1, point p2, point p3, point p4)
{
    Vector v1 = Vector(p1, p2), v2 = Vector(p3, p4);
    return sign(cross_product(v1, Vector(p1, p3))) * sign(cross_product(v1, Vector(p1, p4))) == -1 and
           sign(cross_product(v2, Vector(p3, p1))) * sign(cross_product(v2, Vector(p3, p2))) == -1;
}

void stupid(int n, int q)
{
    a[0] = point(0, 0);
    for (int i = 1; i <= n; i++)
    {
        long long d, k;
        cin >> d >> k;
        a[i] = point(a[i - 1].x + d, a[i - 1].y + d * k);
    }
    for (int rq = 0; rq < q; rq++)
    {
        cin >> tower.x >> tower.y;
        tower.y += EPS;
        int ps = -1;
        for (int i = 0; i <= n; i++)
        {
            if (a[i].x > tower.x)
            {
                ps = i - 1;
                break;
            }
        }
        if (ps == -1)
        {
            ps = n;
        }
        long long l = a[ps].x, r = a[ps + 1].x;
        bool done = false;
        for (int i = ps - 1; i >= 0; i--)
        {
            if (i + 2 > n)
            {
                continue;
            }
            Vector v1 = Vector(a[i], tower), v2 = Vector(a[i], a[i + 1]);
            if (sign(cross_product(v1, v2)) == 1)
            {
                done = true;
                l = a[i + 1].x;
                break;
            }
        }
        if (!done)
        {
            l = a[0].x;
        }
        done = false;
        for (int i = ps + 1; i <= n; i++)
        {
            if (i - 2 < 0)
            {
                continue;
            }
            Vector v1 = Vector(a[i], tower), v2 = Vector(a[i], a[i - 1]);
            if (sign(cross_product(v1, v2)) == -1)
            {
                done = true;
                r = a[i - 1].x;
                break;
            }
        }
        if (!done)
        {
            r = a[n].x;
        }
        cout << l << " " << r << endl;
    }
}

inline bool by_y(const request &a, const request &b)
{
    return a.y < b.y;
}

int main()
{
    freopen("mountain.in", "r", stdin);
    freopen("mountain.out", "w", stdout);
    ios_base::sync_with_stdio(false);
    int q;
    cin >> n >> q;
    if (n <= 3000 and q <= 3000)
    {
        stupid(n, q);
    }
    else
    {
        a[0] = point(0, 0);
        for (int i = 1; i <= n; i++)
        {
            long long d, k;
            cin >> d >> k;
            a[i] = point(a[i - 1].x + d, a[i - 1].y + d * k);
        }
        vector<request> v;
        for (int rq = 0; rq < q; rq++)
        {
            request cr;
            cin >> cr.x >> cr.y;
            cr.nm = rq;
            v.push_back(cr);
        }
        sort(v.begin(), v.end(), by_y);
        static pair<long long, long long> ans[MX_SZ];
        static pair<bool, bool> done[MX_SZ];
        int pnt = 0;
        int ps = -1;
        for (int i = 0; i <= n; i++)
        {
            if (v[0].x > tower.x)
            {
                ps = i - 1;
                break;
            }
        }
        if (ps == -1)
        {
            ps = n;
        }
        for (int i = ps - 1; i >= 0; i--)
        {
            if (i + 2 > n)
            {
                continue;
            }
            Vector v1 = Vector(a[i], point(v[pnt].x, v[pnt].y)), v2 = Vector(a[i], a[i + 1]);
            while (pnt < q and sign(cross_product(v1, v2)) == 1)
            {
                done[v[pnt].nm].first = true;
                ans[v[pnt].nm].first = a[i + 1].x;
                pnt++;
                v1 = Vector(a[i], point(v[pnt].x, v[pnt].y));
            }
        }
        pnt = 0;
        for (int i = ps + 1; i <= n; i++)
        {
            if (i - 2 < 0)
            {
                continue;
            }
            Vector v1 = Vector(a[i], point(v[pnt].x, v[pnt].y)), v2 = Vector(a[i], a[i - 1]);
            while (pnt < q and sign(cross_product(v1, v2)) == -1)
            {
                done[v[pnt].nm].second = true;
                ans[v[pnt].nm].second = a[i + 1].x;
                pnt++;
                v1 = Vector(a[i], point(v[pnt].x, v[pnt].y));
            }
        }
        for (int i = 0; i < q; i++)
        {
            if (!done[i].first)
            {
                ans[i].first = 0;
            }
            ans[i].first = min(ans[i].first, (long long)a[ps].x);
            if (!done[i].second)
            {
                ans[i].second = 0;
            }
            ans[i].second = max(ans[i].second, (long long)a[ps + 1].x);
            cout << ans[i].first << " " << ans[i].second << '\n';
        }
    }
}
