#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;

const long double PI = acos(-1);
constexpr long double EPS = 1e-15;
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;

//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

ll cnt[1000010];

int main(){
  int a,b;
  cin >> a >> b;
  set<pair<ll,int>> st;
  REP(i,b) {
    int x,y;
    cin >> x >> y;
    st.erase({cnt[x],a-x});
    cnt[x] += y;
    st.insert({cnt[x],a-x});
    set<pair<ll,int>>::iterator it = st.end();
    it--;
    cout << a - (*it).se << " " << (*it).fi << endl;
  }

  return 0;
}

