#include<iostream>
#include<sstream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cfloat>
#include<functional>
#include<map>
#include<string>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<bitset>
#include<list>
#include<numeric>
#include<complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<long long, long long> ll_ll;
typedef pair<double, double> d_d;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define rep2d(i, j, n) for(i = 0;i < n;++i)for(j = i + 1;j < n;++j)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << x << "\n"
#define pri2(x, y) cout << x << " " << y << "\n"
#define pri3(x, y, z) cout << x << " " << y << " " << z << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << x << "\n"
#define debug2(x, y) cout << " --- " << x << " " << y << "\n"
#define debug3(x, y, z) cout << " --- " << x << " " << y << " " << z << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

bool mycom(i_i a, i_i b){
  if(a.X == b.X)return a.Y < b.Y;
  return a.X > b.X;
}

signed main(void){
  int i, j, k;
  int a[25] = {1};
  rep1(i, 25)a[i] = a[i - 1] * 2;
  for(int testcase = 0;testcase < 1234567;testcase++){
    int2(n, q);
    rep(i, 25)if(n <= a[i])break;

    vector<i_i> sgt;
    sgt.resize(a[i]);
    rep(j, a[i])sgt[j] = mp(-123, n + 1);
    sgt[0] = mp(i, a[i]);

    rep(i, n)sgt[sgt[0].Y + i] = mp(0, i + 1);

    for(;q--;){
      int2(x, v);
      x = sgt[0].Y + x - 1;
      if(v > 0){
        sgt[x].X += v;
        for(;x != 1;x/=2){
          if(mycom(sgt[x], sgt[x / 2]))sgt[x / 2] = sgt[x];
          else break;
        }
      }else{
        sgt[x].X += v;
        for(;x != 1;x/=2){
          if(mycom(sgt[(x / 2) * 2], sgt[(x / 2) * 2 + 1]))sgt[x / 2] = sgt[(x / 2) * 2];
          else sgt[x / 2] = sgt[(x / 2) * 2 + 1];
        }
      }
      pri2(sgt[1].Y, sgt[1].X);
    }


/*/

//*/ break;
  }
  return 0;
}