#include <iostream>
#include <set>
using namespace std;
typedef pair<int, int> Pii;
int main() {
  int N, Q;
  cin >> N >> Q;
  static int memo[1000001];
  set<Pii> st;
  
  for(int q=0; q<Q; q++) {
    int a, v; cin >> a >> v;
    st.erase(Pii(-memo[a], a));
    memo[a] += v;
    st.insert(Pii(-memo[a], a));
    cout << st.begin()->second << ' ' << -st.begin()->first << endl;
  }
  
  return 0;
}