#include <iostream>
#include <queue>
#include <vector>
#include <utility>

int main(void){
  int n, q;
  std::pair<int, int> max;
  std::priority_queue<std::pair<int, int> > v;
  std::vector<int> a(1000000, 0);
  std::cin >> n >> q;
  for(int i=0; i < q; i++){
    int man, fish_number; std::cin >> man >> fish_number;
    a[man] += fish_number;
    v.push(std::pair<int, int>(a[man], -man));
    
    while(1){
      max = v.top();
      if(max.first == a[-max.second]){
	std::cout << -max.second << " " << max.first << std::endl;
	break;
      }
      v.pop();
    }
  }
  return 0;
}