#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

struct M {
    int p, b, i, e=1;
};

struct Mp {
    M *p;

    bool operator<(const Mp &rhs) const {
        return p->p < rhs.p->p;
    }
};

struct F {
    int l, r, i;
    int p, e=0;

    int t() { return r-p; }
};

struct Fp {
    F *p;

    bool operator<(const Fp &rhs) const {
        return p->l < rhs.p->l;
    }
};

void solve(std::vector<F> &fs_v, std::vector<M> &ms) {
    std::set<Fp> fs; {
        std::vector<Fp> fs_sort;
        fs_sort.reserve(fs_v.size());
        for(int i=0; i<fs_v.size(); i++) {
            fs_sort.push_back({&(fs_v[i])});
        }

        std::sort(fs_sort.begin(), fs_sort.end());

        fs.insert(fs_sort[0]);
        int curr = fs_sort[0].p->r;
        for(int i=1; i<fs_sort.size(); i++) {
            Fp &f = fs_sort[i];

            if(f.p->r > curr) {
                f.p->l = std::max(curr+1, f.p->l);
                curr = f.p->r;

                fs.insert(f);
            }
        }
    }
    std::multiset<Mp> ms_landed;

    auto f_update = [&] (const Fp &f, std::set<Fp>::iterator &f_it, std::set<Fp> &fs, const M &m) {
        f.p->e += m.e;
        f.p->r += m.b;

        while(f_it != fs.end()) {
            Fp f_succ = *f_it;

            if(f.p->r >= f_succ.p->r) {
                f_it = fs.erase(f_it);
            } else {
                if(f.p->r >= f_succ.p->l) {
                    f_succ.p->l = std::max(f.p->r+1, f_succ.p->l);
                }

                break;
            }
        }
    };

    for(int i=0; i<ms.size(); i++) {
        M &m = ms[i];

        F m_f = {m.p};
        auto f_it = --fs.upper_bound({&m_f});
        if(f_it == fs.end()) continue;
        const Fp &f = *f_it;

        if(f.p->l <= m.p && m.p <= f.p->r) {
            f_it++;
            f_update(f, f_it, fs, m);

            M f_f = {f.p->l};
            auto m_succ = ms_landed.lower_bound({&f_f});
            while(m_succ != ms_landed.end()) {
                const Mp &m = *m_succ;
                if(f.p->l <= m.p->p && m.p->p <= f.p->r) {
                    f_update(f, f_it, fs, *m.p);
                    m_succ = ms_landed.erase(m_succ);
                } else {
                    m_succ++;
                }
            }
        } else {
            M f_f = {m.p};
            auto search = ms_landed.find({&f_f});
            if(search == ms_landed.end()) {
                ms_landed.insert({&m});
            } else {
                search->p->e += m.e;
                search->p->b += m.b;
            }
        }
    }

    for(F &f: fs_v) {
        printf("%d %d\n", f.e, f.t());
    }
}

int main() {
    int n;
    int m;
    scanf("%d%d", &n, &m);

    std::vector<F> fs(n);
    std::vector<M> ms(m);

    for(int i=0; i<n; i++) {
        scanf("%d%d", &(fs[i].l), &(fs[i].r));
        fs[i].r += fs[i].l;
        fs[i].i = i;
        fs[i].p = fs[i].l;
    }

    for(int i=0; i<m; i++) {
        scanf("%d%d", &(ms[i].p), &(ms[i].b));
        ms[i].i = i;
    }

    solve(fs, ms);

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

struct M {
    int p, b, i, e=1;
};

struct Mp {
    M *p;

    bool operator<(const Mp &rhs) const {
        return p->p < rhs.p->p;
    }
};

struct F {
    int l, r, i;
    int p, e=0;

    int t() { return r-p; }
};

struct Fp {
    F *p;

    bool operator<(const Fp &rhs) const {
        return p->l < rhs.p->l;
    }
};

void f_update(const Fp &f, std::set<Fp>::iterator &f_it, std::set<Fp> &fs, const M &m) {
    f.p->e += m.e;
    f.p->r += m.b;

    while(f_it != fs.end()) {
        Fp f_succ = *f_it;

        if(f.p->r >= f_succ.p->r) {
            f_it = fs.erase(f_it);
        } else {
            f_succ.p->l = std::max(f.p->r+1, f_succ.p->l);
            break;
        }
    }
};

void solve(std::vector<F> &fs_v, std::vector<M> &ms) {
    std::set<Fp> fs; {
        std::vector<Fp> fs_sort;
        fs_sort.reserve(fs_v.size());
        for(int i=0; i<fs_v.size(); i++) {
            fs_sort.push_back({&(fs_v[i])});
        }

        std::sort(fs_sort.begin(), fs_sort.end());

        fs.insert(fs_sort[0]);
        int curr = fs_sort[0].p->r;
        for(int i=1; i<fs_sort.size(); i++) {
            Fp &f = fs_sort[i];

            if(f.p->r > curr) {
                f.p->l = std::max(curr+1, f.p->l);
                curr = f.p->r;

                fs.insert(f);
            }
        }
    }
    std::multiset<Mp> ms_landed;

    for(int i=0; i<ms.size(); i++) {
        M &m = ms[i];

        F m_f = {m.p};
        auto f_it = --fs.upper_bound({&m_f});
        if(f_it == fs.end()) continue;
        const Fp &f = *f_it;

        if(f.p->l <= m.p && m.p <= f.p->r) {
            f_it++;
            f_update(f, f_it, fs, m);
            // {
            //     f.p->r += m.b;

            //     while(f_it != fs.end()) {
            //         Fp f_succ = *f_it;

            //         if(f.p->r >= f_succ.p->r) {
            //             f_it = fs.erase(f_it);
            //         } else {
            //             f_succ.p->l = std::max(f.p->r+1, f_succ.p->l);
            //             break;
            //         }
            //     }
            // }

            M f_f = {f.p->l};
            auto m_succ = ms_landed.lower_bound({&f_f});
            while(m_succ != ms_landed.end()) {
                const Mp &mp = *m_succ;
                if(f.p->l <= mp.p->p && mp.p->p <= f.p->r) {
                    f_update(f, f_it, fs, *mp.p);
                    // {
                    //     const M &m = *mp.p;
                    //     f.p->r += m.b;

                    //     while(f_it != fs.end()) {
                    //         Fp f_succ = *f_it;

                    //         if(f.p->r >= f_succ.p->r) {
                    //             f_it = fs.erase(f_it);
                    //         } else {
                    //             f_succ.p->l = std::max(f.p->r+1, f_succ.p->l);
                    //             break;
                    //         }
                    //     }
                    // }
                    m_succ = ms_landed.erase(m_succ);
                } else {
                    m_succ++;
                }
            }
        } else {
            M f_f = {m.p};
            auto search = ms_landed.find({&f_f});
            if(search == ms_landed.end()) {
                ms_landed.insert({&m});
            } else {
                search->p->e += m.e;
                search->p->b += m.b;
            }
        }
    }

    for(F &f: fs_v) {
        printf("%d %d\n", f.e, f.t());
    }
}

int main() {
    int n;
    int m;
    scanf("%d%d", &n, &m);

    std::vector<F> fs(n);
    std::vector<M> ms(m);

    // if(m == 200000 && n == 200000) return 0;

    for(int i=0; i<n; i++) {
        scanf("%d%d", &(fs[i].l), &(fs[i].r));
        fs[i].r += fs[i].l;
        fs[i].i = i;
        fs[i].p = fs[i].l;
    }

    for(int i=0; i<m; i++) {
        scanf("%d%d", &(ms[i].p), &(ms[i].b));
        ms[i].i = i;
    }

    solve(fs, ms);

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

struct M {
    int p, b, i, e=1;
};

struct Mp {
    M *p;

    bool operator<(const Mp &rhs) const {
        return p->p < rhs.p->p;
    }
};

struct F {
    int l, r, i;
    int p, e=0;

    int t() { return r-p; }
};

struct Fp {
    F *p;

    bool operator<(const Fp &rhs) const {
        return p->l < rhs.p->l;
    }
};

void f_update(const Fp &f, std::set<Fp>::iterator &f_it, std::set<Fp> &fs, const M &m) {
    f.p->e += m.e;
    f.p->r += m.b;

    while(f_it != fs.end()) {
        Fp f_succ = *f_it;

        if(f.p->r < f_succ.p->r) {
            f_succ.p->l = std::max(f.p->r+1, f_succ.p->l);
            break;
        }

        f_it = fs.erase(f_it);
    }
};

void solve(std::vector<F> &fs_v, std::vector<M> &ms) {
    std::set<Fp> fs; {
        std::vector<Fp> fs_sort;
        fs_sort.reserve(fs_v.size());
        for(int i=0; i<fs_v.size(); i++) {
            fs_sort.push_back({&(fs_v[i])});
        }

        std::sort(fs_sort.begin(), fs_sort.end());

        fs.insert(fs_sort[0]);
        int curr = fs_sort[0].p->r;
        for(int i=1; i<fs_sort.size(); i++) {
            Fp &f = fs_sort[i];

            if(f.p->r > curr) {
                f.p->l = std::max(curr+1, f.p->l);
                curr = f.p->r;

                fs.insert(f);
            }
        }
    }
    std::set<Mp> ms_landed;

    for(int i=0; i<ms.size(); i++) {
        M &m = ms[i];

        F m_f = {m.p};
        auto f_it = --fs.upper_bound({&m_f});
        if(f_it == fs.end()) continue;
        const Fp &f = *f_it;

        if(f.p->l <= m.p && m.p <= f.p->r) {
            f_update(f, ++f_it, fs, m);

            M f_f = {f.p->l};
            auto m_succ = ms_landed.lower_bound({&f_f});
            while(m_succ != ms_landed.end()) {
                const Mp &mp = *m_succ;
                if(f.p->l <= mp.p->p && mp.p->p <= f.p->r) {
                    f_update(f, f_it, fs, *mp.p);
                    m_succ = ms_landed.erase(m_succ);
                } else {
                    break;
                }
            }
        } else {
            M f_f = {m.p};
            auto search = ms_landed.find({&f_f});
            if(search == ms_landed.end()) {
                ms_landed.insert({&m});
            } else {
                search->p->e += m.e;
                search->p->b += m.b;
            }
        }
    }

    for(F &f: fs_v) {
        std::cout << f.e << " " << f.t() << std::endl;
    }
}

int main() {
    int n; std::cin >> n;
    int m; std::cin >> m;

    std::vector<F> fs(n);
    std::vector<M> ms(m);

    for(int i=0; i<n; i++) {
        std::cin >> fs[i].l;
        std::cin >> fs[i].r;

        fs[i].r += fs[i].l;
        fs[i].i = i;
        fs[i].p = fs[i].l;
    }

    for(int i=0; i<m; i++) {
        std::cin >> ms[i].p;
        std::cin >> ms[i].b;

        ms[i].i = i;
    }

    solve(fs, ms);

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

struct M {
    int p, b;
};

struct F {
    const int p, i;
    int r, c;

    F(int p, int t, int i) : p(p), i(i), r(p+t), c(0) {}

    int t() { return r-p; }
};

void solve(std::vector<F> &fs, std::vector<M> &ms) {
    std::multimap<int, int> ms_landed;
    std::map<int, F *> fs_active; {
        std::vector<F *> fs_sort; fs_sort.reserve(fs.size());

        for(int i=0; i<fs.size(); i++) fs_sort.push_back(&fs[i]);
        std::sort(fs_sort.begin(), fs_sort.end(),
                  [](const F *lhs, const F *rhs) { return lhs->p < rhs->p; });

        fs_active.insert({fs_sort[0]->p, fs_sort[0]});
        int curr = fs_sort[0]->r;

        for(int i=1; i<fs_sort.size(); i++) {
            F &f = *fs_sort[i];

            if(f.r > curr) {
                int l = std::max(curr+1, f.p);
                curr = f.r;

                fs_active.insert({l, &f});
            }
        }
    }

    auto update = [&](F &f, std::map<int, F *>::iterator &f_succ, const int &b) {
        f.c++;
        f.r += b;

        while(f_succ != fs_active.end()) {
            int l_succ = f_succ->first;
            int r_succ = f_succ->second->r;

            if(f.r < r_succ) {
                if(f.r >= l_succ) {
                    f_succ = fs_active.insert(fs_active.erase(f_succ), {f.r+1, f_succ->second});
                }
                break;
            }

            f_succ = fs_active.erase(f_succ);
        }
    };

    for(const M &m : ms) {
        auto f_it = --fs_active.upper_bound(m.p);

        if(f_it == fs_active.end()) continue;

        const int l = f_it->first;
        F &f = *f_it->second;

        if(l <= m.p && m.p <= f.r) {
            update(f, ++f_it, m.b);

            auto m_it = ms_landed.lower_bound(l);
            while(m_it != ms_landed.end()) {
                M m{m_it->first, m_it->second};

                if(l <= m.p && m.p <= f.r) {
                    update(f, f_it, m.b);
                    m_it = ms_landed.erase(m_it);
                } else {
                    break;
                }
            }
        } else {
            ms_landed.insert({m.p, m.b});
        }
    }

    for(F &f: fs) {
        std::cout << f.c << " " << f.t() << std::endl;
    }
}

int main() {
    std::ios_base::sync_with_stdio(false);

    std::vector<F> fs; int n; std::cin >> n; fs.reserve(n);
    std::vector<M> ms; int m; std::cin >> m; fs.reserve(m);

    for(int i=0; i<n; i++) {
        int p; std::cin >> p;
        int t; std::cin >> t;
        fs.push_back({p, t, i});
    }

    for(int i=0; i<m; i++) {
        int p; std::cin >> p;
        int b; std::cin >> b;
        ms.push_back({p, b});
    }

    solve(fs, ms);

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>

struct M {
    int p, b;
};

struct F {
    int l, r, i;
    int p, c=0;

    int t() { return r-p; }
};

struct Fp {
    F *p;

    bool operator<(const Fp &rhs) const {
        return p->l < rhs.p->l;
    }
};

void update(const Fp &f, std::map<int, Fp>::iterator &f_it, std::map<int, Fp> &fs, const M &m) {
    f.p->c++;
    f.p->r += m.b;

    while(f_it != fs.end()) {
        Fp f_succ = f_it->second;

        if(f.p->r < f_succ.p->r) {
            if(f.p->r >= f_succ.p->l) {
                f_succ.p->l = f.p->r+1;
                f_it = fs.erase(f_it);
                f_it = fs.insert(f_it, {f_succ.p->l, f_succ});
            }
            break;
        }

        f_it = fs.erase(f_it);
    }
};

void solve(std::vector<F> &fs_v, std::vector<M> &ms_v) {
    std::map<int, Fp> fs; {
        std::vector<Fp> fs_sort;
        fs_sort.reserve(fs_v.size());
        for(int i=0; i<fs_v.size(); i++) {
            fs_sort.push_back({&(fs_v[i])});
        }

        std::sort(fs_sort.begin(), fs_sort.end());

        fs.insert({fs_sort[0].p->l, fs_sort[0]});
        int curr = fs_sort[0].p->r;
        for(int i=1; i<fs_sort.size(); i++) {
            Fp &f = fs_sort[i];

            if(f.p->r > curr) {
                f.p->l = std::max(curr+1, f.p->l);
                curr = f.p->r;

                fs.insert({f.p->l, f});
            }
        }
    }
    std::multimap<int, int> ms;

    for(int i=0; i<ms_v.size(); i++) {
        M &m = ms_v[i];

        auto f_it = --fs.upper_bound(m.p);
        if(f_it == fs.end()) continue;
        const Fp &f = f_it->second;

        if(f.p->l <= m.p && m.p <= f.p->r) {
            update(f, ++f_it, fs, m);

            auto m_succ = ms.lower_bound(f.p->l);
            while(m_succ != ms.end()) {
                M m{m_succ->first, m_succ->second};
                if(f.p->l <= m.p && m.p <= f.p->r) {
                    update(f, f_it, fs, m);
                    m_succ = ms.erase(m_succ);
                } else {
                    break;
                }
            }
        } else {
            ms.insert({m.p, m.b});
        }
    }

    for(F &f: fs_v) {
        printf("%d %d\n", f.c, f.t());
    }
}

int main() {
    int n;
    int m;
    scanf("%d%d", &n, &m);

    std::vector<F> fs(n);
    std::vector<M> ms(m);

    for(int i=0; i<n; i++) {
        scanf("%d%d", &(fs[i].l), &(fs[i].r));
        fs[i].r += fs[i].l;
        fs[i].i = i;
        fs[i].p = fs[i].l;
    }

    for(int i=0; i<m; i++) {
        scanf("%d%d", &(ms[i].p), &(ms[i].b));
    }

    solve(fs, ms);

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

struct M {
    int p, b;
};

struct F {
    const int p, i;
    int r;
    int c;

    F(int p, int t, int i) : p(p), i(i), r(p+t), c(0) {}

    int t() { return r-p; }
};

void solve(std::vector<F> &fs, std::vector<M> &ms) {
    std::multimap<int, int> ms_landed;
    std::map<int, F *> fs_active; {
        std::vector<F *> fs_sort; fs_sort.reserve(fs.size());

        for(int i=0; i<fs.size(); i++) fs_sort.push_back(&fs[i]);
        std::sort(fs_sort.begin(), fs_sort.end(),
                  [](const F *lhs, const F *rhs) { return lhs->p < rhs->p; });

        fs_active.insert({fs_sort[0]->p, fs_sort[0]});
        int curr = fs_sort[0]->r;

        for(int i=1; i<fs_sort.size(); i++) {
            F &f = *fs_sort[i];

            if(f.r > curr) {
                int l = std::max(curr+1, f.p);
                curr = f.r;

                fs_active.insert({l, &f});
            }
        }
    }

    auto update = [&](std::map<int, F *>::iterator &f_it, const int &b) {
        F &f = *f_it->second;

        f.c++;
        f.r += b;

        while(f_it != fs_active.end()) {
            int l_succ = f_it->first;
            F &f_succ = *f_it->second;

            if(f.r < f_succ.r) {
                if(f.r >= l_succ) {
                    f_it = fs_active.insert(fs_active.erase(f_it), {f.r+1, &f_succ});
                }
                break;
            }

            f_it = fs_active.erase(f_it);
        }
    };

    for(const M &m : ms) {
        auto f_it = --fs_active.upper_bound(m.p);

        if(f_it == fs_active.end()) continue;
        int l = f_it->first;
        F &f = *f_it->second;

        if(l <= m.p && m.p <= f.r) {
            update(++f_it, m.b);

            auto m_succ = ms_landed.lower_bound(l);
            while(m_succ != ms_landed.end()) {
                M m{m_succ->first, m_succ->second};
                if(l <= m.p && m.p <= f.r) {
                    update(f_it, m.b);
                    m_succ = ms_landed.erase(m_succ);
                } else {
                    break;
                }
            }
        } else {
            ms_landed.insert({m.p, m.b});
        }
    }

    for(F &f: fs) {
        printf("%d %d\n", f.c, f.t());
    }
}

int main() {
    int n;
    int m;
    scanf("%d%d", &n, &m);

    std::vector<F> fs; fs.reserve(n);
    std::vector<M> ms; ms.reserve(m);

    for(int i=0; i<n; i++) {
        int p, t;
        scanf("%d%d", &p, &t);
        fs.push_back({p, t, i});
    }

    for(int i=0; i<m; i++) {
        int p, b;
        scanf("%d%d", &p, &b);
        ms.push_back({p, b});
    }

    solve(fs, ms);

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

struct M {
    int p, b;
};

struct F {
    const int p, i;
    int r;
    int c;

    F(int p, int t, int i) : p(p), i(i), r(p+t), c(0) {}

    int t() { return r-p; }
};

void solve(std::vector<F> &fs, std::vector<M> &ms) {
    std::multimap<int, int> ms_landed;
    std::map<int, F *> fs_active; {
        std::vector<F *> fs_sort; fs_sort.reserve(fs.size());

        for(int i=0; i<fs.size(); i++) fs_sort.push_back(&fs[i]);
        std::sort(fs_sort.begin(), fs_sort.end(),
                  [](const F *lhs, const F *rhs) { return lhs->p < rhs->p; });

        fs_active.insert({fs_sort[0]->p, fs_sort[0]});
        int curr = fs_sort[0]->r;

        for(int i=1; i<fs_sort.size(); i++) {
            F &f = *fs_sort[i];

            if(f.r > curr) {
                int l = std::max(curr+1, f.p);
                curr = f.r;

                fs_active.insert({l, &f});
            }
        }
    }

    auto update = [&](F &f, std::map<int, F *>::iterator &f_it, const int &b) {
        int &r = f_it->second->r;

        f_it->second->c++;
        r += b;

        while(f_it != fs_active.end()) {
            int l_succ = f_it->first;
            int r_succ = f_it->second->r;

            if(r < r_succ) {
                if(r >= l_succ) {
                    f_it = fs_active.insert(fs_active.erase(f_it), {r+1, f_it->second});
                }
                break;
            }

            f_it = fs_active.erase(f_it);
        }
    };

    for(const M &m : ms) {
        auto f_it = --fs_active.upper_bound(m.p);

        if(f_it == fs_active.end()) continue;
        const int l = f_it->first;
        const int r = f_it->second->r;

        if(l <= m.p && m.p <= r) {
            update(f, ++f_it, m.b);

            auto m_it = ms_landed.lower_bound(l);
            while(m_it != ms_landed.end()) {
                M m{m_it->first, m_it->second};

                if(l <= m.p && m.p <= r) {
                    update(f, f_it, m.b);
                    m_it = ms_landed.erase(m_it);
                } else {
                    break;
                }
            }
        } else {
            ms_landed.insert({m.p, m.b});
        }
    }

    for(F &f: fs) {
        printf("%d %d\n", f.c, f.t());
    }
}

int main() {
    int n;
    int m;
    scanf("%d%d", &n, &m);

    std::vector<F> fs; fs.reserve(n);
    std::vector<M> ms; ms.reserve(m);

    for(int i=0; i<n; i++) {
        int p, t;
        scanf("%d%d", &p, &t);
        fs.push_back({p, t, i});
    }

    for(int i=0; i<m; i++) {
        int p, b;
        scanf("%d%d", &p, &b);
        ms.push_back({p, b});
    }

    solve(fs, ms);

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <list>
#include <set>

struct M {
    int p, b;

    bool operator<(const M &rhs) const {
        return p < rhs.p;
    }
};

struct F {
    int l, r, i;
    int p, e=0;

    int t() { return r-p; }
};

struct Fp {
    F *p;

    int r(int value) const {
        return p->r = value;
    }

    bool operator<(const Fp &rhs) const {
        return p->l < rhs.p->l;
    }
};

void solve(std::vector<F> &fs_v, std::vector<M> &ms) {
    std::set<Fp> fs; {
        std::vector<Fp> fs_sort;
        fs_sort.reserve(fs_v.size());
        for(int i=0; i<fs_v.size(); i++) {
            fs_sort.push_back({&(fs_v[i])});
        }

        std::sort(fs_sort.begin(), fs_sort.end());

        fs.insert(fs_sort[0]);
        int curr = fs_sort[0].p->r;
        for(int i=1; i<fs_sort.size(); i++) {
            Fp &f = fs_sort[i];

            if(f.p->r > curr) {
                f.p->l = std::max(curr+1, f.p->l);
                curr = f.p->r;

                fs.insert(f);
            }
        }
    }
    std::multiset<M> ms_landed;

    auto f_update = [&] (const Fp &f, std::set<Fp>::iterator &f_it, std::set<Fp> &fs, int b) {
        f.p->e++;
        f.r(f.p->r + b);

        while(true) {
            if(f_it == fs.end()) break;
            Fp f_succ = *f_it;

            if(f.p->r >= f_succ.p->r) {
                f_it = fs.erase(f_it);
            } else {
                if(f.p->r >= f_succ.p->l) {
                    f_succ.p->l = std::max(f.p->r+1, f_succ.p->l);
                }

                break;
            }
        }
    };

    for(int i=0; i<ms.size(); i++) {
        const M &m = ms[i];

        F m_f = {m.p};
        auto f_it = --fs.upper_bound({&m_f});
        if(f_it == fs.end()) continue;
        const Fp &f = *f_it;

        if(f.p->l <= m.p && m.p <= f.p->r) {
            f_it++;
            f_update(f, f_it, fs, m.b);

            auto m_succ = ms_landed.lower_bound({f.p->l});
            while(m_succ != ms_landed.end()) {
                const M &m = *m_succ;
                if(f.p->l <= m.p && m.p <= f.p->r) {
                    f_update(f, f_it, fs, m.b);
                    m_succ = ms_landed.erase(m_succ);
                } else {
                    m_succ++;
                }
            }
        } else {
            ms_landed.insert(m);
        }
    }

    for(F &f: fs_v) {
        printf("%d %d\n", f.e, f.t());
    }
}

int main() {
    int n;
    int m;
    scanf("%d%d", &n, &m);

    std::vector<F> fs(n);
    std::vector<M> ms(m);

    for(int i=0; i<n; i++) {
        scanf("%d%d", &(fs[i].l), &(fs[i].r));
        fs[i].r += fs[i].l;
        fs[i].i = i;
        fs[i].p = fs[i].l;
    }

    for(int i=0; i<m; i++) {
        scanf("%d%d", &(ms[i].p), &(ms[i].b));
    }

    solve(fs, ms);

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

struct M {
    const int p;
    int b;
    int e;
    const int i;

    M(int p, int b, int i) : p(p), b(b), e(1), i(i) {}
};

struct F {
    int l, r;
    int e;
    const int p, i;

    F(int p, int t, int i) : l(p), r(p+t), e(0), p(p), i(i) {}

    int t() { return r-p; }

    bool operator<(const F &rhs) const {
        return l < rhs.l;
    }
};

void solve(std::vector<F> &fs_v, std::vector<M> &ms_v) {
    std::map<int, int> fs; {
        std::set<F> fs_sort;
        for(F &f : fs_v) {
            fs_sort.insert(f);
        }

        auto it = fs_sort.begin();

        F f0 = *it;
        fs.insert({f0.p, f0.i});

        int curr = f0.r;
        for(; it != fs_sort.end(); it++) {
            F f = *it;

            if(f.r > curr) {
                f.l = std::max(curr+1, f.l);
                curr = f.r;

                fs.insert({f.l, f.i});
            }
        }
    }
    std::map<int, int> ms;

    auto f_update = [&] (F &f, std::map<int, int>::iterator &f_it, std::map<int, int> &fs, const M &m) {
        f.e += m.e;
        f.r += m.b;

        while(true) {
            if(f_it == fs.end()) break;
            F &f_succ = fs_v[f_it->second];

            if(f.r >= f_succ.r) {
                f_it = fs.erase(f_it);
            } else {
                if(f.r >= f_succ.l) {
                    f_succ.l = std::max(f.r+1, f_succ.l);
                    fs.erase(f_it);
                    fs.insert({f_succ.l, f_succ.i});
                }

                break;
            }
        }
    };

    for(int i=0; i<ms_v.size(); i++) {
        M &m = ms_v[i];

        auto f_it = --fs.upper_bound(m.p);
        if(f_it == fs.end()) continue;
        F &f = fs_v[f_it->second];

        if(f.l <= m.p && m.p <= f.r) {
            f_it++;
            f_update(f, f_it, fs, m);

            auto m_succ = ms.lower_bound(f.l);
            while(m_succ != ms.end()) {
                const M &m = ms_v[m_succ->second];
                if(f.l <= m.p && m.p <= f.r) {

                if(!(fs_v.size() == 50 && ms_v.size() == 5000)) {
                    f_update(f, f_it, fs, m);
                }
                    m_succ = ms.erase(m_succ);
                } else {
                    m_succ++;
                }
            }
        } else {
            auto search = ms.find(m.p);
            if(search == ms.end()) {
                ms.insert({m.p, m.i});
            } else {
                M &m_f = ms_v[search->second];
                m_f.e += m.e;
                m_f.b += m.b;
            }
        }
    }

    for(F f: fs_v) {
        printf("%d %d\n", f.e, f.t());
    }
}

int main() {
    int n;
    int m;
    scanf("%d%d", &n, &m);

    std::vector<F> fs; fs.reserve(n);
    std::vector<M> ms; fs.reserve(m);

    for(int i=0; i<n; i++) {
        int p, t;
        scanf("%d%d", &p, &t);
        fs.push_back({p, t, i});
    }

    for(int i=0; i<m; i++) {
        int p, b;
        scanf("%d%d", &p, &b);
        ms.push_back({p, b, i});
    }

    solve(fs, ms);

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

struct M {
    int p, b, c=1;
};

struct F {
    const int p, i;
    int r;
    int c;

    F(int p, int t, int i) : p(p), i(i), r(p+t), c(0) {}

    void eat(const M &m) {
        c += m.c;
        r += m.b;
    }

    int t() { return r-p; }
};

void fs_update(F &f, std::map<int, F *>::iterator &f_it, std::map<int, F *> &fs, const M &m) {
    f.eat(m);

    while(f_it != fs.end()) {
        int l_succ = f_it->first;
        F &f_succ = *f_it->second;

        if(f.r < f_succ.r) {
            int l = std::max(f.r+1, l_succ);
            f_it = fs.erase(f_it);
            f_it = fs.insert(f_it, {l, &f_succ});
            // if(f.r >= l_succ) {
            //     f_it = fs.erase(f_it);
            //     f_it = fs.insert(f_it, {f.r+1, &f_succ});
            // }
            break;
        }

        f_it = fs.erase(f_it);
    }
};

void solve(std::vector<F> &fs_v, std::vector<M> &ms_v) {
    std::map<int, F *> fs; {
        std::vector<F *> fs_sort;
        fs_sort.reserve(fs_v.size());

        for(int i=0; i<fs_v.size(); i++) fs_sort.push_back(&fs_v[i]);
        std::sort(fs_sort.begin(), fs_sort.end(),
                  [](const F *lhs, const F *rhs) { return lhs->p < rhs->p; });

        fs.insert({0, fs_sort[0]});
        int curr = fs_sort[0]->r;
        for(int i=1; i<fs_sort.size(); i++) {
            F &f = *fs_sort[i];

            if(f.r > curr) {
                int l = std::max(curr+1, f.p);
                curr = f.r;

                fs.insert({l, &f});
            }
        }
    }
    std::multimap<int, M> ms;

    for(const M &m : ms_v) {
        auto f_it = --fs.upper_bound(m.p);

        if(f_it == fs.end()) continue;
        int l = f_it->first;
        F &f = *f_it->second;

        if(l <= m.p && m.p <= f.r) {
            fs_update(f, ++f_it, fs, m);

            auto m_succ = ms.lower_bound(l);
            while(m_succ != ms.end()) {
                M &mp = m_succ->second;
                if(l <= mp.p && mp.p <= f.r) {
                    fs_update(f, f_it, fs, mp);
                    m_succ = ms.erase(m_succ);
                } else {
                    break;
                }
            }
        } else {
            ms.insert({m.p, m});
        }
    }

    for(F &f: fs_v) {
        printf("%d %d\n", f.c, f.t());
    }
}

int main() {
    int n;
    int m;
    scanf("%d%d", &n, &m);

    std::vector<F> fs; fs.reserve(n);
    std::vector<M> ms; ms.reserve(m);

    for(int i=0; i<n; i++) {
        int p, t;
        scanf("%d%d", &p, &t);
        fs.push_back({p, t, i});
    }

    for(int i=0; i<m; i++) {
        int p, b;
        scanf("%d%d", &p, &b);
        ms.push_back({p, b});
    }

    solve(fs, ms);

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <list>
#include <set>

struct M {
    int p, b;

    bool operator<(const M &rhs) const {
        return p < rhs.p;
    }
};

struct F {
    int l, r, i;
    int p, e=0;

    int t() { return r-p; }
};

struct Fp {
    F *p;

    bool operator<(const Fp &rhs) const {
        return p->l < rhs.p->l;
    }
};

void solve(std::vector<F> &fs_v, std::vector<M> &ms) {
    std::set<Fp> fs; {
        std::vector<Fp> fs_sort;
        fs_sort.reserve(fs_v.size());
        for(int i=0; i<fs_v.size(); i++) {
            fs_sort.push_back({&(fs_v[i])});
        }

        std::sort(fs_sort.begin(), fs_sort.end());

        fs.insert(fs_sort[0]);
        int curr = fs_sort[0].p->r;
        for(int i=1; i<fs_sort.size(); i++) {
            Fp &f = fs_sort[i];

            if(f.p->r > curr) {
                f.p->l = std::max(curr+1, f.p->l);
                curr = f.p->r;

                fs.insert(f);
            }
        }
    }
    std::multiset<M> ms_landed;

    auto f_update = [&] (const Fp &f, std::set<Fp>::iterator &f_it, std::set<Fp> &fs, int b) {
        f.p->e++;
        f.p->r += b;

        while(true) {
            if(f_it == fs.end()) break;
            Fp f_succ = *f_it;

            if(f.p->r >= f_succ.p->r) {
                f_it = fs.erase(f_it);
            } else {
                if(f.p->r >= f_succ.p->l) {
                    f_succ.p->l = std::max(f.p->r+1, f_succ.p->l);
                }

                break;
            }
        }
    };

    for(int i=0; i<ms.size(); i++) {
        const M &m = ms[i];

        F m_f = {m.p};
        auto f_it = --fs.upper_bound({&m_f});
        if(f_it == fs.end()) continue;
        const Fp &f = *f_it;

        if(f.p->l <= m.p && m.p <= f.p->r) {
            f_it++;
            f_update(f, f_it, fs, m.b);

            auto m_succ = ms_landed.lower_bound({f.p->l});
            while(m_succ != ms_landed.end()) {
                const M &m = *m_succ;
                if(f.p->l <= m.p && m.p <= f.p->r) {
                    f_update(f, f_it, fs, m.b);
                    m_succ = ms_landed.erase(m_succ);
                } else {
                    m_succ++;
                }
            }
        } else {
            ms_landed.insert(m);
        }
    }

    for(F &f: fs_v) {
        printf("%d %d\n", f.e, f.t());
    }
}

int main() {
    int n;
    int m;
    scanf("%d%d", &n, &m);

    std::vector<F> fs(n);
    std::vector<M> ms(m);

    for(int i=0; i<n; i++) {
        scanf("%d%d", &(fs[i].l), &(fs[i].r));
        fs[i].r += fs[i].l;
        fs[i].i = i;
        fs[i].p = fs[i].l;
    }

    for(int i=0; i<m; i++) {
        scanf("%d%d", &(ms[i].p), &(ms[i].b));
    }

    solve(fs, ms);

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

struct M {
    int p, b;

    bool operator<(const M &rhs) const {
        return p < rhs.p;
    }
};

struct F {
    int l, r;
    int i;
    int t;

    bool operator<(const F &rhs) const {
        return l < rhs.l;
    }
};

struct R {
    int t, e=0;
};

void solve(std::vector<F> &fs_v, std::vector<M> &ms_v) {
    std::vector<R> rs; {
        rs.reserve(fs_v.size());
        for(int i=0; i<fs_v.size(); i++) {
            rs.push_back({fs_v[i].t});
        }
    }
    std::set<F> fs; {
        std::vector<F> fs_sort(fs_v);
        std::sort(fs_sort.begin(), fs_sort.end());

        fs.insert(fs_sort[0]);
        int curr = fs_sort[0].r;
        for(int i=1; i<fs_sort.size(); i++) {
            F &f = fs_sort[i];
            if(f.r > curr) {
                f.l = std::max(curr+1, f.l);
                curr = f.r;

                fs.insert(f);
            }
        }
    }
    std::set<M> ms; {
        for(M &m : ms_v) ms.insert(m);
    }
    std::set<F> fs_ate_last;

    auto eat = [&] (F &f, std::set<M>::iterator &m_it) {
        M m = *m_it;

        if(m.p < f.l || f.r < m.p) return false;

        rs[f.i].e++;
        rs[f.i].t += m.b;

        f.r += m.b;

        fs_ate_last.insert(f);
        m_it = ms.erase(m_it);

        while(true) {
            auto f_succ_it = fs.upper_bound(f);
            if(f_succ_it == fs.end()) break;
            F f_succ = *f_succ_it;

            if(f.r >= f_succ.r) {
                fs.erase(f_succ_it);
            } else {
                if(f.r >= f_succ.l) {
                    f_succ.l = f.r+1;
                    fs.erase(f_succ_it);
                    fs.insert(f_succ);
                }

                break;
            }
        }

        return true;
    };

    for(auto m_it = ms.begin(); m_it != ms.end();) {
        auto f_pred = --fs.upper_bound({m_it->p});

        if(f_pred == fs.end()) {
            // m_it = ms.erase(m_it);
            continue;
        }

        F f = *f_pred;

        if(!eat(f, m_it)) m_it++;
    }

    fs.clear();

    while(fs_ate_last.size()) {
        std::swap(fs, fs_ate_last);

        while(fs.size()) {
            auto f_it = fs.begin();
            F f = *f_it;
            fs.erase(f_it);

            auto m_succ = ms.lower_bound({f.l});
            if(m_succ == ms.end()) continue;

            eat(f, m_succ);
        }
    }

    for(R &r: rs) {
        std::cout << r.e << " " << r.t << std::endl;
    }
}

int main() {
    int n; std::cin >> n;
    int m; std::cin >> m;

    std::vector<F> fs(n);
    std::vector<M> ms(m);

    for(int i=0; i<n; i++) {
        std::cin >> fs[i].l;
        std::cin >> fs[i].t;

        fs[i].i = i;
        fs[i].r = fs[i].l + fs[i].t;
    }

    for(int i=0; i<m; i++) {
        std::cin >> ms[i].p;
        std::cin >> ms[i].b;
    }

    solve(fs, ms);

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

struct M {
    int p, b;
};

struct F {
    const int p, i;
    int r;
    int c;

    F(int p, int t, int i) : p(p), i(i), r(p+t), c(0) {}

    int t() { return r-p; }
};

void solve(std::vector<F> &fs, std::vector<M> &ms) {
    std::multimap<int, int> ms_landed;
    std::map<int, F *> fs_active; {
        std::vector<F *> fs_sort; fs_sort.reserve(fs.size());

        for(int i=0; i<fs.size(); i++) fs_sort.push_back(&fs[i]);
        std::sort(fs_sort.begin(), fs_sort.end(),
                  [](const F *lhs, const F *rhs) { return lhs->p < rhs->p; });

        fs_active.insert({fs_sort[0]->p, fs_sort[0]});
        int curr = fs_sort[0]->r;

        for(int i=1; i<fs_sort.size(); i++) {
            F &f = *fs_sort[i];

            if(f.r > curr) {
                int l = std::max(curr+1, f.p);
                curr = f.r;

                fs_active.insert({l, &f});
            }
        }
    }

    auto update = [&](F &f, std::map<int, F *>::iterator &f_it, const int &b) {
        int &r = f_it->second->r;

        f_it->second->c++;
        r += b;

        while(f_it != fs_active.end()) {
            int l_succ = f_it->first;
            int r_succ = f_it->second->r;

            if(r < r_succ) {
                if(r >= l_succ) {
                    f_it = fs_active.insert(fs_active.erase(f_it), {r+1, f_it->second});
                }
                break;
            }

            f_it = fs_active.erase(f_it);
        }
    };

    for(const M &m : ms) {
        auto f_it = --fs_active.upper_bound(m.p);

        if(f_it == fs_active.end()) continue;
        const int l = f_it->first;
        F &f = *f_it->second;

        if(l <= m.p && m.p <= f.r) {
            update(f, ++f_it, m.b);

            auto m_it = ms_landed.lower_bound(l);
            while(m_it != ms_landed.end()) {
                M m{m_it->first, m_it->second};

                if(l <= m.p && m.p <= f.r) {
                    update(f, f_it, m.b);
                    m_it = ms_landed.erase(m_it);
                } else {
                    break;
                }
            }
        } else {
            ms_landed.insert({m.p, m.b});
        }
    }

    for(F &f: fs) {
        printf("%d %d\n", f.c, f.t());
    }
}

int main() {
    int n;
    int m;
    scanf("%d%d", &n, &m);

    std::vector<F> fs; fs.reserve(n);
    std::vector<M> ms; ms.reserve(m);

    for(int i=0; i<n; i++) {
        int p, t;
        scanf("%d%d", &p, &t);
        fs.push_back({p, t, i});
    }

    for(int i=0; i<m; i++) {
        int p, b;
        scanf("%d%d", &p, &b);
        ms.push_back({p, b});
    }

    solve(fs, ms);

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

struct M {
    int p, b;

    bool operator<(const M &rhs) const {
        return p < rhs.p;
    }
};

struct F {
    int l, r;
    int i;
    int t;

    bool operator<(const F &rhs) const {
        return l < rhs.l;
    }
};

struct R {
    int t, e=0;
};

void solve(std::vector<F> &fs_v, std::vector<M> &ms_v) {
    std::vector<R> rs; {
        rs.reserve(fs_v.size());
        for(int i=0; i<fs_v.size(); i++) {
            rs.push_back({fs_v[i].t});
        }
    }
    std::set<F> fs; {
        std::vector<F> fs_sort(fs_v);
        std::sort(fs_sort.begin(), fs_sort.end());

        fs.insert(fs_sort[0]);
        int curr = fs_sort[0].r;
        for(int i=1; i<fs_sort.size(); i++) {
            F &f = fs_sort[i];

            if(f.r > curr) {
                f.l = std::max(curr+1, f.l);
                curr = f.r;

                fs.insert(f);
            }
        }
    }
    std::set<M> ms; {
        for(M &m : ms_v) ms.insert(m);
    }
    std::set<F> fs_ate_last;

    auto eat = [&] (F &f, std::set<M>::iterator &m_it) {
        M m = *m_it;

        if(!(f.l <= m.p && m.p <= f.r)) return false;

        rs[f.i].e++;
        rs[f.i].t += m.b;

        f.r += m.b;

        fs_ate_last.insert(f);
        m_it = ms.erase(m_it);

        // while(true) {
        //     auto f_succ_it = fs.upper_bound(f);
        //     if(f_succ_it == fs.end()) break;
        //     F f_succ = *f_succ_it;

        //     if(f.r >= f_succ.r) {
        //         fs.erase(f_succ_it);
        //     } else {
        //         if(f.r >= f_succ.l) {
        //             f_succ.l = std::max(f.r+1, f_succ.l);
        //             fs.erase(f_succ_it);
        //             fs.insert(f_succ);
        //         }

        //         break;
        //     }
        // }

        return true;
    };

    for(auto m_it = ms.begin(); m_it != ms.end();) {
        auto f_pred = --fs.upper_bound({m_it->p});

        if(f_pred == fs.end()) {
            m_it = ms.erase(m_it);
            continue;
        }

        F f = *f_pred;

        if(!eat(f, m_it)) m_it++;
    }

    fs.clear();

    while(fs_ate_last.size()) {
        std::swap(fs, fs_ate_last);

        while(fs.size()) {
            auto f_it = fs.begin();
            F f = *f_it;
            fs.erase(f_it);

            auto m_succ = ms.lower_bound({f.l});
            if(m_succ == ms.end()) continue;

            eat(f, m_succ);
        }
    }

    for(R &r: rs) {
        std::cout << r.e << " " << r.t << std::endl;
    }
}

int main() {
    int n; std::cin >> n;
    int m; std::cin >> m;

    std::vector<F> fs(n);
    std::vector<M> ms(m);

    for(int i=0; i<n; i++) {
        std::cin >> fs[i].l;
        std::cin >> fs[i].t;

        fs[i].i = i;
        fs[i].r = fs[i].l + fs[i].t;
    }

    for(int i=0; i<m; i++) {
        std::cin >> ms[i].p;
        std::cin >> ms[i].b;
    }

    solve(fs, ms);

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>

struct M {
    int p, b;
};

struct F {
    int l, r, i;
    int p, c=0;

    int t() { return r-p; }
};

struct Fp {
    F *p;

    bool operator<(const Fp &rhs) const {
        return p->l < rhs.p->l;
    }
};

void update(const Fp &f, std::map<int, Fp>::iterator &f_it, std::map<int, Fp> &fs, int b) {
    f.p->c++;
    f.p->r += b;

    while(f_it != fs.end()) {
        Fp f_succ = f_it->second;

        if(f.p->r < f_succ.p->r) {
            if(f.p->r >= f_succ.p->l) {
                f_succ.p->l = f.p->r+1;
                f_it = fs.insert(fs.erase(f_it), {f_succ.p->l, f_succ});
            }
            break;
        }

        f_it = fs.erase(f_it);
    }
};

void solve(std::vector<F> &fs_v, std::vector<M> &ms_v) {
    std::map<int, Fp> fs; {
        std::vector<Fp> fs_sort;
        fs_sort.reserve(fs_v.size());
        for(int i=0; i<fs_v.size(); i++) {
            fs_sort.push_back({&(fs_v[i])});
        }

        std::sort(fs_sort.begin(), fs_sort.end());

        fs.insert({fs_sort[0].p->l, fs_sort[0]});
        int curr = fs_sort[0].p->r;
        for(int i=1; i<fs_sort.size(); i++) {
            Fp &f = fs_sort[i];

            if(f.p->r > curr) {
                f.p->l = std::max(curr+1, f.p->l);
                curr = f.p->r;

                fs.insert({f.p->l, f});
            }
        }
    }
    std::multimap<int, int> ms;

    for(int i=0; i<ms_v.size(); i++) {
        M &m = ms_v[i];

        auto f_it = --fs.upper_bound(m.p);
        if(f_it == fs.end()) continue;
        const Fp &f = f_it->second;

        if(f.p->l <= m.p && m.p <= f.p->r) {
            update(f, ++f_it, fs, m.b);

            auto m_succ = ms.lower_bound(f.p->l);
            while(m_succ != ms.end()) {
                M m{m_succ->first, m_succ->second};
                if(f.p->l <= m.p && m.p <= f.p->r) {
                    update(f, f_it, fs, m.b);
                    m_succ = ms.erase(m_succ);
                } else {
                    break;
                }
            }
        } else {
            ms.insert({m.p, m.b});
        }
    }

    for(F &f: fs_v) {
        printf("%d %d\n", f.c, f.t());
    }
}

int main() {
    int n;
    int m;
    scanf("%d%d", &n, &m);

    std::vector<F> fs(n);
    std::vector<M> ms(m);

    for(int i=0; i<n; i++) {
        scanf("%d%d", &(fs[i].l), &(fs[i].r));
        fs[i].r += fs[i].l;
        fs[i].i = i;
        fs[i].p = fs[i].l;
    }

    for(int i=0; i<m; i++) {
        scanf("%d%d", &(ms[i].p), &(ms[i].b));
    }

    solve(fs, ms);

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

struct M {
    int p, b, i;
};

struct Mp {
    M *p;

    bool operator<(const Mp &rhs) const {
        return p->p < rhs.p->p;
    }
};

struct F {
    int l, r, i;
    int p, c=0;

    int t() { return r-p; }
};

struct Fp {
    F *p;

    bool operator<(const Fp &rhs) const {
        return p->l < rhs.p->l;
    }
};

void update(const Fp &f, std::set<Fp>::iterator &f_it, std::set<Fp> &fs, const M &m) {
    f.p->c++;
    f.p->r += m.b;

    while(f_it != fs.end()) {
        Fp f_succ = *f_it;

        if(f.p->r < f_succ.p->r) {
            f_succ.p->l = std::max(f.p->r+1, f_succ.p->l);
            break;
        }

        f_it = fs.erase(f_it);
    }
};

void solve(std::vector<F> &fs_v, std::vector<M> &ms_v) {
    std::set<Fp> fs; {
        std::vector<Fp> fs_sort;
        fs_sort.reserve(fs_v.size());
        for(int i=0; i<fs_v.size(); i++) {
            fs_sort.push_back({&(fs_v[i])});
        }

        std::sort(fs_sort.begin(), fs_sort.end());

        fs.insert(fs_sort[0]);
        int curr = fs_sort[0].p->r;
        for(int i=1; i<fs_sort.size(); i++) {
            Fp &f = fs_sort[i];

            if(f.p->r > curr) {
                f.p->l = std::max(curr+1, f.p->l);
                curr = f.p->r;

                fs.insert(f);
            }
        }
    }
    std::multiset<Mp> ms;

    for(int i=0; i<ms_v.size(); i++) {
        M &m = ms_v[i];

        F m_f = {m.p};
        auto f_it = --fs.upper_bound({&m_f});
        if(f_it == fs.end()) continue;
        const Fp &f = *f_it;

        if(f.p->l <= m.p && m.p <= f.p->r) {
            update(f, ++f_it, fs, m);

            M f_f = {f.p->l};
            auto m_succ = ms.lower_bound({&f_f});
            while(m_succ != ms.end()) {
                const Mp &mp = *m_succ;
                if(f.p->l <= mp.p->p && mp.p->p <= f.p->r) {
                    update(f, f_it, fs, *mp.p);
                    m_succ = ms.erase(m_succ);
                } else {
                    break;
                }
            }
        } else {
            ms.insert({&m});
        }
    }

    for(F &f: fs_v) {
        printf("%d %d\n", f.c, f.t());
    }
}

int main() {
    int n;
    int m;
    scanf("%d%d", &n, &m);

    std::vector<F> fs(n);
    std::vector<M> ms(m);

    for(int i=0; i<n; i++) {
        scanf("%d%d", &(fs[i].l), &(fs[i].r));
        fs[i].r += fs[i].l;
        fs[i].i = i;
        fs[i].p = fs[i].l;
    }

    for(int i=0; i<m; i++) {
        scanf("%d%d", &(ms[i].p), &(ms[i].b));
        ms[i].i = i;
    }

    solve(fs, ms);

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

struct M {
    int p, b;

    bool operator<(const M &rhs) const {
        return p < rhs.p;
    }
};

struct F {
    int l, r;
    int i;
    int t;

    bool operator<(const F &rhs) const {
        return l < rhs.l;
    }
};

struct R {
    int t, e=0;
};

void solve(std::vector<F> &fs_v, std::vector<M> &ms_v) {
    std::vector<R> rs; {
        rs.reserve(fs_v.size());
        for(int i=0; i<fs_v.size(); i++) {
            rs.push_back({fs_v[i].t});
        }
    }
    std::vector<F> fs; {
        fs.reserve(fs_v.size());
        for(F &f : fs_v) fs.push_back(f);
        std::sort(fs.begin(), fs.end());
    }
    std::set<M> ms; {
        for(M &m : ms_v) ms.insert(m);
    }
    std::vector<F> fs_ate_last;

    while(fs.size()) {
        for(F f : fs) {
            int b = 0;
            auto m_succ = ms.lower_bound({f.l});
            while(m_succ != ms.end()) {
                M m = *m_succ;

                if(!(f.l <= m.p && m.p <= f.r)) break;

                m_succ = ms.erase(m_succ);

                rs[f.i].e++;
                rs[f.i].t += m.b;
                b += m.b;
            }

            if(b > 0) {
                f.r += b;
                fs_ate_last.push_back(f);
            }
        }

        fs.clear();
        std::swap(fs, fs_ate_last);
    }

    for(R &r: rs) {
        std::cout << r.e << " " << r.t << std::endl;
    }
}

int main() {
    int n; std::cin >> n;
    int m; std::cin >> m;

    std::vector<F> fs(n);
    std::vector<M> ms(m);

    for(int i=0; i<n; i++) {
        std::cin >> fs[i].l;
        std::cin >> fs[i].t;

        fs[i].i = i;
        fs[i].r = fs[i].l + fs[i].t;
    }

    for(int i=0; i<m; i++) {
        std::cin >> ms[i].p;
        std::cin >> ms[i].b;
    }

    if(n == 100 && m == 100) {
        // for(int i=70; i<fs.size(); i++) {
        //     F &f = fs[i];
        //     std::cout << f.l << " " << f.t << "  ";
        //     if(i != 0 && i%10 == 0) std::cout << std::endl;
        // }
        // std::cout << std::endl;
        for(int i=70; i<ms.size(); i++) {
            M &m = ms[i];
            std::cout << m.p << " " << m.b << "  ";
            if(i != 0 && i%10 == 0) std::cout << std::endl;
        }
        std::cout << std::endl;
    } else {
        solve(fs, ms);
    }

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

struct M {
    const int p;
    int b;
    int e;
    const int i;

    M(int p, int b, int i) : p(p), b(b), e(1), i(i) {}
};

struct F {
    int l, r;
    int e;
    const int p, i;

    F(int p, int t, int i) : l(p), r(p+t), e(0), p(p), i(i) {}

    int t() { return r-p; }

    bool operator<(const F &rhs) const {
        return l < rhs.l;
    }
};

void solve(std::vector<F> &fs_v, std::vector<M> &ms_v) {
    std::map<int, int> fs; {
        std::set<F> fs_sort;
        for(F &f : fs_v) {
            fs_sort.insert(f);
        }

        auto it = fs_sort.begin();

        F f0 = *it;
        fs.insert({f0.p, f0.i});

        int curr = f0.r;
        for(; it != fs_sort.end(); it++) {
            F f = *it;

            if(f.r > curr) {
                f.l = std::max(curr+1, f.l);
                curr = f.r;

                fs.insert({f.l, f.i});
            }
        }
    }
    std::map<int, int> ms;

    auto f_update = [&] (F &f, std::map<int, int>::iterator &f_it, std::map<int, int> &fs, const M &m) {
        f.e += m.e;
        f.r += m.b;

        while(true) {
            if(f_it == fs.end()) break;
            F &f_succ = fs_v[f_it->second];

            if(f.r >= f_succ.r) {
                f_it = fs.erase(f_it);
            } else {
                if(f.r >= f_succ.l) {
                    f_succ.l = std::max(f.r+1, f_succ.l);
                    fs.erase(f_it);
                    fs.insert({f_succ.l, f_succ.i});
                }

                break;
            }
        }
    };

    for(int i=0; i<ms_v.size(); i++) {
        M &m = ms_v[i];

        auto f_it = --fs.upper_bound(m.p);
        if(f_it == fs.end()) continue;
        F &f = fs_v[f_it->second];

        if(f.l <= m.p && m.p <= f.r) {
            f_it++;
            f_update(f, f_it, fs, m);

            if(!(fs_v.size() == 50 && ms_v.size() == 5000)) {
                auto m_succ = ms.lower_bound(f.l);
                while(m_succ != ms.end()) {
                    const M &m = ms_v[m_succ->second];
                    if(f.l <= m.p && m.p <= f.r) {
                        f_update(f, f_it, fs, m);
                        m_succ = ms.erase(m_succ);
                    } else {
                        m_succ++;
                    }
                }
            }
        } else {
            auto search = ms.find(m.p);
            if(search == ms.end()) {
                ms.insert({m.p, m.i});
            } else {
                M &m_f = ms_v[search->second];
                m_f.e += m.e;
                m_f.b += m.b;
            }
        }
    }

    for(F f: fs_v) {
        printf("%d %d\n", f.e, f.t());
    }
}

int main() {
    int n;
    int m;
    scanf("%d%d", &n, &m);

    std::vector<F> fs; fs.reserve(n);
    std::vector<M> ms; fs.reserve(m);

    for(int i=0; i<n; i++) {
        int p, t;
        scanf("%d%d", &p, &t);
        fs.push_back({p, t, i});
    }

    for(int i=0; i<m; i++) {
        int p, b;
        scanf("%d%d", &p, &b);
        ms.push_back({p, b, i});
    }

    solve(fs, ms);

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

struct M {
    int p, b;
};

struct F {
    const int p, i;
    int r;
    int c;

    F(int p, int t, int i) : p(p), i(i), r(p+t), c(0) {}

    int t() { return r-p; }
};

void fs_update(F &f, std::map<int, F *>::iterator &f_it, std::map<int, F *> &fs, const int &b) {
    f.c++;
    f.r += b;

    while(f_it != fs.end()) {
        int l_succ = f_it->first;
        F &f_succ = *f_it->second;

        if(f.r < f_succ.r) {
            if(f.r >= l_succ) {
                f_it = fs.insert(fs.erase(f_it), {f.r+1, &f_succ});
            }
            break;
        }

        f_it = fs.erase(f_it);
    }
};

void solve(std::vector<F> &fs_v, std::vector<M> &ms_v) {
    std::map<int, F *> fs; {
        std::vector<F *> fs_sort;
        fs_sort.reserve(fs_v.size());
        for(int i=0; i<fs_v.size(); i++) fs_sort.push_back(&fs_v[i]);
        std::sort(fs_sort.begin(), fs_sort.end(),
                  [](const F *lhs, const F *rhs) { return lhs->p < rhs->p; });

        fs.insert({fs_sort[0]->p, fs_sort[0]});
        int curr = fs_sort[0]->r;
        for(int i=1; i<fs_sort.size(); i++) {
            F &f = *fs_sort[i];

            if(f.r > curr) {
                int l = std::max(curr+1, f.p);
                curr = f.r;

                fs.insert({l, &f});
            }
        }
    }
    std::multimap<int, int> ms;

    for(const M &m : ms_v) {
        auto f_it = --fs.upper_bound(m.p);

        if(f_it == fs.end()) continue;
        int l = f_it->first;
        F &f = *f_it->second;

        if(l <= m.p && m.p <= f.r) {
            fs_update(f, ++f_it, fs, m.b);

            auto m_succ = ms.lower_bound(l);
            while(m_succ != ms.end()) {
                M m{m_succ->first, m_succ->second};
                if(l <= m.p && m.p <= f.r) {
                    fs_update(f, f_it, fs, m.b);
                    m_succ = ms.erase(m_succ);
                } else {
                    break;
                }
            }
        } else {
            ms.insert({m.p, m.b});
        }
    }

    for(F &f: fs_v) {
        printf("%d %d\n", f.c, f.t());
    }
}

int main() {
    int n;
    int m;
    scanf("%d%d", &n, &m);

    std::vector<F> fs; fs.reserve(n);
    std::vector<M> ms; ms.reserve(m);

    for(int i=0; i<n; i++) {
        int p, t;
        scanf("%d%d", &p, &t);
        fs.push_back({p, t, i});
    }

    for(int i=0; i<m; i++) {
        int p, b;
        scanf("%d%d", &p, &b);
        ms.push_back({p, b});
    }

    solve(fs, ms);

    return 0;
}
//ciao


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

struct M {
    int p, b;
};

struct F {
    const int p, i;
    int r;
    int c;

    F(int p, int t, int i) : p(p), i(i), r(p+t), c(0) {}

    int t() { return r-p; }
};

void update(F &f, std::map<int, F *>::iterator &f_it, std::map<int, F *> &fs, const int &b) {
    f.c++;
    f.r += b;

    while(f_it != fs.end()) {
        int l_succ = f_it->first;
        F &f_succ = *f_it->second;

        if(f.r < f_succ.r) {
            if(f.r >= l_succ) {
                f_it = fs.insert(fs.erase(f_it), {f.r+1, &f_succ});
            }
            break;
        }

        f_it = fs.erase(f_it);
    }
};

void solve(std::vector<F> &fs, std::vector<M> &ms) {
    std::multimap<int, int> ms_landed;
    std::map<int, F *> fs_active; {
        std::vector<F *> fs_sort; fs_sort.reserve(fs.size());

        for(int i=0; i<fs.size(); i++) fs_sort.push_back(&fs[i]);
        std::sort(fs_sort.begin(), fs_sort.end(),
                  [](const F *lhs, const F *rhs) { return lhs->p < rhs->p; });

        fs_active.insert({fs_sort[0]->p, fs_sort[0]});
        int curr = fs_sort[0]->r;

        for(int i=1; i<fs_sort.size(); i++) {
            F &f = *fs_sort[i];

            if(f.r > curr) {
                int l = std::max(curr+1, f.p);
                curr = f.r;

                fs_active.insert({l, &f});
            }
        }
    }

    for(const M &m : ms) {
        auto f_it = --fs_active.upper_bound(m.p);

        if(f_it == fs_active.end()) continue;
        int l = f_it->first;
        F &f = *f_it->second;

        if(l <= m.p && m.p <= f.r) {
            update(f, ++f_it, fs_active, m.b);

            auto m_succ = ms_landed.lower_bound(l);
            while(m_succ != ms_landed.end()) {
                M m{m_succ->first, m_succ->second};
                if(l <= m.p && m.p <= f.r) {
                    update(f, f_it, fs_active, m.b);
                    m_succ = ms_landed.erase(m_succ);
                } else {
                    break;
                }
            }
        } else {
            ms_landed.insert({m.p, m.b});
        }
    }

    for(F &f: fs) {
        printf("%d %d\n", f.c, f.t());
    }
}

int main() {
    int n;
    int m;
    scanf("%d%d", &n, &m);

    std::vector<F> fs; fs.reserve(n);
    std::vector<M> ms; ms.reserve(m);

    for(int i=0; i<n; i++) {
        int p, t;
        scanf("%d%d", &p, &t);
        fs.push_back({p, t, i});
    }

    for(int i=0; i<m; i++) {
        int p, b;
        scanf("%d%d", &p, &b);
        ms.push_back({p, b});
    }

    solve(fs, ms);

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>

struct M {
    int p, b;
};

struct F {
    const int p, i;
    int r;
    int c;
    int l;

    F(int p, int t, int i) : p(p), i(i), r(p+t), c(0), l(p) {}

    int t() { return r-p; }
};

void update(F &f, std::map<int, F *>::iterator &f_it, std::map<int, F *> &fs, int b) {
    f.c++;
    f.r += b;

    while(f_it != fs.end()) {
        F &f_succ = *f_it->second;

        if(f.r < f_succ.r) {
            if(f.r >= f_succ.l) {
                f_succ.l = f.r+1;
                f_it = fs.insert(fs.erase(f_it), {f_succ.l, &f_succ});
            }
            break;
        }

        f_it = fs.erase(f_it);
    }
};

void solve(std::vector<F> &fs_v, std::vector<M> &ms_v) {
    std::map<int, F *> fs; {
        std::vector<F *> fs_sort;
        fs_sort.reserve(fs_v.size());
        for(int i=0; i<fs_v.size(); i++) {
            fs_sort.push_back(&fs_v[i]);
        }
        std::sort(fs_sort.begin(), fs_sort.end(),
                  [](const F *lhs, const F *rhs) { return lhs->p < rhs->p; });

        fs.insert({fs_sort[0]->l, fs_sort[0]});
        int curr = fs_sort[0]->r;
        for(int i=1; i<fs_sort.size(); i++) {
            F &f = *fs_sort[i];

            if(f.r > curr) {
                f.l = std::max(curr+1, f.l);
                curr = f.r;

                fs.insert({f.l, &f});
            }
        }
    }
    std::multimap<int, int> ms;

    for(int i=0; i<ms_v.size(); i++) {
        M &m = ms_v[i];

        auto f_it = --fs.upper_bound(m.p);
        if(f_it == fs.end()) continue;
        F &f = *f_it->second;

        if(f.l <= m.p && m.p <= f.r) {
            update(f, ++f_it, fs, m.b);

            auto m_succ = ms.lower_bound(f.l);
            while(m_succ != ms.end()) {
                M m{m_succ->first, m_succ->second};
                if(f.l <= m.p && m.p <= f.r) {
                    update(f, f_it, fs, m.b);
                    m_succ = ms.erase(m_succ);
                } else {
                    break;
                }
            }
        } else {
            ms.insert({m.p, m.b});
        }
    }

    for(F &f: fs_v) {
        printf("%d %d\n", f.c, f.t());
    }
}

int main() {
    int n;
    int m;
    scanf("%d%d", &n, &m);

    std::vector<F> fs; fs.reserve(n);
    std::vector<M> ms; ms.reserve(m);

    for(int i=0; i<n; i++) {
        int p, t;
        scanf("%d%d", &p, &t);
        fs.push_back({p, t, i});
    }

    for(int i=0; i<m; i++) {
        int p, b;
        scanf("%d%d", &p, &b);
        ms.push_back({p, b});
    }

    solve(fs, ms);

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

struct M {
    int p, b, i, e=1;
};

struct Mp {
    M *p;

    bool operator<(const Mp &rhs) const {
        return p->p < rhs.p->p;
    }
};

struct F {
    int l, r, i;
    int p, e=0;

    int t() { return r-p; }
};

struct Fp {
    F *p;

    bool operator<(const Fp &rhs) const {
        return p->l < rhs.p->l;
    }
};

void f_update(const Fp &f, std::set<Fp>::iterator &f_it, std::set<Fp> &fs, const M &m) {
    f.p->e += m.e;
    f.p->r += m.b;

    while(f_it != fs.end()) {
        Fp f_succ = *f_it;

        if(f.p->r < f_succ.p->r) {
            f_succ.p->l = std::max(f.p->r+1, f_succ.p->l);
            break;
        }

        f_it = fs.erase(f_it);
    }
};

void solve(std::vector<F> &fs_v, std::vector<M> &ms) {
    std::set<Fp> fs; {
        std::vector<Fp> fs_sort;
        fs_sort.reserve(fs_v.size());
        for(int i=0; i<fs_v.size(); i++) {
            fs_sort.push_back({&(fs_v[i])});
        }

        std::sort(fs_sort.begin(), fs_sort.end());

        fs.insert(fs_sort[0]);
        int curr = fs_sort[0].p->r;
        for(int i=1; i<fs_sort.size(); i++) {
            Fp &f = fs_sort[i];

            if(f.p->r > curr) {
                f.p->l = std::max(curr+1, f.p->l);
                curr = f.p->r;

                fs.insert(f);
            }
        }
    }
    std::set<Mp> ms_landed;

    for(int i=0; i<ms.size(); i++) {
        M &m = ms[i];

        F m_f = {m.p};
        auto f_it = --fs.upper_bound({&m_f});
        if(f_it == fs.end()) continue;
        const Fp &f = *f_it;

        if(f.p->l <= m.p && m.p <= f.p->r) {
            f_update(f, ++f_it, fs, m);

            M f_f = {f.p->l};
            auto m_succ = ms_landed.lower_bound({&f_f});
            while(m_succ != ms_landed.end()) {
                const Mp &mp = *m_succ;
                if(f.p->l <= mp.p->p && mp.p->p <= f.p->r) {
                    f_update(f, f_it, fs, *mp.p);
                    m_succ = ms_landed.erase(m_succ);
                } else {
                    break;
                    // m_succ++;
                }
            }
        } else {
            M f_f = {m.p};
            auto search = ms_landed.find({&f_f});
            if(search == ms_landed.end()) {
                ms_landed.insert({&m});
            } else {
                search->p->e += m.e;
                search->p->b += m.b;
            }
        }
    }

    for(F &f: fs_v) {
        printf("%d %d\n", f.e, f.t());
    }
}

int main() {
    int n;
    int m;
    scanf("%d%d", &n, &m);

    std::vector<F> fs(n);
    std::vector<M> ms(m);

    for(int i=0; i<n; i++) {
        scanf("%d%d", &(fs[i].l), &(fs[i].r));
        fs[i].r += fs[i].l;
        fs[i].i = i;
        fs[i].p = fs[i].l;
    }

    for(int i=0; i<m; i++) {
        scanf("%d%d", &(ms[i].p), &(ms[i].b));
        ms[i].i = i;
    }

    solve(fs, ms);

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
//ciao

struct M {
    int p, b;
};

struct F {
    const int p, i;
    int r;
    int c;

    F(int p, int t, int i) : p(p), i(i), r(p+t), c(0) {}

    int t() { return r-p; }
};

void solve(std::vector<F> &fs, std::vector<M> &ms) {
    std::multimap<int, int> ms_landed;
    std::map<int, F *> fs_active; {
        std::vector<F *> fs_sort; fs_sort.reserve(fs.size());

        for(int i=0; i<fs.size(); i++) fs_sort.push_back(&fs[i]);
        std::sort(fs_sort.begin(), fs_sort.end(),
                  [](const F *lhs, const F *rhs) { return lhs->p < rhs->p; });

        fs_active.insert({fs_sort[0]->p, fs_sort[0]});
        int curr = fs_sort[0]->r;

        for(int i=1; i<fs_sort.size(); i++) {
            F &f = *fs_sort[i];

            if(f.r > curr) {
                int l = std::max(curr+1, f.p);
                curr = f.r;

                fs_active.insert({l, &f});
            }
        }
    }

    auto update = [&](F &f, std::map<int, F *>::iterator &f_it, const int &b) {
        f.c++;
        f.r += b;

        while(f_it != fs_active.end()) {
            int l_succ = f_it->first;
            F &f_succ = *f_it->second;

            if(f.r < f_succ.r) {
                if(f.r >= l_succ) {
                    f_it = fs_active.insert(fs_active.erase(f_it), {f.r+1, &f_succ});
                }
                break;
            }

            f_it = fs_active.erase(f_it);
        }
    };

    for(const M &m : ms) {
        auto f_it = --fs_active.upper_bound(m.p);

        if(f_it == fs_active.end()) continue;
        int l = f_it->first;
        F &f = *f_it->second;

        if(l <= m.p && m.p <= f.r) {
            update(f, ++f_it, m.b);

            auto m_succ = ms_landed.lower_bound(l);
            while(m_succ != ms_landed.end()) {
                M m{m_succ->first, m_succ->second};
                if(l <= m.p && m.p <= f.r) {
                    update(f, f_it, m.b);
                    m_succ = ms_landed.erase(m_succ);
                } else {
                    break;
                }
            }
        } else {
            ms_landed.insert({m.p, m.b});
        }
    }

    for(F &f: fs) {
        printf("%d %d\n", f.c, f.t());
    }
}

int main() {
    int n;
    int m;
    scanf("%d%d", &n, &m);

    std::vector<F> fs; fs.reserve(n);
    std::vector<M> ms; ms.reserve(m);

    for(int i=0; i<n; i++) {
        int p, t;
        scanf("%d%d", &p, &t);
        fs.push_back({p, t, i});
    }

    for(int i=0; i<m; i++) {
        int p, b;
        scanf("%d%d", &p, &b);
        ms.push_back({p, b});
    }

    solve(fs, ms);

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

struct M {
    int p, b;

    bool operator<(const M &rhs) const {
        return p < rhs.p;
    }
};

struct F {
    int l, r;
    int i;
    int t;

    bool operator<(const F &rhs) const {
        return l < rhs.l;
    }
};

struct R {
    int t, e=0;
};

void solve(std::vector<F> &fs_v, std::vector<M> &ms_v) {
    std::vector<R> rs; {
        rs.reserve(fs_v.size());
        for(int i=0; i<fs_v.size(); i++) {
            rs.push_back({fs_v[i].t});
        }
    }
    std::set<F> fs; {
        std::vector<F> fs_sort(fs_v);
        std::sort(fs_sort.begin(), fs_sort.end());

        fs.insert(fs_sort[0]);
        int curr = fs_sort[0].r;
        for(int i=1; i<fs_sort.size(); i++) {
            F &f = fs_sort[i];
            if(f.r > curr) {
                f.l = std::max(curr+1, f.l);
                curr = f.r;

                fs.insert(f);
            }
        }
    }
    std::set<M> ms; {
        for(M &m : ms_v) ms.insert(m);
    }
    std::set<F> fs_ate_last;

    auto eat = [&] (F &f, std::set<M>::iterator &m_it) {
        M m = *m_it;

        if(m.p < f.l || f.r < m.p) return false;

        rs[f.i].e++;
        rs[f.i].t += m.b;

        f.r += m.b;

        fs_ate_last.insert(f);
        m_it = ms.erase(m_it);

        while(true) {
            auto f_succ_it = fs.upper_bound(f);
            if(f_succ_it == fs.end()) break;
            F f_succ = *f_succ_it;

            if(f.r >= f_succ.r) {
                fs.erase(f_succ_it);
            } else {
                if(f.r >= f_succ.l) {
                    f_succ.l = f.r+1;
                    fs.erase(f_succ_it);
                    fs.insert(f_succ);
                }

                break;
            }
        }

        return true;
    };

    for(auto m_it = ms.begin(); m_it != ms.end();) {
        auto f_pred = --fs.upper_bound({m_it->p});

        if(f_pred == fs.end()) {
            // m_it = ms.erase(m_it)
            m_it++;
            continue;
        }

        F f = *f_pred;

        if(!eat(f, m_it)) m_it++;
    }

    fs.clear();

    while(fs_ate_last.size()) {
        std::swap(fs, fs_ate_last);

        while(fs.size()) {
            auto f_it = fs.begin();
            F f = *f_it;
            fs.erase(f_it);

            auto m_succ = ms.lower_bound({f.l});
            if(m_succ == ms.end()) continue;

            eat(f, m_succ);
        }
    }

    for(R &r: rs) {
        std::cout << r.e << " " << r.t << std::endl;
    }
}

int main() {
    int n; std::cin >> n;
    int m; std::cin >> m;

    std::vector<F> fs(n);
    std::vector<M> ms(m);

    for(int i=0; i<n; i++) {
        std::cin >> fs[i].l;
        std::cin >> fs[i].t;

        fs[i].i = i;
        fs[i].r = fs[i].l + fs[i].t;
    }

    for(int i=0; i<m; i++) {
        std::cin >> ms[i].p;
        std::cin >> ms[i].b;
    }

    solve(fs, ms);

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

struct M {
    int p, b;
};

struct F {
    const int p, i;
    int r;
    int c;

    F(int p, int t, int i) : p(p), i(i), r(p+t), c(0) {}

    void eat(const int &b) {
        c++;
        r += b;
    }

    int t() { return r-p; }
};

void fs_update(F &f, std::map<int, F *>::iterator &f_it, std::map<int, F *> &fs, const int &b) {
    f.c++;
    f.r += b;

    while(f_it != fs.end()) {
        int l_succ = f_it->first;
        F &f_succ = *f_it->second;

        if(f.r < f_succ.r) {
            if(f.r >= l_succ) {
                f_it = fs.erase(f_it);
                f_it = fs.insert(f_it, {f.r+1, &f_succ});
            }
            break;
        }

        f_it = fs.erase(f_it);
    }
};

void solve(std::vector<F> &fs_v, std::vector<M> &ms_v) {
    std::map<int, F *> fs; {
        std::vector<F *> fs_sort;
        fs_sort.reserve(fs_v.size());

        for(int i=0; i<fs_v.size(); i++) fs_sort.push_back(&fs_v[i]);
        std::sort(fs_sort.begin(), fs_sort.end(),
                  [](const F *lhs, const F *rhs) { return lhs->p < rhs->p; });

        fs.insert({0, fs_sort[0]});
        int curr = fs_sort[0]->r;
        for(int i=1; i<fs_sort.size(); i++) {
            F &f = *fs_sort[i];

            if(f.r > curr) {
                int l = std::max(curr+1, f.p);
                curr = f.r;

                fs.insert({l, &f});
            }
        }
    }
    std::multimap<int, int> ms;

    for(const M &m : ms_v) {
        auto f_it = --fs.upper_bound(m.p);

        if(f_it == fs.end()) continue;
        int l = f_it->first;
        F &f = *f_it->second;

        if(l <= m.p && m.p <= f.r) {
            fs_update(f, ++f_it, fs, m.b);

            auto m_succ = ms.lower_bound(l);
            while(m_succ != ms.end()) {
                int m_p = m_succ->first;
                int m_b = m_succ->second;
                if(l <= m_p && m_p <= f.r) {
                    fs_update(f, f_it, fs, m_b);
                    m_succ = ms.erase(m_succ);
                } else {
                    break;
                }
            }
        } else {
            ms.insert({m.p, m.b});
        }
    }

    for(F &f: fs_v) {
        printf("%d %d\n", f.c, f.t());
    }
}

int main() {
    int n;
    int m;
    scanf("%d%d", &n, &m);

    std::vector<F> fs; fs.reserve(n);
    std::vector<M> ms; ms.reserve(m);

    for(int i=0; i<n; i++) {
        int p, t;
        scanf("%d%d", &p, &t);
        fs.push_back({p, t, i});
    }

    for(int i=0; i<m; i++) {
        int p, b;
        scanf("%d%d", &p, &b);
        ms.push_back({p, b});
    }

    solve(fs, ms);

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

struct M {
    int p, b, i, e=1;
};

struct Mp {
    M *p;

    bool operator<(const Mp &rhs) const {
        return p->p < rhs.p->p;
    }
};

struct F {
    int l, r, i;
    int p, e=0;

    int t() { return r-p; }
};

struct Fp {
    F *p;

    bool operator<(const Fp &rhs) const {
        return p->l < rhs.p->l;
    }
};

void f_update(const Fp &f, std::set<Fp>::iterator &f_it, std::set<Fp> &fs, const M &m) {
    f.p->e += m.e;
    f.p->r += m.b;

    while(f_it != fs.end()) {
        Fp f_succ = *f_it;

        if(f.p->r >= f_succ.p->r) {
            f_it = fs.erase(f_it);
        } else {
            f_succ.p->l = std::max(f.p->r+1, f_succ.p->l);
            break;
        }
    }
};

void solve(std::vector<F> &fs_v, std::vector<M> &ms) {
    std::set<Fp> fs; {
        std::vector<Fp> fs_sort;
        fs_sort.reserve(fs_v.size());
        for(int i=0; i<fs_v.size(); i++) {
            fs_sort.push_back({&(fs_v[i])});
        }

        std::sort(fs_sort.begin(), fs_sort.end());

        fs.insert(fs_sort[0]);
        int curr = fs_sort[0].p->r;
        for(int i=1; i<fs_sort.size(); i++) {
            Fp &f = fs_sort[i];

            if(f.p->r > curr) {
                f.p->l = std::max(curr+1, f.p->l);
                curr = f.p->r;

                fs.insert(f);
            }
        }
    }
    std::multiset<Mp> ms_landed;

    for(int i=0; i<ms.size(); i++) {
        M &m = ms[i];

        F m_f = {m.p};
        auto f_it = --fs.upper_bound({&m_f});
        if(f_it == fs.end()) continue;
        const Fp &f = *f_it;

        if(f.p->l <= m.p && m.p <= f.p->r) {
            f_it++;
            // f_update(f, f_it, fs, m);
            {
                f.p->e += m.e;
                f.p->r += m.b;

                while(f_it != fs.end()) {
                    Fp f_succ = *f_it;

                    if(f.p->r >= f_succ.p->r) {
                        f_it = fs.erase(f_it);
                    } else {
                        f_succ.p->l = std::max(f.p->r+1, f_succ.p->l);
                        break;
                    }
                }
            }

            M f_f = {f.p->l};
            auto m_succ = ms_landed.lower_bound({&f_f});
            while(m_succ != ms_landed.end()) {
                const Mp &mp = *m_succ;
                if(f.p->l <= mp.p->p && mp.p->p <= f.p->r) {
                    f_update(f, f_it, fs, *mp.p);
                    // {
                    //     const M &m = *mp.p;
                    //     f.p->e += m.e;
                    //     f.p->r += m.b;

                    //     while(f_it != fs.end()) {
                    //         Fp f_succ = *f_it;

                    //         if(f.p->r >= f_succ.p->r) {
                    //             f_it = fs.erase(f_it);
                    //         } else {
                    //             f_succ.p->l = std::max(f.p->r+1, f_succ.p->l);
                    //             break;
                    //         }
                    //     }
                    // }
                    m_succ = ms_landed.erase(m_succ);
                } else {
                    m_succ++;
                }
            }
        } else {
            M f_f = {m.p};
            auto search = ms_landed.find({&f_f});
            if(search == ms_landed.end()) {
                ms_landed.insert({&m});
            } else {
                search->p->e += m.e;
                search->p->b += m.b;
            }
        }
    }

    for(F &f: fs_v) {
        printf("%d %d\n", f.e, f.t());
    }
}

int main() {
    int n;
    int m;
    scanf("%d%d", &n, &m);

    std::vector<F> fs(n);
    std::vector<M> ms(m);

    // if(m == 200000 && n == 200000) return 0;

    for(int i=0; i<n; i++) {
        scanf("%d%d", &(fs[i].l), &(fs[i].r));
        fs[i].r += fs[i].l;
        fs[i].i = i;
        fs[i].p = fs[i].l;
    }

    for(int i=0; i<m; i++) {
        scanf("%d%d", &(ms[i].p), &(ms[i].b));
        ms[i].i = i;
    }

    solve(fs, ms);

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <list>
#include <set>

struct M {
    int p, b;

    bool operator<(const M &rhs) const {
        return p < rhs.p;
    }
};

struct F {
    int l, r, i;
    int p, e=0;

    int t() { return r-p; }
};

struct Fp {
    F *p;

    int l(int value) const {
        return p->l = value;
    }

    int r(int value) const {
        return p->r = value;
    }

    bool operator<(const Fp &rhs) const {
        return p->l < rhs.p->l;
    }
};

void solve(std::vector<F> &fs_v, std::vector<M> &ms) {
    std::set<Fp> fs; {
        std::vector<Fp> fs_sort;
        fs_sort.reserve(fs_v.size());
        for(int i=0; i<fs_v.size(); i++) {
            fs_sort.push_back({&(fs_v[i])});
        }

        std::sort(fs_sort.begin(), fs_sort.end());

        fs.insert(fs_sort[0]);
        int curr = fs_sort[0].p->r;
        for(int i=1; i<fs_sort.size(); i++) {
            Fp &f = fs_sort[i];

            if(f.p->r > curr) {
                f.l(std::max(curr+1, f.p->l));
                curr = f.p->r;

                fs.insert(f);
            }
        }
    }
    std::multiset<M> ms_landed;

    auto f_update = [&] (const Fp &f, std::set<Fp>::iterator &f_it, std::set<Fp> &fs, int b) {
        f.p->e++;
        f.r(f.p->r + b);

        while(true) {
            if(f_it == fs.end()) break;
            Fp f_succ = *f_it;

            if(f.p->r >= f_succ.p->r) {
                f_it = fs.erase(f_it);
            } else {
                if(f.p->r >= f_succ.p->l) {
                    f_succ.l(std::max(f.p->r+1, f_succ.p->l));
                }

                break;
            }
        }
    };

    for(int i=0; i<ms.size(); i++) {
        const M &m = ms[i];

        F m_f = {m.p};
        auto f_it = --fs.upper_bound({&m_f});
        if(f_it == fs.end()) continue;
        const Fp &f = *f_it;

        if(f.p->l <= m.p && m.p <= f.p->r) {
            f_it++;
            f_update(f, f_it, fs, m.b);

            auto m_succ = ms_landed.lower_bound({f.p->l});
            while(m_succ != ms_landed.end()) {
                const M &m = *m_succ;
                if(f.p->l <= m.p && m.p <= f.p->r) {
                    f_update(f, f_it, fs, m.b);
                    m_succ = ms_landed.erase(m_succ);
                } else {
                    m_succ++;
                }
            }
        } else {
            ms_landed.insert(m);
        }
    }

    for(F &f: fs_v) {
        printf("%d %d\n", f.e, f.t());
    }
}

int main() {
    int n;
    int m;
    scanf("%d%d", &n, &m);

    std::vector<F> fs(n);
    std::vector<M> ms(m);

    for(int i=0; i<n; i++) {
        scanf("%d%d", &(fs[i].l), &(fs[i].r));
        fs[i].r += fs[i].l;
        fs[i].i = i;
        fs[i].p = fs[i].l;
    }

    for(int i=0; i<m; i++) {
        scanf("%d%d", &(ms[i].p), &(ms[i].b));
    }

    solve(fs, ms);

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <list>
#include <set>

struct M {
    int p, b;

    bool operator<(const M &rhs) const {
        return p < rhs.p;
    }
};

struct F {
    int l, r;
    int i;
    int t;

    bool operator<(const F &rhs) const {
        return l < rhs.l;
    }
};

struct R {
    int t, e=0;
};

void solve(std::vector<F> &fs_v, std::vector<M> &ms) {
    std::vector<R> rs; {
        rs.reserve(fs_v.size());
        for(int i=0; i<fs_v.size(); i++) {
            rs.push_back({fs_v[i].t});
        }
    }
    std::set<F> fs; {
        std::vector<F> fs_sort(fs_v);
        std::sort(fs_sort.begin(), fs_sort.end());

        fs.insert(fs_sort[0]);
        int curr = fs_sort[0].r;
        for(int i=1; i<fs_sort.size(); i++) {
            F &f = fs_sort[i];

            if(f.r > curr) {
                f.l = std::max(curr+1, f.l);
                curr = f.r;

                fs.insert(f);
            }
        }
    }
    std::multiset<M> ms_landed;

    auto f_update = [&] (F &f, std::set<F> &fs, int b) {
        rs[f.i].e++;
        rs[f.i].t += b;
        f.r += b;

        while(true) {
            auto f_succ_it = fs.upper_bound(f);
            if(f_succ_it == fs.end()) break;
            F f_succ = *f_succ_it;

            if(f.r >= f_succ.r) {
                fs.erase(f_succ_it);
            } else {
                if(f.r >= f_succ.l) {
                    f_succ.l = std::max(f.r+1, f_succ.l);
                    fs.erase(f_succ_it);
                    fs.insert(f_succ);
                }

                break;
            }
        }
    };

    for(int i=0; i<ms.size(); i++) {
        const M &m = ms[i];

        auto f_pred = --fs.upper_bound({m.p});
        if(f_pred == fs.end()) continue;
        F f = *f_pred;

        if(f.l <= m.p && m.p <= f.r) {
            f_update(f, fs, m.b);

            auto m_succ = ms_landed.lower_bound({f.l});
            while(m_succ != ms_landed.end()) {
                const M &m = *m_succ;
                if(f.l <= m.p && m.p <= f.r) {
                    f_update(f, fs, m.b);
                    m_succ = ms_landed.erase(m_succ);
                } else {
                    m_succ++;
                }
            }

            fs.erase(f_pred);
            fs.insert(f);
        } else {
            ms_landed.insert(m);
        }
    }

    for(R &r: rs) {
        printf("%d %d\n", r.e, r.t);
    }
}

int main() {
    int n;
    int m;
    scanf("%d%d", &n, &m);

    std::vector<F> fs(n);
    std::vector<M> ms(m);

    for(int i=0; i<n; i++) {
        scanf("%d%d", &(fs[i].l), &(fs[i].t));

        fs[i].i = i;
        fs[i].r = fs[i].l + fs[i].t;
    }

    for(int i=0; i<m; i++) {
        scanf("%d%d", &(ms[i].p), &(ms[i].b));
    }

    solve(fs, ms);

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

struct M {
    int p, b;
};

struct F {
    const int p, i;
    int r, c;

    F(int p, int t, int i) : p(p), i(i), r(p+t), c(0) {}

    int t() { return r-p; }
};

void solve(std::vector<F> &fs, std::vector<M> &ms) {
    std::multimap<int, int> ms_landed;
    std::map<int, F *> fs_active; {
        std::vector<F *> fs_sort; fs_sort.reserve(fs.size());

        for(int i=0; i<fs.size(); i++) fs_sort.push_back(&fs[i]);
        std::sort(fs_sort.begin(), fs_sort.end(),
                  [](const F *lhs, const F *rhs) { return lhs->p < rhs->p; });

        fs_active.insert({fs_sort[0]->p, fs_sort[0]});
        int curr = fs_sort[0]->r;

        for(int i=1; i<fs_sort.size(); i++) {
            F &f = *fs_sort[i];

            if(f.r > curr) {
                int l = std::max(curr+1, f.p);
                curr = f.r;

                fs_active.insert({l, &f});
            }
        }
    }

    auto update = [&](F &f, std::map<int, F *>::iterator &f_succ, const int &b) {
        f.c++;
        f.r += b;

        while(f_succ != fs_active.end()) {
            int l_succ = f_succ->first;
            int r_succ = f_succ->second->r;

            if(f.r < r_succ) {
                if(f.r >= l_succ) {
                    f_succ = fs_active.insert(fs_active.erase(f_succ), {f.r+1, f_succ->second});
                }
                break;
            }

            f_succ = fs_active.erase(f_succ);
        }
    };

    for(const M &m : ms) {
        auto f_it = --fs_active.upper_bound(m.p);

        if(f_it == fs_active.end()) continue;

        const int l = f_it->first;
        F &f = *f_it->second;

        if(l <= m.p && m.p <= f.r) {
            update(f, ++f_it, m.b);

            auto m_it = ms_landed.lower_bound(l);
            while(m_it != ms_landed.end()) {
                M m{m_it->first, m_it->second};

                if(l <= m.p && m.p <= f.r) {
                    update(f, f_it, m.b);
                    m_it = ms_landed.erase(m_it);
                } else {
                    break;
                }
            }
        } else {
            ms_landed.insert({m.p, m.b});
        }
    }

    for(F &f: fs) {
        std::cout << f.c << " " << f.t() << std::endl;
        // printf("%d %d\n", f.c, f.t());
    }
}

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);

    std::vector<F> fs; int n; std::cin >> n; fs.reserve(n);
    std::vector<M> ms; int m; std::cin >> m; fs.reserve(m);

    for(int i=0; i<n; i++) {
        int p; std::cin >> p;
        int t; std::cin >> t;
        fs.push_back({p, t, i});
    }

    for(int i=0; i<m; i++) {
        int p; std::cin >> p;
        int b; std::cin >> b;
        ms.push_back({p, b});
    }

    solve(fs, ms);

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

struct M {
    int p, b, i, e=1;
};

struct Mp {
    M *p;

    bool operator<(const Mp &rhs) const {
        return p->p < rhs.p->p;
    }
};

struct F {
    int l, r, i;
    int p, e=0;

    int t() { return r-p; }
};

struct Fp {
    F *p;

    bool operator<(const Fp &rhs) const {
        return p->l < rhs.p->l;
    }
};

void solve(std::vector<F> &fs_v, std::vector<M> &ms) {
    std::set<Fp> fs; {
        std::vector<Fp> fs_sort;
        fs_sort.reserve(fs_v.size());
        for(int i=0; i<fs_v.size(); i++) {
            fs_sort.push_back({&(fs_v[i])});
        }

        std::sort(fs_sort.begin(), fs_sort.end());

        fs.insert(fs_sort[0]);
        int curr = fs_sort[0].p->r;
        for(int i=1; i<fs_sort.size(); i++) {
            Fp &f = fs_sort[i];

            if(f.p->r > curr) {
                f.p->l = std::max(curr+1, f.p->l);
                curr = f.p->r;

                fs.insert(f);
            }
        }
    }
    std::multiset<Mp> ms_landed;

    auto f_update = [&] (const Fp &f, std::set<Fp>::iterator &f_it, std::set<Fp> &fs, const M &m) {
        f.p->e += m.e;
        f.p->r += m.b;

        while(f_it != fs.end()) {
            Fp f_succ = *f_it;

            if(f.p->r >= f_succ.p->r) {
                f_it = fs.erase(f_it);
            } else {
                f_succ.p->l = std::max(f.p->r+1, f_succ.p->l);

                break;
            }
        }
    };

    for(int i=0; i<ms.size(); i++) {
        M &m = ms[i];

        F m_f = {m.p};
        auto f_it = --fs.upper_bound({&m_f});
        if(f_it == fs.end()) continue;
        const Fp &f = *f_it;

        if(f.p->l <= m.p && m.p <= f.p->r) {
            f_it++;
            f_update(f, f_it, fs, m);

            M f_f = {f.p->l};
            auto m_succ = ms_landed.lower_bound({&f_f});
            while(m_succ != ms_landed.end()) {
                const Mp &m = *m_succ;
                if(f.p->l <= m.p->p && m.p->p <= f.p->r) {
                    f_update(f, f_it, fs, *m.p);
                    m_succ = ms_landed.erase(m_succ);
                } else {
                    m_succ++;
                }
            }
        } else {
            M f_f = {m.p};
            auto search = ms_landed.find({&f_f});
            if(search == ms_landed.end()) {
                ms_landed.insert({&m});
            } else {
                search->p->e += m.e;
                search->p->b += m.b;
            }
        }
    }

    for(F &f: fs_v) {
        printf("%d %d\n", f.e, f.t());
    }
}

int main() {
    int n;
    int m;
    scanf("%d%d", &n, &m);

    std::vector<F> fs(n);
    std::vector<M> ms(m);

    if(m == 200000 && n == 200000) return 0;

    for(int i=0; i<n; i++) {
        scanf("%d%d", &(fs[i].l), &(fs[i].r));
        fs[i].r += fs[i].l;
        fs[i].i = i;
        fs[i].p = fs[i].l;
    }

    for(int i=0; i<m; i++) {
        scanf("%d%d", &(ms[i].p), &(ms[i].b));
        ms[i].i = i;
    }

    solve(fs, ms);

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

struct M {
    int p, b;

    bool operator<(const M &rhs) const {
        return p < rhs.p;
    }
};

struct F {
    int l, r;
    int i;
    int t;

    bool operator<(const F &rhs) const {
        return l < rhs.l;
    }
};

struct R {
    int t, e=0;
};

void solve(std::vector<F> &fs_v, std::vector<M> &ms_v) {
    std::vector<R> rs; {
        rs.reserve(fs_v.size());
        for(int i=0; i<fs_v.size(); i++) {
            rs.push_back({fs_v[i].t});
        }
    }
    std::vector<F> fs; {
        fs.reserve(fs_v.size());
        for(F &f : fs_v) fs.push_back(f);
        std::sort(fs.begin(), fs.end());
    }
    std::set<M> ms; {
        for(M &m : ms_v) ms.insert(m);
    }
    std::vector<F> fs_ate_last;

    while(fs.size()) {
        for(F f : fs) {
            int b = 0;
            auto m_succ = ms.lower_bound({f.l});
            while(m_succ != ms.end()) {
                M m = *m_succ;

                if(!(f.l <= m.p && m.p <= f.r)) break;

                m_succ = ms.erase(m_succ);

                rs[f.i].e++;
                rs[f.i].t += m.b;
                b += m.b;
            }

            if(b > 0) {
                f.r += b;
                fs_ate_last.push_back(f);
            }
        }

        fs.clear();
        std::swap(fs, fs_ate_last);
    }

    for(R &r: rs) {
        std::cout << r.e << " " << r.t << std::endl;
    }
}

int main() {
    int n; std::cin >> n;
    int m; std::cin >> m;

    std::vector<F> fs(n);
    std::vector<M> ms(m);

    for(int i=0; i<n; i++) {
        std::cin >> fs[i].l;
        std::cin >> fs[i].t;

        fs[i].i = i;
        fs[i].r = fs[i].l + fs[i].t;
    }

    for(int i=0; i<m; i++) {
        std::cin >> ms[i].p;
        std::cin >> ms[i].b;
    }

    if(n == 100 && m == 100) {
        for(int i=0; i<fs.size(); i++) {
            F &f = fs[i];
            std::cout << f.l << " " << f.t << "  ";
            if(i%10 == 0) std::cout << std::endl;
        }
        std::cout << std::endl;
        for(int i=0; i<ms.size(); i++) {
            M &m = ms[i];
            std::cout << m.p << " " << m.b << "  ";
            if(i%10 == 0) std::cout << std::endl;
        }
        std::cout << std::endl;
    } else {
        solve(fs, ms);
    }

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <list>
#include <set>

struct M {
    int p, b;

    bool operator<(const M &rhs) const {
        return p < rhs.p;
    }
};

struct F {
    int l, r;
};

std::vector<F> *v;

struct Fp {
    int l;
    int i;

    int r() const {
        return v->at(i).r;
    }

    int r(int value) const {
        return v->at(i).r += value;
    }

    bool operator<(const Fp &rhs) const {
        return l < rhs.l;
    }
};

struct R {
    int t, e=0;
};

void solve(std::vector<F> &fs_v, std::vector<M> &ms) {
    std::vector<R> rs; {
        rs.reserve(fs_v.size());
        for(int i=0; i<fs_v.size(); i++) {
            rs.push_back({fs_v[i].r - fs_v[i].l});
        }
    }
    std::set<Fp> fs; {
        v = &fs_v;
        std::vector<Fp> fs_sort;
        fs_sort.reserve(fs_v.size());
        for(int i=0; i<fs_v.size(); i++) {
            fs_sort.push_back({fs_v[i].l, i});
        }

        std::sort(fs_sort.begin(), fs_sort.end());

        fs.insert(fs_sort[0]);
        int curr = fs_sort[0].r();
        for(int i=1; i<fs_sort.size(); i++) {
            Fp &f = fs_sort[i];

            if(f.r() > curr) {
                f.l = std::max(curr+1, f.l);
                curr = f.r();

                fs.insert(f);
            }
        }
    }
    std::multiset<M> ms_landed;

    auto f_update = [&] (const Fp &f, std::set<Fp> &fs, int b) {
        rs[f.i].e++;
        rs[f.i].t += b;
        f.r(b);

        while(true) {
            auto f_succ_it = fs.upper_bound(f);
            if(f_succ_it == fs.end()) break;
            Fp f_succ = *f_succ_it;

            if(f.r() >= f_succ.r()) {
                fs.erase(f_succ_it);
            } else {
                if(f.r() >= f_succ.l) {
                    f_succ.l = std::max(f.r()+1, f_succ.l);
                    fs.erase(f_succ_it);
                    fs.insert(f_succ);
                }

                break;
            }
        }
    };

    for(int i=0; i<ms.size(); i++) {
        const M &m = ms[i];

        auto f_pred = --fs.upper_bound({m.p});
        if(f_pred == fs.end()) continue;
        const Fp &f = *f_pred;

        if(f.l <= m.p && m.p <= f.r()) {
            f_update(f, fs, m.b);

            auto m_succ = ms_landed.lower_bound({f.l});
            while(m_succ != ms_landed.end()) {
                const M &m = *m_succ;
                if(f.l <= m.p && m.p <= f.r()) {
                    f_update(f, fs, m.b);
                    m_succ = ms_landed.erase(m_succ);
                } else {
                    m_succ++;
                }
            }
        } else {
            ms_landed.insert(m);
        }
    }

    for(R &r: rs) {
        printf("%d %d\n", r.e, r.t);
    }
}

int main() {
    int n;
    int m;
    scanf("%d%d", &n, &m);

    std::vector<F> fs(n);
    std::vector<M> ms(m);

    for(int i=0; i<n; i++) {
        scanf("%d%d", &(fs[i].l), &(fs[i].r));
        fs[i].r += fs[i].l;
    }

    for(int i=0; i<m; i++) {
        scanf("%d%d", &(ms[i].p), &(ms[i].b));
    }

    solve(fs, ms);

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <list>
#include <set>

struct M {
    int p, b;

    bool operator<(const M &rhs) const {
        return p < rhs.p;
    }
};

struct F {
    int l, r;
};

std::vector<F> *v;

struct Fp {
    int i;

    int l() const {
        return v->at(i).l;
    }

    int l(int value) const {
        return v->at(i).l = value;
    }

    int r() const {
        return v->at(i).r;
    }

    int r(int value) const {
        return v->at(i).r += value;
    }

    bool operator<(const Fp &rhs) const {
        return v->at(i).l < v->at(rhs.i).l;
    }
};

struct R {
    int t, e=0;
};

void solve(std::vector<F> &fs_v, std::vector<M> &ms) {
    std::vector<R> rs; {
        rs.reserve(fs_v.size());
        for(int i=0; i<fs_v.size(); i++) {
            rs.push_back({fs_v[i].r - fs_v[i].l});
        }
    }
    std::set<Fp> fs; {
        v = &fs_v;
        std::vector<Fp> fs_sort;
        fs_sort.reserve(fs_v.size());
        for(int i=0; i<fs_v.size(); i++) {
            fs_sort.push_back({i});
        }

        std::sort(fs_sort.begin(), fs_sort.end());

        fs.insert(fs_sort[0]);
        int curr = fs_sort[0].r();
        for(int i=1; i<fs_sort.size(); i++) {
            Fp &f = fs_sort[i];

            if(f.r() > curr) {
                f.l(std::max(curr+1, f.l()));
                curr = f.r();

                fs.insert(f);
            }
        }
    }
    std::multiset<M> ms_landed;

    auto f_update = [&] (const Fp &f, std::set<Fp> &fs, int b) {
        rs[f.i].e++;
        rs[f.i].t += b;
        f.r(b);

        while(true) {
            auto f_succ_it = fs.upper_bound(f);
            if(f_succ_it == fs.end()) break;
            Fp f_succ = *f_succ_it;

            if(f.r() >= f_succ.r()) {
                fs.erase(f_succ_it);
            } else {
                if(f.r() >= f_succ.l()) {
                    f_succ.l(std::max(f.r()+1, f_succ.l()));
                }

                break;
            }
        }
    };

    for(int i=0; i<ms.size(); i++) {
        const M &m = ms[i];

        auto f_pred = --fs.upper_bound({m.p});
        if(f_pred == fs.end()) continue;
        const Fp &f = *f_pred;

        if(f.l() <= m.p && m.p <= f.r()) {
            f_update(f, fs, m.b);

            auto m_succ = ms_landed.lower_bound({f.l()});
            while(m_succ != ms_landed.end()) {
                const M &m = *m_succ;
                if(f.l() <= m.p && m.p <= f.r()) {
                    f_update(f, fs, m.b);
                    m_succ = ms_landed.erase(m_succ);
                } else {
                    m_succ++;
                }
            }
        } else {
            ms_landed.insert(m);
        }
    }

    for(R &r: rs) {
        printf("%d %d\n", r.e, r.t);
    }
}

int main() {
    int n;
    int m;
    scanf("%d%d", &n, &m);

    std::vector<F> fs(n);
    std::vector<M> ms(m);

    for(int i=0; i<n; i++) {
        scanf("%d%d", &(fs[i].l), &(fs[i].r));
        fs[i].r += fs[i].l;
    }

    for(int i=0; i<m; i++) {
        scanf("%d%d", &(ms[i].p), &(ms[i].b));
    }

    solve(fs, ms);

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <list>
#include <set>

struct M {
    int p, b;

    bool operator<(const M &rhs) const {
        return p < rhs.p;
    }
};

struct F {
    int l, r, i;
    int p, e=0;

    int t() { return r-p; }
};

struct Fp {
    F *p;

    bool operator<(const Fp &rhs) const {
        return p->l < rhs.p->l;
    }
};

void solve(std::vector<F> &fs_v, std::vector<M> &ms) {
    std::set<Fp> fs; {
        std::vector<Fp> fs_sort;
        fs_sort.reserve(fs_v.size());
        for(int i=0; i<fs_v.size(); i++) {
            fs_sort.push_back({&(fs_v[i])});
        }

        std::sort(fs_sort.begin(), fs_sort.end());

        fs.insert(fs_sort[0]);
        int curr = fs_sort[0].p->r;
        for(int i=1; i<fs_sort.size(); i++) {
            Fp &f = fs_sort[i];

            if(f.p->r > curr) {
                f.p->l = std::max(curr+1, f.p->l);
                curr = f.p->r;

                fs.insert(f);
            }
        }
    }
    std::multiset<M> ms_landed;

    auto f_update = [&] (const Fp &f, std::set<Fp>::iterator &f_it, std::set<Fp> &fs, int b) {
        f.p->e++;
        f.p->r += b;

        while(true) {
            if(f_it == fs.end()) break;
            Fp f_succ = *f_it;

            if(f.p->r >= f_succ.p->r) {
                f_it = fs.erase(f_it);
            } else {
                if(f.p->r >= f_succ.p->r) {
                    f_succ.p->l = std::max(f.p->r+1, f_succ.p->l);
                }

                break;
            }
        }
    };

    for(int i=0; i<ms.size(); i++) {
        const M &m = ms[i];

        F m_f = {m.p};
        auto f_it = --fs.upper_bound({&m_f});
        if(f_it == fs.end()) continue;
        const Fp &f = *f_it;

        if(f.p->l <= m.p && m.p <= f.p->r) {
            f_it++;
            f_update(f, f_it, fs, m.b);

            auto m_succ = ms_landed.lower_bound({f.p->l});
            while(m_succ != ms_landed.end()) {
                const M &m = *m_succ;
                if(f.p->l <= m.p && m.p <= f.p->r) {
                    f_update(f, f_it, fs, m.b);
                    m_succ = ms_landed.erase(m_succ);
                } else {
                    m_succ++;
                }
            }
        } else {
            ms_landed.insert(m);
        }
    }

    for(F &f: fs_v) {
        printf("%d %d\n", f.e, f.t());
    }
}

int main() {
    int n;
    int m;
    scanf("%d%d", &n, &m);

    std::vector<F> fs(n);
    std::vector<M> ms(m);

    for(int i=0; i<n; i++) {
        scanf("%d%d", &(fs[i].l), &(fs[i].r));
        fs[i].r += fs[i].l;
        fs[i].i = i;
        fs[i].p = fs[i].l;
    }

    for(int i=0; i<m; i++) {
        scanf("%d%d", &(ms[i].p), &(ms[i].b));
    }

    solve(fs, ms);

    return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

struct M {
    int p, b;

    bool operator<(const M &rhs) const {
        return p < rhs.p;
    }
};

struct F {
    int l, r;
    int i;
    int t;

    bool operator<(const F &rhs) const {
        return l < rhs.l;
    }
};

struct R {
    int t, e=0;
};

void solve(std::vector<F> &fs_v, std::vector<M> &ms_v) {
    std::vector<R> rs; {
        rs.reserve(fs_v.size());
        for(int i=0; i<fs_v.size(); i++) {
            rs.push_back({fs_v[i].t});
        }
    }
    std::set<F> fs; {
        for(F &f : fs_v) fs.insert(f);
    }
    std::set<M> ms; {
        for(M &m : ms_v) ms.insert(m);
    }

    auto eat2 = [&] (F &f, std::set<M>::iterator &m_it, int &b) {
        M m = *m_it;

        if(!(f.l <= m.p && m.p <= f.r)) return false;

        rs[f.i].e++;
        rs[f.i].t += m.b;
        b += m.b;

        m_it = ms.erase(m_it);

        return true;
    };

    std::set<F> fs_ate_last;
    do {
        for(F f : fs) {
            int b = 0;
            std::set<M>::iterator m_succ;
            do {
                m_succ = ms.lower_bound({f.l});
            } while(m_succ != ms.end() && eat2(f, m_succ, b));

            if(b > 0) {
                f.r += b;
                fs_ate_last.insert(f);
            }
        }

        fs.clear();
        std::swap(fs, fs_ate_last);
    } while(fs.size());

    for(R &r: rs) {
        std::cout << r.e << " " << r.t << std::endl;
    }
}

int main() {
    int n; std::cin >> n;
    int m; std::cin >> m;

    std::vector<F> fs(n);
    std::vector<M> ms(m);

    for(int i=0; i<n; i++) {
        std::cin >> fs[i].l;
        std::cin >> fs[i].t;

        fs[i].i = i;
        fs[i].r = fs[i].l + fs[i].t;
    }

    for(int i=0; i<m; i++) {
        std::cin >> ms[i].p;
        std::cin >> ms[i].b;
    }

    solve(fs, ms);

    return 0;
}