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

using namespace std;

int n, q;
int d[1000000];
int k[1000000];
int x[1000000];
int y[1000000];

long double e = 1e-6;

int main()
{
    freopen("mountain.in", "r", stdin);
    freopen("mountain.out", "w", stdout);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n >> q;

    for (int i = 1; i <= n; i++)
    {
        scanf("%d%d", &d[i], &k[i]);
        x[i] = x[i - 1] + d[i];
        y[i] = y[i - 1] + d[i] * k[i];
    }

    for (int qq = 1; qq <= q; qq++)
    {
        int x1, y1;
        scanf("%d%d", &x1, &y1);

        int ans1 = x[n];
        bool st = false;
        for (int i = 1; i <= n; i++)
        {
            if (x[i] >= x1)
            {
                double k1 = ((double)(y[i] - y1)) / (x[i] - x1);

                if (k1 > k[i] + e)
                {
                    int r = x[i];
                    int l = x[i] - d[i];

                    while (r - l > 1)
                    {
                        int m = l + (r - l) / 2;

                        double k1 = ((double)(y[i] - k[i] * (x[i] - m)  - y1)) / (m - x1);

                        if (k1 + e <= k[i])
                        {
                            l = m;
                        } else
                        {
                            r = m;
                        }
                    }

                    ans1 = r - 1;
                    break;
                }
            }
        }

        bool tt = false;
        for (int i = n; i >= 1; i--)
        {
            if (x[i] <= x1)
            {
                double k1 = ((double)(y[i] - d[i] * k[i] - y1)) / (x[i] - d[i] - x1);

                if (k1 + e < k[i])
                {
                    int l = x[i] - d[i];
                    int r = x[i];

                    while (r - l > 1)
                    {
                        int m = l + (r - l) / 2;

                        double k1 = ((double)(y[i] - d[i] * k[i] + k[i] * (m - x[i] + d[i]) - y1)) / (m - x1);

                        if (k1 + e >= k[i])
                        {
                            r = m;
                        } else
                        {
                            l = m;
                        }
                    }

                    printf("%d %d\n", l + 1, ans1);
                    tt = true;
                    break;
                }
            }
        }

        if (!tt)
        {
            printf("%d %d\n", 0, ans1);
        }
    }
    return 0;
}
