#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <set>

using namespace std;

struct Point
{
    long long x, y;
    Point(){}
    Point(long long _x, long long _y) {x = _x; y = _y;}
};

Point operator - (Point p1, Point p2)
{
    return Point(p1.x - p2.x, p1.y - p2.y);
}

long long ve(Point p1, Point p2)
{
    return p1.x*p2.y - p1.y*p2.x;
}

long long h[100000];

long long check(long long x1, long long y1, long long x2, long long y2)
{
    Point v = Point(x2 - x1, y2 - y1);

    for(long long x = x1; x <= x2; x++)
    {
        if(ve(v, Point(x-x1, h[x]-y1)) > 0) return 0;
    }
    return 1;
}

pair<long long, long long> solve(long long x, long long y, long long X)
{
    long long x1 = x;
    while(x1 <= X && check(x, y, x1, h[x1])) x1++;

    long long x2 = x;
    while(x2 >= 0 && check(x2, h[x2], x, y)) x2--;

    return make_pair(x2+1, x1-1);
}

int main()
{

    freopen("mountain.in", "r", stdin);
    freopen("mountain.out", "w", stdout);

    long long n, q;
    cin >> n >> q;


    long long X = 0;
    for(long long i = 0; i < n; i++)
    {
        long long d, k;
        cin >> d >> k;

        long long x2 = X+1;
        for(; x2 <= X+d; x2++) h[x2] = h[x2-1] + k;

        X = x2-1;
    }

    while(q--)
    {
        long long x, y;
        cin >> x >> y;
        pair<long long, long long> p = solve(x, y, X);
        cout << p.first << " " << p.second;
    }





    return 0;
}
