import java.lang.Math.*


fun main(args:Array<String>):Unit {
    val (n, q) = readLine()!!.split(' ').map(String::toInt)
    val maxSegmentTree = MaxSegmentTree(n)
    repeat(q){
        val (a, v) = readLine()!!.split(' ')//.map(String::toInt)
        maxSegmentTree.addAt(a.toInt() - 1, v.toInt())
        val (id, fish) = maxSegmentTree.max()
        println("$id $fish")
    }
}
data class Player(val id:Int, val fish:Int)
class MaxSegmentTree constructor (val mArray:Array<Array<Player>>){
    companion object {
        operator fun invoke(size:Int):MaxSegmentTree{
            val default = Player(0, 0)
            var s = size shl 1
            val a = Array(ceil(log(size.toDouble()) / log(2e0) + 1).toInt()){
                s = (s + 1) shr 1
                Array(s){default}
            }
            a[0] = a[0].mapIndexed{index, player -> player.copy(id = index + 1)}.toTypedArray()
            return MaxSegmentTree(a)
        }
    }
    fun addAt(playerId:Int, value:Int):Unit{
        mArray[0][playerId] = mArray[0][playerId].copy(fish = mArray[0][playerId].fish + value)
        var pos = playerId shr 1
        for (i in 1 until mArray.size){
            mArray[i][pos] = mArray[i - 1][pos * 2]
            if (mArray[i - 1].indices.contains(pos * 2 + 1) && mArray[i][pos].fish < mArray[i - 1][pos * 2 + 1].fish) mArray[i][pos] = mArray[i - 1][pos * 2 + 1]
            pos = pos shr 1
        }
    }
    fun max():Player = mArray.last().first()
}
