#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
#define int ll

const int MAX_N = 1 << 20;
int n;
pair<ll, ll> dat[2*MAX_N-1];

void init(int n_) {
  n = 1;
  while(n < n_) n *= 2;
  REP(i, 2*n-1) dat[i] = {0, max((ll)0, i-n+1)};
}

//k??????(0-index)?????????a????¶????
void update(int k, int a) {
  k += n-1;
  dat[k].first += a;
  while(k > 0) {
    k = (k-1)/2;
    if(dat[k*2+1].first != dat[k*2+2].first) {
      dat[k] = max(dat[k*2+1], dat[k*2+2]);
    } else {
      if(dat[k*2+1].second < dat[k*2+2].second) dat[k] = dat[k*2+1];
      else dat[k] = dat[k*2+2];
    }
  }
}

pair<ll, ll> query(int a, int b, int k, int l, int r) {
  if(r <= a || b <= l) return {-INF, INF};

  if(a <= l && r <= b) return dat[k];
  else {
    PII vl = query(a, b, k*2+1, l, (l+r)/2),
        vr = query(a, b, k*2+2, (l+r)/2, r);
    cout << l << " " << r << " " << vl.first << " " << vr.first << endl;
    if(vl.first != vr.first) {
      return max(vl, vr);
    } else {
      //cout << "a" << endl;
      if(vl.second < vr.second) return vl;
      else return vr;
    }
  }
}

signed main(void)
{
  int q;
  cin >> n >> q;

  init(n);
  REP(i, q) {
    int a, v;
    cin >> a >> v;
    update(a-1, v);
    pair<ll, ll> ret = query(0, n, 0, 0, n);
    cout << ret.second+1 << " " << ret.first << endl;
    /*cout << endl;
    REP(i, 2*n-1) {
      cout << i << " " << dat[i].second+1 << " " << dat[i].first << endl;
    }
    cout << endl;*/
  }
/*
  cout << endl;
  REP(i, 3) {
    cout << dat[i].first << " " << dat[i].second << endl;
  }
*/
  return 0;
}