#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <ctime>
#include <cassert>
#include <tuple>
#include <bitset>
#define mp make_pair
#define pb push_back
#define NAME "mountain"
#define mt make_tuple
#define y1 y1_123
#define f1 f111

using namespace std;

typedef long long ll;
typedef long long ld;

const int nmax = 1000 * 1000;
const ld pi = acos(-1.0);
const int mod = 1000 * 1000 * 1000 + 7;
const int inf = 1000 * 1000 * 1000;
const ll infl = 1000ll * 1000 * 1000 * 1000 * 1000 * 1000;

struct point {
	ld x, y;
	point(){}
	point(ld X, ld Y) {
		x = X;
		y = Y;
	}
};

point operator + (point a, point b) {
	return point(a.x + b.x, a.y + b.y);
}

point operator - (point a, point b) {
	return point(a.x - b.x, a.y - b.y);
}

ld vect(point a, point b) {
	return a.x * b.y - a.y * b.x;
}

ld scal(point a, point b) {
	return a.x * b.x + a.y * b.y;
}

int n, q;
vector<point> now;
pair<ll, ll> answer[nmax];
vector<pair<point, int> > qq;
int d, k;

bool cmp1(pair<point, int> a, pair<point, int> b) {
	return a.first.y < b.first.y;
}

bool cmp2(pair<point, int> a, pair<point, int> b) {
	return a.first.x < b.first.x;
}


int main() {
	freopen(NAME".in", "r", stdin); freopen(NAME".out", "w", stdout);
	cin >> n >> q;
	now.clear();
	point q1 = point(0, 0);
	now.pb(q1);
	for (int i = 0; i < n; i++) {
		scanf("%d%d", &d, &k);
		q1 = point(q1.x + d, q1.y + d * k);
		now.pb(q1);
	}
	bool f = true, f1 = true;
	for (int zz = 0; zz < q; zz++) {
		scanf("%d%d", &d, &k);
		f = (f && (zz == 0 || qq.back().first.x == d));
		f1 = (f1 && (zz == 0 || qq.back().first.y == k));
		qq.pb(mp(point(d, k), zz));
	}
	if (f) {
		sort(qq.begin(), qq.end(), cmp1);
		d = qq[0].first.x;
		int indl, indr;
	    for (int i = 0; i < (int)now.size(); i++) {
	        if (now[i].x <= d) {
	        	indl = i;
	        }
	        if (now[i].x >= d) {
	           	indr = i;
				break;
			}
	    }
		for (auto v : qq) {
			point np = v.first;
		    while (indl > 0 && vect(now[indl] - np, now[indl - 1] - np) <= 0) {
		    	indl--;
		    }
		    while (indr + 1 < (int)now.size() && vect(now[indr] - np, now[indr + 1] - np) >= 0) {
				indr++;
		    }
	       	answer[v.second] = mp(now[indl].x, now[indr].x);
		}
		for (int i = 0; i < q; i++) {
			cout << answer[i].first << " " << answer[i].second << endl;
		}        
		//cerr << "fick";
	} else if (f1) {
		sort(qq.begin(), qq.end(), cmp2);
		int indl = (int)now.size() - 1, indr = 0;
		for (auto v : qq) {
			indr = 0;
			while (indr + 1 < (int)now.size() && now[indr].x <= v.first.x) {
				indr++;
			}
			while (indr + 1 < (int)now.size() && vect(now[indr] - v.first, now[indr + 1] - v.first) >= 0) {
				indr++;
			}
			answer[v.second].second = now[indr].x;
		}
		reverse(qq.begin(), qq.end());
		for (auto v : qq) {
			indl = (int)now.size() - 1;
			while (indl > 0 && now[indl].x >= v.first.x) {
				indl--;
			}
			while (indl > 0 && vect(now[indl] - v.first, now[indl - 1] - v.first) <= 0) {
				indl--;
			}
			answer[v.second].first = now[indl].x;
		}
		for (int i = 0; i < q; i++) {
			cout << answer[i].first << " " << answer[i].second << endl;
		}
	} else {
		int i = 0;
		for (auto v : qq) {
			point np = v.first;
	        int indl = 0, indr;
	        for (int i = 0; i < (int)now.size(); i++) {
	            if (now[i].x <= np.x) {
	                indl = indr = i;
	            }
	            if (now[i].x >= np.x) {
	                indr = i;
	                break;
	            }
	        }
	        indr = max(indr, indl);
	        //cerr << np.x << " " << np.y << " " << indl << " " << indr << endl;
	        while (indl > 0 && vect(now[indl] - np, now[indl - 1] - np) <= 0) {
	            indl--;
	        }
	        while (indr + 1 < (int)now.size() && vect(now[indr] - np, now[indr + 1] - np) >= 0) {
	            indr++;
	        }
	        cout << now[indl].x << " " << now[indr].x << endl;
	        i++;
		}
	}
}