#include <bits/stdc++.h>
using namespace std;
long long n, q, d, p, a;
struct slog{
    long long d;
    long long p;
}dan, niz[300005];

long long pronadji(long long x){
    int l=1;
    int r=n;
    int ans;
    while (l <= r) {
        int mid = l+(r-l)/2;
        if (niz[mid].d <= x) {
            ans = mid;
            l = mid+1;
        }
        else {
            r = mid-1;
        }
    }
    return ans;
};

int main(){
    scanf("%lld %lld", &n, &q);
    for(int i=1; i<=n; i++){
        scanf("%lld %lld", &dan.d, &dan.p);
        niz[i].d=dan.d;
        niz[i].p=niz[i-1].p+dan.p;
    }
    for(int i=1; i<=q; i++){
        scanf("%lld", &a);
        long long b=a-niz[1].d+1;
        if(b<0)b=0;

        cout << b << " " << niz[pronadji(a)].p << endl;

        printf("%lld\n", min(b, niz[pronadji(a)].p));
    }
    return 0;
}