#include<bits/stdc++.h>

using namespace std;

typedef long long lint;
typedef long double ldb;

#define F(i, l, r) for(auto i = l; i != r; i++)
#define Df(i, l, r) for(auto i = l; i != r; i--)
#define rs resize
#define cont continue
#define ret return
#define ins insert
#define era erase
#define brk break
#define asg assign
#define retn exit(0)
#define all(x) x.begin(),x.end()
#define mk make_pair
#define X first
#define Y second

const string fname = "mountain";

const ldb eps = 1e-7;

struct seg{
    int k;
    int x1, x2;
    int y1, y2;
};

typedef pair<int, int> frac;

bool operator < (const frac & a, const frac & b){
    if(a.X * 1ll * a.Y < 0)
        ret true;
    ret (a.X * 1ll * b.Y < b.X * 1ll * a.Y);
}

int n, q;
vector<seg> s;
vector<pair<int ,int> > tw;

int main(){
    string fin = fname + ".in";
    string fout = fname + ".out";
    freopen(fin.c_str(), "r", stdin);
    freopen(fout.c_str(), "w", stdout);
    scanf("%d%d", &n, &q);
    s.rs(n);
    int cx = 0, cy = 0;
    F(i, 0, n){
        int k, d;
        scanf("%d%d", &d, &k);
        s[i].k = k;
        s[i].x1 = cx;
        s[i].y1 = cy;
        cy = cy + k * d;
        cx += d;
        s[i].x2 = cx;
        s[i].y2 = cy;
    }
    F(i, 0, q){
        int vx, vy;
        scanf("%d%d", &vx, &vy);
        int ws;
        F(j, 0, n){
            if(s[j].x1 <= vx && s[j].x2 >= vx){
                ws = j; brk;
            }
        }
        int ls = ws - 1, rs = ws + 1;
        if(rs < n && s[rs].x1 == vx)
            rs++;
        //printf("%d\n", rs);
        if(ls < 0){
            printf("0 ");
        }
        else{
            while(ls >= 0){
                if(s[ls].k < 0){ls--; cont;}
                int sx = s[ls].x2 - 1;
                int sy = s[ls].y2 - s[ls].k;
                frac ang = mk((vy - sy), (vx - sx));
                if(ang < mk(s[ls].k, 1))
                    brk;
                ls--;
            }
            if(ls == -1)
                printf("0 ");
            else
                printf("%d ", s[ls].x2);
        }
        if(rs > n - 1){
            printf("%d\n", cx);
        }
        else{
            while(rs <= n - 1){
                if(s[rs].k > 0){rs++; cont;}
                int sx = s[rs].x1 + 1;
                int sy = s[rs].y1 + s[rs].k;
                frac ang = mk(sy - vy, vx - sx);
                if(ang.X <= 0 && ang.Y <= 0){ang.X *= -1; ang.Y *= -1;}
                if(ang < mk(-s[rs].k, 1))
                    brk;
                rs++;
            }
            //printf("%d\n", rs);
            if(rs == n)
                printf("%d\n", cx);
            else
                printf("%d\n", s[rs].x1);
        }
    }
    ret 0;
}
