#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

struct Point
{
    int x;
    int y;
    int no;
    int prevk = -1000000000;
    int nextk = 1000000000;
    Point(int a, int b)
    {
        x = a;
        y = b;
    }
};

vector<Point> points;

bool byx(Point a, Point b)
{
    return a.x < b.x;
}

int main()
{
    freopen("mountain.in", "r", stdin);
    freopen("mountain.out", "w", stdout);
    int n, q;
    cin >> n >> q;
    points.push_back(Point(0, 0));
    points[0].no = 0;
    for (int i = 0; i < n; i++)
    {
        int xpr, k;
        cin >> xpr >> k;
        points[i].nextk = k;
        points.push_back(Point(points[i].x + xpr, points[i].y + xpr * k));
        points[i + 1].prevk = k;
        points[i + 1].no = i + 1;
    }
    for (int tow = 0; tow < q; tow++)
    {
        int topx, topy;
        cin >> topx >> topy;
        int closestL = lower_bound(points.begin(), points.end(), Point(topx, topy), byx)->no;
        if (points[closestL].x > topx)
        {
            closestL--;
        }
        int closestR = lower_bound(points.begin(), points.end(), Point(topx, topy), byx)->no;
        bool going = true;
        while (going && closestL > 0)
        {
            if (points[closestL].prevk * (topx - points[closestL].x) <= topy - points[closestL].y)
            {
                closestL--;
            }
            else
            {
                going = false;
            }
        }
        cout << points[closestL].x << " ";
        going = true;
        while (going && closestR < n)
        {
            if (points[closestR].nextk * (topx - points[closestR].x) <= topy - points[closestR].y)
            {
                closestR++;
            }
            else
            {
                going = false;
            }
        }
        cout << points[closestR].x << endl;
    }
    return 0;
}
