#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <iostream>
#include <time.h>
#define ll long long int
using namespace std;
const int mod=1e9+7;

double d[444444],k[444444],x[444444],y[444444];
int l1,r1;

bool chkl(int c,double xx,double yy){
	double a1,a2,b1,b2,xxx,yyy;
	int i;
	if(x[c]==xx){
		return true;
	}
	a1=(y[c]-yy)/(x[c]-xx);
	b1=y[c]-a1*x[c];
	for(i=c;i<=l1;i++){
		a2=k[i];
		b2=y[i]-a2*x[i];
		if(a1!=a2){
			xxx=(b2-b1)/(a1-a2);
			yyy=a1*xxx+b1;
			if(xxx>x[i]&&xxx<x[i+1]){
				return false;
			}
		}
	}
	return true;
}

bool chkr(int c,double xx,double yy){
	double a1,a2,b1,b2,xxx,yyy;
	int i;
	if(x[c]==xx){
		return true;
	}
	a1=(y[c]-yy)/(x[c]-xx);
	b1=y[c]-a1*x[c];
	for(i=r1;i<c;i++){
		a2=k[i];
		b2=y[i]-a2*x[i];
		if(a1!=a2){
			xxx=(b2-b1)/(a1-a2);
			yyy=a1*xxx+b1;
			if(xxx>x[i]&&xxx<x[i+1]){
				return false;
			}
		}
	}
	return true;
}

int main(){
#pragma comment(linker,"/STACK:536870912")
#pragma warning(disable:4996)
#ifdef _DEBUG
	freopen("input.txt","rt",stdin);
	freopen("output.txt","wt",stdout);
#else
	freopen("mountain.in","rt",stdin);
	freopen("mountain.out","wt",stdout);
#endif
	int n,i,j,q,l,r,m;
	double xx,yy;
	scanf("%d%d",&n,&q);
	x[0]=0;
	y[0]=0;
	for(i=0;i<n;i++){
		scanf("%lf%lf",&d[i],&k[i]);
		x[i+1]=x[i]+d[i];
		y[i+1]=k[i]*x[i+1]+y[i]-k[i]*x[i];
	}
	for(i=0;i<q;i++){
		scanf("%lf%lf",&xx,&yy);
		l=0;
		r=n;
		while(r-l>1){
			m=(l+r)/2;
			if(x[m]<=xx){
				l=m;
			} else{
				r=m;
			}
		}
		l1=l;
		r1=r;
		while(l>0&&chkl(l-1,xx,yy)){
			l--;
		}
		while(r<n&&chkr(r+1,xx,yy)){
			r++;
		}
		printf("%.0lf %.0lf\n",x[l],x[r]);
	}

	return 0;
}