#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef pair<int, int> P;
const int MAX_N = 2000010;

int N, Q;
P v[2 * MAX_N - 1];

void init(int _n){
  N = 1;
  while(N < _n) N *= 2;
  REP(i, 2 * N - 1) v[i] = P(0, 0);
  REP(i, _n) v[i + N - 1].second = i * -1;
}

void update(int k, int a){
  k += N - 1;
  v[k].first += a;
  while(k > 0){
    k = (k - 1) / 2;
    v[k] = max(v[k * 2 + 1], v[k * 2 + 2]);
  }
}

int main() {
  cin >>N >>Q;
  init(N);
  REP(i, Q){
    int a, b; cin >>a >>b;
    update(a - 1, b);
    cout <<v[0].second * -1 + 1 <<" " <<v[0].first <<endl;
  }
  return 0;
}