#include <bits/stdc++.h>

using namespace std;

const int MX_SZ = 4e+5 + 42;

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

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

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

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

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

int main()
{
    freopen("mountain.in", "r", stdin);
    freopen("mountain.out", "w", stdout);
    ios_base::sync_with_stdio(false);
    int q;
    cin >> n >> 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;
        assert(tower.y != 0);
        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 = -1, r = -1;
        for (int i = ps - 1; i >= 0; i--)
        {
            Vector v1 = Vector(a[i], tower);
            for (int j = 0; j < n; j++)
            {
                if (j == i or j + 1== i)
                {
                    continue;
                }
                Vector v2 = Vector(a[j], a[j + 1]);
                if (sign(cross_product(v1, Vector(a[i], a[j]))) * sign(cross_product(v1, Vector(a[i], a[j + 1]))) == -1 and
                    sign(cross_product(v2, Vector(a[j], a[i]))) * sign(cross_product(v2, Vector(a[j], tower))) == -1)
                {
                    l = a[i + 1].x;
                    break;
                }
            }
            if (l != -1)
            {
                break;
            }
        }
        if (l == -1)
        {
            l = a[0].x;
        }
        for (int i = ps; i <= n; i++)
        {
            Vector v1 = Vector(a[i], tower);
            for (int j = 0; j < n; j++)
            {
                if (j == i or j + 1 == i)
                {
                    continue;
                }
                Vector v2 = Vector(a[j], a[j + 1]);
                if (sign(cross_product(v1, Vector(a[i], a[j]))) * sign(cross_product(v1, Vector(a[i], a[j + 1]))) == -1 and
                    sign(cross_product(v2, Vector(a[j], a[i]))) * sign(cross_product(v2, Vector(a[j], tower))) == -1)
                {
                    r = a[i - 1].x;
                    break;
                }
            }
            if (r != -1)
            {
                break;
            }
        }
        if (r == -1)
        {
            r = a[n].x;
        }
        cout << l << " " << r << endl;
    }
}
