#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>

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;
typedef vector<int> vint;
typedef vector<char> vchar;

#define PI 3.141592653589793238462643383279
#define intmax 2000000014
#define longmax 2000000000000000014LL
#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 intn(n, a) rep(i, n)scanf("%d", &a[i]);
#define int2n(n, a, b) rep(i, n)scanf("%d%d", &a[i], &b[i]);
#define sc(x) cin >> x
#define sc2(x, y) cin >> x >> y
#define sc3(x, y, z) cin >> 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 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 debugn(i, n, a) rep(i, n)cout << " --- " << a[i] << "\n";
#define debugin(i, n, a) rep(i, n)printf(" --- %10d\n", a[i])
#define debugi2n(i, n, a, b) rep(i, n)printf(" --- %10d %10d\n", a[i], b[i])
#define debugiin(i, n, a) rep(i, n)printf(" --- %10d %10d\n", a[i].first, a[i].second)
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

int i, j, tmp, tmp2;

struct segtree{
	vint data;
	void use(int n){
    int x;
    for(x = 0;;x++)if((1 << x) > n)break;
    x = 1 << x;
    data.assign(x + 1, 0);
    data[0] = x;
  }
  void update(int num, int v){
    data[data[0] + num] += v;
    for(i = data[0] + num;i > 1;data[i] = updater(data[i * 2], data[i * 2 + 1]))i /= 2;
  }
  int updater(int x, int y){
    return max(x, y);
  }
  i_i search(void){
    int resa = data[1], resv;
    for(i = 1;i < data[0];){
      if(data[i * 2] == resa)i = i * 2;
      else i = i * 2 + 1;
    }
    return mp(i - data[0], resa);
  }
};

signed main(void){
  for(int testcase = 0;;){
    int2(n, q);
    segtree seg; seg.use(n);
    for(;q--;){
      int2(a, v);
      seg.update(--a, v);
      i_i res = seg.search();
      pri2(res.X + 1, res.Y);
    }

/*/
    pri(++testcase);

//*/ break;
  }
  return 0;
}