#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<utility>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<set>
 
using namespace std;
const int dx[] = {1,0,-1,0},dy[] = {0,1,0,-1};
#define INF 1e+9
#define EPS 1e-9
#define rep(i,j) for(int i = 0; i < (j); i++)
#define reps(i,j,k) for(int i = j; i < (k); i++)
typedef long long ll;
int main(){
    int n,q;
    scanf("%d%d",&n,&q);
    map<ll ,int> Data;
    rep(i,q){
        int a,v;
        scanf("%d%d",&a,&v);
        Data[a] += v;
        ll b;
        int w = 0;
        for(map<ll,int>::iterator it = Data.begin(); it != Data.end() ; it++){
            if((*it).second > w){
                b = (*it).first;
                w = (*it).second;
            }
        }
        printf("%lld %d\n",b,w);
    }
    return 0;
}