#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }



const long long INF = 1LL<<61;
const int MAX_R = 2000000;

int SIZE_R;
struct RMQ {
    pair<long long, int> dat[2*MAX_R-1];
    
    void init(int n = MAX_R, long long v = 0) {
        SIZE_R = 1;
        while (SIZE_R < n) SIZE_R *= 2; 
        for (int i = 0; i < 2*MAX_R-1; ++i) dat[i] = make_pair(v, -1);
    }
    
    inline void set(int a, long long x) { 
        int k = a + SIZE_R-1;
        dat[k] = make_pair(x, a);
    }
    
    inline void init_tree(int k = 0, int l = 0, int r = SIZE_R) {
        if (r - l == 1) {}                  // leaf
        else {
            init_tree(k*2+1, l, (l+r)/2);
            init_tree(k*2+2, (l+r)/2, r);
            dat[k] = min(dat[k*2+1], dat[k*2+2]);
        }
    }
    
    inline void update(int a, long long x) {
        int k = a + SIZE_R-1;
        dat[k] = make_pair(x, a);
        while (k > 0) {
            k = (k-1)/2;
            dat[k] = min(dat[k*2+1], dat[k*2+2]);
        }
    }
    
    inline pair<long long, int> get(int a, int b, int k = 0, int l = 0, int r = SIZE_R) {
        if (r <= a || b <= l) return pair<long long, int>(INF, -1);
        if (a <= l && r <= b) return dat[k];
        else {
            pair<long long, int> vl = get(a, b, k*2+1, l, (l+r)/2);
            pair<long long, int> vr = get(a, b, k*2+2, (l+r)/2, r);
            return min(vl, vr);
        }
    }
    
    void print(int r = SIZE_R) {
        for (int i = 0; i < SIZE_R; ++i) {cout << get(i, i+1) << ",";}
        cout << endl;
    }
};

RMQ rmq;


int n, q, a, v;


int main() {
    while (cin >> n >> q) {
        rmq.init(n+1);
        for (int i = 0; i < q; ++i) {
            cin >> a >> v;
            rmq.update(a, rmq.get(a, a+1).first - v);
            
            //rmq.print();
            
            pint res = rmq.get(0, n+1);
            cout << res.second << " " << -res.first << endl;
        }
    }
    
    return 0;
}
