
#include <iostream>
#include <vector>
#include <algorithm>

#pragma comment (linker, "/STACK:10000000")

using namespace std;

struct Point
{
	long long x, y;

	Point (long long x_ = 0, long long y_ = 0):
		x (x_),
		y (y_)

		{}
};

struct Vector
{
	long long x, y;

	Vector (Point p1, Point p2):
		x (p2.x - p1.x),
		y (p2.y - p1.y)

		{}
};

long long cross_pr (Vector v1, Vector v2)
{
	return (v1.x * v2.y - v2.x * v1.y);
}

long long dot_pr (Vector v1, Vector v2)
{
	return (v1.x * v2.x + v1.y * v2.y);
}

bool cross_intervals (Point p1, Point p2,
	                  Point p3, Point p4)
{
	bool cross_one = (cross_pr (Vector (p1, p3), Vector (p1, p2)) *
		              cross_pr (Vector (p1, p4), Vector (p1, p2))) < 0;

	bool cross_two = (cross_pr (Vector (p3, p2), Vector (p3, p4)) *
		              cross_pr (Vector (p3, p1), Vector (p3, p4))) < 0;

	return (cross_one && cross_two);
}

int main ()
{
	freopen ( "mountain.in", "r", stdin);
	freopen ("mountain.out", "w", stdout);

	int n = 0, q = 0;
	cin >> n >> q;

	vector <Point> points (n + 1);
	points [0] = Point (0, 0);

	for(int i = 0; i < n; i++)
	{
		int dx = 0, k = 0;
		cin >> dx >> k;

		points [i + 1] = Point (points[i].x + dx, points[i].y + k * dx);
	}

	long long x_max = points.back().x;

	for(int j = 0; j < q; j++)
	{
		int x_up = 0, y_up = 0;
		cin >> x_up >> y_up;
		Point up (x_up, y_up);

		long long left_ans = x_up, right_ans = x_up;
		
		for(int left_x = x_up; left_x >= 0; left_x--)
		{
			int less_x = 0;

			while (less_x < points.size () && points[less_x].x < left_x)
				less_x++;
			less_x--;
			less_x = max (less_x, 0);

			int dx = left_x - points [less_x].x;
			int k = (points [less_x + 1].y - points[less_x].y) / (points [less_x + 1].x - points[less_x].x);
			int dy = k * dx;

			Point down (left_x, points[less_x].y + dy);
			bool res = true;

			for(int i = 0; i + 1 < int (points.size ()); i++)
			{
				if(cross_intervals (down, up, points[i], points[i + 1]))
				{
					res = false;
					break;
				}
			}

			if (res)
				left_ans = left_x;
			else
				break;

		}

		for(int right_x = x_up; right_x <= x_max; right_x++)
		{
			int less_x = 0;

			while (less_x < points.size () && points[less_x].x < right_x)
				less_x++;
			less_x--;
			less_x = max (less_x, 0);

			int dx = right_x - points [less_x].x;
			int k = (points [less_x + 1].y - points[less_x].y) / (points [less_x + 1].x - points[less_x].x);
			int dy = k * dx;

			Point down (right_x, points[less_x].y + dy);
			bool res = true;

			for(int i = 0; i + 1 < int (points.size ()); i++)
			{
				if(cross_intervals (down, up, points[i], points[i + 1]))
				{
					res = false;
					break;
				}
			}

			if (res)
				right_ans = right_x;
			else
				break;
		}

		cout << left_ans << " " << right_ans << "\n";
	}
}