#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define pb            push_back
template<class T, class S> inline pair<T, S> mp(const T x, const S y){ return make_pair(x, y); }
template<class T, class S> inline bool minup(T& m, const S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, const S x){ return m<(T)x ? (m=(T)x, true) : false; }

static const int    INF = 1000000000;
static const ll     MOD = 1000000007LL;
static const double EPS = 1E-10;

// ???????????????????¨?
template<typename T> struct SkewHeap
{
public:
  struct Node
  {
    Node *left, *right;
    T v;
    Node() : left(NULL), right(NULL) {}
    Node(T v) : left(NULL), right(NULL), v(v) {}
  }* root;
  int cnt;
  SkewHeap(T v) : root(new Node(v)), cnt(0) {}

  Node* meld(Node* l, Node* r)
  {
    if(l == NULL) return r;
    if(r == NULL) return l;
    if(l->v < r->v) swap(l, r);
    l->right = meld(l->right, r);
    swap(l->left, l->right);
    return l;
  }

  inline void push(T x)
  {
    Node* n = new Node(x);
    root = meld(root, n);
    cnt += 1;
  }

  inline void pop()
  {
    Node* n = root;
    root = meld(root->right, root->left);
    delete n;
    cnt -= 1;
  }

  inline void pop(Node* root)
  {
    Node* n = root;
    root = meld(root->right, root->left);
    delete n;
  }

  inline T top(){ return root->v; }
  inline int size(){ return cnt; }
  inline bool empty(){ return !cnt; }
};

const int MAX_N = 1000000;
int n, q;
int a, v;
int cnt[MAX_N+1];

int main()
{
  SkewHeap<pii> heap = SkewHeap<pii>(mp(-INF, -INF));

  cin >> n >> q;
  while(q--){
    cin >> a >> v;
    cnt[a] += v;
    heap.push(mp(cnt[a], -a));

    while(!heap.empty()){
      pii popop = heap.top();
      if(cnt[-popop.second] == popop.first){
        cout << -popop.second << ' ' << popop.first << endl;
        break;
      }
      heap.pop();
    }
  }

  return 0;
}