#include <iostream>
#include <algorithm>
#include <fstream>
#include <cmath>


using namespace std;
struct point {
    int x11;
    int y11;
};
int main()
{
    cin.tie(0);
    //freopen("mountain.in","r",stdin);
    freopen("mountain.out","w",stdout);
    int n,q;
    int i,l,r,c,x1,x2,p1,q1;
    int flag;
    long double k1,k2;
    point arra[11];
    arra[0].x11=0;
    arra[0].y11=0;
    cin>>n>>q;
    for (i=0;i<n;i++){
        cin>>arra[i+1].x11>>arra[i+1].y11;
    }
    for (i=1;i<=n;i++){
        arra[i].y11=arra[i-1].y11+arra[i].y11*arra[i].x11;
        arra[i].x11=arra[i-1].x11+arra[i].x11;
    }
    for (i=0;i<q;i++){
        l=0;
        r=n+1;
        cin>>p1>>q1;
        while (r-l>1){
            c=(r+l)/2;
            if (arra[c].x11>p1) {r = c;} else{ l = c;}

        }
        x1=l-1;
        x2=l+2;
        flag=0;
        while (x1>-1){
            k1= (q1-arra[x1].y11)/(p1-arra[x1].x11);
            k2= (q1-arra[x1+1].y11)/(p1-arra[x1+1].x11);
            if (q1-arra[x1+1].y11<0){cout<<arra[x1+1].x11<<" ";flag=1; break;}
            if (k2-k1>0.000000001) {x1--;} else {cout<<arra[x1+1].x11<<" ";flag=1; break;}
        }
        if (flag==0) cout<<"0 ";
        flag=0;
        while (x2<=n){
            k1= (q1-arra[x2].y11)/(p1-arra[x2].x11);
            k2= (q1-arra[x2-1].y11)/(p1-arra[x2-1].x11);
            if (k2-k1>0.000000001) {x2++; }else {cout<<arra[x2-1].x11<<" ";flag=1; break;}
        }
        if (flag==0) cout<<arra[n].x11<<endl;
    }
    return 0;
}
