import java.io.*;
import java.util.*;

public class Pr4Mountain {
	public static void main(String[] args) throws IOException {
		new Pr4Mountain().run();
	}

	BufferedReader in;
	PrintWriter out;
	StringTokenizer st;

	String nextToken() throws IOException {
		while (st == null || !st.hasMoreTokens()) {
			st = new StringTokenizer(in.readLine());
		}
		return st.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	void run() throws IOException {
		in = new BufferedReader(new FileReader("mountain.in"));
		out = new PrintWriter("mountain.out");
		solve();
		out.flush();
	}

	class Point {
		long x;
		long y;

		public Point() {
		}

		public Point(long x, long y) {
			this.x = x;
			this.y = y;
		}
	}

	void solve() throws IOException {
		int n = nextInt();
		int q = nextInt();
		Point[] all = new Point[n + 1];
		all[0] = new Point();
		for (int i = 1; i <= n; i++) {
			long d = nextInt();
			long k = nextInt();
			all[i] = new Point(all[i - 1].x + d, all[i - 1].y + d * k);
		}
		// for(int i = 0; i < n; i++) {
		// System.out.println(all[i].x + " " + all[i].y);
		// }
		if (q <= 3000 && n <= 3000) {
			for (; q > 0; q--) {
				int u = nextInt();
				int v = nextInt();
				int l = 0;
				int r = 0;
				for (int i = 0; i <= n; i++) {
					if (all[i].x == u) {
						l = i;
						r = i;
						break;
					}
					if (i == 0 && u < all[i].x) {
						l = i;
						r = i;
						break;
					}
					if (n == i && all[i].x < u) {
						l = i;
						r = i;
						break;
					}
					if (i > 0 && all[i].x > u && all[i - 1].x < u) {
						l = i - 1;
						r = i;
						break;
					}
				}
				double mink = Double.POSITIVE_INFINITY;
				if (u != all[l].x) {
					mink = (v - all[l].y) * 1.0 / (u - all[l].x);
				}
				// int wh = l;
				while (l > 0) {
					if ((v - all[l - 1].y) * 1.0 / (u - all[l - 1].x) <= mink) {
						mink = (v - all[l - 1].y) * 1.0 / (u - all[l - 1].x);
						l--;
					} else {
						break;
					}
				}
				double maxk = Double.NEGATIVE_INFINITY;
				if (u != all[r].x) {
					maxk = (all[r].y - v) * 1.0 / (all[r].x - u);
				}
				while (r < n) {
					if ((all[r + 1].y - v) * 1.0 / (all[r + 1].x - u) >= maxk) {
						maxk = (all[r + 1].y - v) * 1.0 / (all[r + 1].x - u);
						r++;
					} else {
						break;
					}
				}
				out.println(all[l].x + " " + all[r].x);
			}
			return;
		}
		int[][] queries = new int[q][3];
		for (int i = 0; i < q; i++) {
			queries[i][0] = nextInt();
			queries[i][1] = nextInt();

			queries[i][2] = i;
		}
		long[][] ans = new long[q][2];
		Arrays.sort(queries, new Comparator<int[]>() {

			@Override
			public int compare(int[] o1, int[] o2) {
				return Integer.compare(o1[1], o2[1]);
			}
		});
		int l = 0;
		int r = 0;
		for (int i = 0; i <= n; i++) {
			if (all[i].x == queries[0][0]) {
				l = i;
				r = i;
				break;
			}
			if (i == 0 && queries[0][0] < all[i].x) {
				l = i;
				r = i;
				break;
			}
			if (n == i && all[i].x < queries[0][0]) {
				l = i;
				r = i;
				break;
			}
			if (i > 0 && all[i].x > queries[0][0] && all[i - 1].x < queries[0][0]) {
				l = i - 1;
				r = i;
				break;
			}
		}
		double mink = Double.POSITIVE_INFINITY;
		if (queries[0][0] != all[l].x) {
			mink = (queries[0][1] - all[l].y) * 1.0 / (queries[0][0] - all[l].x);
		}
		double maxk = Double.NEGATIVE_INFINITY;
		if (queries[0][0] != all[r].x) {
			maxk = (all[r].y - queries[0][1]) * 1.0 / (all[r].x - queries[0][0]);
		}
		for (int i = 0; i < q; i++) {
			int u = queries[i][0];
			int v = queries[i][1];
			if (u != all[l].x) {
				mink = (v - all[l].y) * 1.0 / (u - all[l].x);
			}
			if (u != all[r].x) {
				maxk = (all[r].y - v) * 1.0 / (all[r].x - u);
			}
			while (l > 0) {
				if ((v - all[l - 1].y) * 1.0 / (u - all[l - 1].x) <= mink) {
					mink = (v - all[l - 1].y) * 1.0 / (u - all[l - 1].x);
					l--;
				} else {
					break;
				}
			}
			while (r < n) {
				if ((all[r + 1].y - v) * 1.0 / (all[r + 1].x - u) >= maxk) {
					maxk = (all[r + 1].y - v) * 1.0 / (all[r + 1].x - u);
					r++;
				} else {
					break;
				}
			}
			ans[queries[i][2]][0] = all[l].x;
			ans[queries[i][2]][1] = all[r].x;
		}
		for (int i = 0; i < q; i++) {
			out.println(ans[i][0] + " " + ans[i][1]);
		}
	}
}
