def main():
    def left(x, y):
        i = 0
        while KOOR[i][0] < x:
            i += 1
        i -= 1
        while i >= 0:
            if KOOR[i][1] < KOOR[i + 1][1] and y < (x - KOOR[i][0]) * (KOOR[i + 1][1] - KOOR[i][1]) / (KOOR[i + 1][0] - KOOR[i][0]) + KOOR[i][1]:
                return KOOR[i + 1][0]
            else:
                i -= 1
        return i + 1
    
    
    def right(x, y):
        i = n
        while KOOR[i][0] > x:
            i -= 1
        i += 1
        while i <= n:
            if KOOR[i][1] < KOOR[i - 1][1] and y < (x - KOOR[i][0]) * (KOOR[i - 1][1] - KOOR[i][1]) / (KOOR[i - 1][0] - KOOR[i][0]) + KOOR[i][1]:
                return KOOR[i - 1][0]
            else:
                i += 1
        return KOOR[n][0]
    
    
    fin = open('mountain.in')
    fout = open('mountain.out', 'w')
    n, q = map(int, fin.readline().split())
    KOOR = [(0, 0)] * (n + 1)
    for i in range(1, n + 1):
        d, k = map(int, fin.readline().split())
        KOOR[i] = (KOOR[i - 1][0] + d, KOOR[i - 1][1] + d * k)
    for i in range(q):
        x, y = map(int, fin.readline().split())
        fout.write(str(left(x, y)) + ' ' + str(right(x, y)) + '\n')
        
        
main()