#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define fi first
#define se second
#define mp make_pair
#define pb push_back

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef ll for_point;

const ll INF = 1e9 + 7;
const int N = 1e6 + 7;
const int M = 1e3 + 7;

struct point{
    for_point x, y;
    int i;
    point(){
        x = 0, y = 0;
    }
    point(for_point xx, for_point yy){
        x = xx, y = yy;
    }
    point(for_point xx, for_point yy, int ii){
        x = xx, y = yy, i = ii;
    }
};

ll d[N], k[N];
point a[N], z[N], an[N];

point get(ll x, ll y, int n){
    int l = 0, r = n;
    point ret = point(0, n);
    for (int i = 0; i < n; i++)
        if (a[i].x < x)
            l = i;
        else break;
    for (int i = n; i >= 0; i--)
        if (a[i].x > x)
            r = i;
        else break;
    for (int i = min(l, n - 1); i >= 0; i--)
        if (y - a[i].y < k[i] * (x - a[i].x)){
            ret.x = i + 1;
            break;
        }
    for (int i = r; i < n; i++)
        if (y - a[i + 1].y < k[i] * (x - a[i + 1].x)){
            ret.y = i;
            break;
        }
    return ret;
}

void get_if_eq_x(int q, int n){
    ll x = z[0].x;
    int l = 0, r = n;
    for (int i = 0; i < n; i++)
        if (a[i].x < x)
            l = i;
        else break;
    for (int i = n; i >= 0; i--)
        if (a[i].x > x)
            r = i;
        else break;
    for (int e = 0; e < q; e++){
        ll y = z[e].y;
        point ret = point(0, n);
        for (int i = min(l, n - 1); i >= 0; i--)
            if (y - a[i].y < k[i] * (x - a[i].x)){
                l = i;
                ret.x = i + 1;
                break;
            }
        for (int i = r; i < n; i++)
            if (y - a[i + 1].y < k[i] * (x - a[i + 1].x)){
                r = i;
                ret.y = i;
                break;
            }
        an[e] = point(a[ret.x].x, a[ret.y].x, z[e].i);
    }
}

bool cmp_y(point a, point b){
    return a.y < b.y;
}

bool cmp_i(point a, point b){
    return a.i < b.i;
}

int init(int q, int n){
    ll mi = INF, ma = -INF;
    for (int i = 0; i < q; i++){
        cin >> z[i].x >> z[i].y;
        mi = min(z[i].x, mi);
        ma = max(z[i].x, ma);
        z[i].i = i;
    }
    if (mi == ma){
        sort(z, z + q, cmp_y);
        return 1;
    }
    return 0;
}

int main()
{
    freopen("mountain.in", "r", stdin);
    freopen("mountain.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, q;
    cin >> n >> q;
    for (int i = 0; i < n; i++){
        cin >> d[i] >> k[i];
        a[i + 1].x = a[i].x + d[i], a[i + 1].y = a[i].y + k[i] * d[i];
    }
    if (init(q, n)){
        get_if_eq_x(q, n);
        sort(an, an + q, cmp_i);
        for (int i = 0; i < q; i++)
            cout << an[i].x << " " << an[i].y << endl;
    }
    else{
        for (int i = 0; i < q; i++){
            point ans = get(z[i].x, z[i].y, n);
            cout << a[ans.x].x  << " " << a[ans.y].x << endl;
        }
    }

    return 0;
}
