import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;

class Main {

	//??????????????¨?????????????????????????????°???????????????????????????
	public static Map<Integer, Integer> _winnerFishesMap = new HashMap<Integer,Integer>();


	public static void main(String[] args){

		Scanner input = new Scanner(System.in);

		String[] menAndEvents = input.nextLine().split(" ");

		//????????????????????????????????°??¨?????????????????°?????????
		int numPlayer = Integer.parseInt(menAndEvents[0]);
		int numEvents = Integer.parseInt(menAndEvents[1]);

		//??¶?´??????¶
		if(numPlayer >= 1 && numPlayer <= 1000000 && numEvents >= 1 && numEvents <= 100000){

			int bestWinner = 0;
			int bestFish =0;

			//?????????????????????????¨??????????
			for(int iEvent = 0; iEvent < numEvents; iEvent++){

				int winner = input.nextInt();
				int numFish = input.nextInt();

				//??¶?´??????¶
				if(winner >= 1 && winner <= numPlayer && numFish >= -100 && numFish <= 100 && numFish != 0){
					int tmpNumFish = 0;
					//???????????????????????????????????¨????????´??????????????§????????????????????°???????????????
					if(_winnerFishesMap.containsKey(winner)){
						tmpNumFish = _winnerFishesMap.get(winner);
					}

					//?????????????????????????????????????????´??°??????
					_winnerFishesMap.put(winner, tmpNumFish + numFish);

					//?????¶?????????????????????????????????????????????????????§???????????????????????????????????????????????§????????????
					//????????????????????????????????°???????????¨????????´???????????????????????\???
					if(numFish < 0 && winner == bestWinner){

						//?????????????????????????????????????????????????¢??????????????????????????????¨?????????????????¨????????????????????????
						List<Entry<Integer,Integer>> winnerFishesEntryList = new ArrayList<Entry<Integer,Integer>>(_winnerFishesMap.entrySet());

						Collections.sort(winnerFishesEntryList, new Comparator<Entry<Integer,Integer>>(){
			                public int compare(Entry<Integer,Integer> o1, Entry<Integer,Integer> o2){
			                    return o2.getValue().compareTo(o1.getValue());
			                }
			            });

						//?????????????????£??????????????????????????????????????????????????????????????????
						Iterator<Entry<Integer,Integer>> winnerFishesEntryItr = winnerFishesEntryList.iterator();
						Entry<Integer,Integer> tmpEntry = winnerFishesEntryItr.next();
						bestWinner	= tmpEntry.getKey();
						bestFish	= tmpEntry.getValue();
						//???????????????????¢???????????????????????????????????¢??????????
						while(winnerFishesEntryItr.hasNext()){
							Entry<Integer,Integer> tmpWinnerFishesEntry = winnerFishesEntryItr.next();
							if(bestFish == tmpWinnerFishesEntry.getValue() && bestWinner > tmpWinnerFishesEntry.getKey()){
								bestWinner	= tmpWinnerFishesEntry.getKey();
								bestFish	= tmpWinnerFishesEntry.getValue();
							}
						}
					} else {
						if(tmpNumFish + numFish > bestFish){
							bestWinner	= winner;
							bestFish	= tmpNumFish + numFish;
						} else if(tmpNumFish + numFish == bestFish && bestWinner > winner){
							bestWinner	= winner;
						}
					}
					System.out.println(bestWinner + " " + bestFish);
				}
			}
		}
		input.close();
	}

}

Measured memory_bytes: 78308