#include <cstdio>
#include <set>
#include <functional>
using namespace std;

typedef pair<int, int> Pair;

int n;
int q;
int num[1000001];
set<Pair, greater<Pair> > rank;

int main() {
  scanf("%d%d", &n, &q);
  for (int i=0; i<q; i++) {
    int a, v;
    scanf("%d%d", &a, &v);
    rank.erase(Pair(num[a], -a));
    num[a] += v;
    rank.insert(Pair(num[a], -a));
    printf("%2$d %1$d\n", rank.begin()->first, -rank.begin()->second);
  }
}