#include <iostream>
#include <vector>
#include <queue>
using namespace std;

typedef pair<int, int> P;

int main() {
  int n, q, a, v, f[1000001] = {};
  
  priority_queue<P> pq;

  for(;;) {
    if(cin >> a >> v); else break;
    f[a] += v;
    pq.push(P(f[a], -a));
    for(;;) {
      int A = pq.top().first;
      int B = -pq.top().second;

      if(f[B] == A) {
	cout << B << " " << A << endl;
	break;
      } else {
	pq.pop();
      }
    }
  }
  
  return 0;
}