#include <bits/stdc++.h>

using std::cin;
using std::cout;
using std::cerr;

using std::vector;
using std::string;
using std::array;
using std::pair;
using std::make_pair;

using std::min;
using std::max;
using std::abs;

template <typename T>
T input() {
    T res;
    cin >> res;
    return res;
}

#ifdef LOCAL
#define LASSERT(x) assert(x)
#else
#define LASSERT(x) {}
#endif

template <typename T>
struct vec {
    T x;
    T y;
};

int64_t cross(vec<int32_t> a, vec<int32_t> b) {
    return a.x * 1ll * b.y - a.y * 1ll * b.x;
}

template <typename T>
vec<T> operator-(vec<T> v1, vec<T> v0) {
    return vec<T> {v1.x - v0.x, v1.y - v0.y};
}


int main() {
    // save with C-x C-s
    std::iostream::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
#ifndef LOCAL
#define TASK "mountain"
    freopen(TASK ".in", "r", stdin);
    freopen(TASK ".out", "w", stdout);
#endif

    int32_t n, q;
    cin >> n >> q;

    vector<vec<int32_t>> coords(n + 1);
    coords[0] = vec<int32_t> {0, 0};

    for (int32_t i = 1; i <= n; ++i) {
        int32_t d, k;
        cin >> d >> k;
        coords[i] = {coords[i - 1].x + d, coords[i - 1].y + d * k};
    }

    vector<vec<int32_t>> requests(q);
    bool group5 = true;

    for (int32_t i = 0; i != q; ++i) {
        cin >> requests[i].x >> requests[i].y;

        if (i != 0 and requests[i].x != requests[i - 1].x)
            group5 = false;
    }

    vector<int32_t> order(q);
    for (int32_t i = 0; i != q; ++i)
        order[i] = i;

    if (group5)
        std::sort(order.begin(), order.end(), [&requests](int32_t i, int32_t j) {
            return requests[i].y < requests[j].y;
        });

    vector<pair<int32_t, int32_t>> answers(q);

    for (int32_t i = 0; i != q; ++i) {
        vec<int32_t> CUR = requests[order[i]];

        int32_t ind = std::lower_bound(coords.begin(), coords.end(), CUR, [](vec<int32_t> a, vec<int32_t> b) {
            return a.x < b.x;
        }) - coords.begin();

        int32_t L = ind, R = ind;
        if (group5 and i != 0)
            std::tie(L, R) = answers[order[i - 1]];

        while (L - 1 >= 0 and cross(coords[L] - CUR, coords[L - 1] - CUR) <= 0)
            --L;
        while (R + 1 < int32_t(coords.size()) and cross(coords[R] - CUR, coords[R + 1] - CUR) >= 0)
            ++R;
        answers[order[i]] = make_pair(L, R);
    }

    for (int32_t i = 0; i != q; ++i)
        cout << coords[answers[i].first].x << " " << coords[answers[i].second].x << "\n";
    return 0;
}