#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    int n,q;
    int a,v;
    vector<int> vec;
    cin >> n >> q;
    vec.resize(n);
    fill(vec.begin(), vec.end(), 0);
    while(cin >> a >> v)
    {
        vec[a-1] += v;
        auto itr = max_element(vec.begin(), vec.end());
        int index = distance(vec.begin(), itr) + 1;
        cout << index << " " << *itr << endl;
    }
    return 0;
}