import scala.util.Random

object Main extends App {

  import scala.io.StdIn._
  import scala.math._

  val rand = new Random()
  val Array(n, c) = readLine.trim.split(' ').map(_.toInt)
  val team = Array.tabulate(n){id ⇒ Team(id + 1, 0L)}
  var treap = team.foldLeft(Leaf:Treap[Team]){case (treap, team) ⇒ treap.insert(team, rand.nextDouble())}
  for (_ ← 0 until c){
    val command = readLine.trim.split(' ').map(_.toInt)
    command match {
      case Array(0, t, p) ⇒
        val current = team(t - 1)
        treap = treap.erase(current)
        team(t - 1) = Team(t, current.score + p)
        treap = treap.insert(team(t - 1), rand.nextDouble())
      case Array(1, m) ⇒
        println(
          treap.findNth(m).get.let{t ⇒ s"${t.id} ${t.score}"}
        )
      case _ ⇒ ???
    }
  }
  case class Team(id: Int, score:Long) extends Ordered[Team] {
    override def compare(that: Team): Int = if (score == that.score) id.compare(that.id) else that.score.compare(score)
  }
  sealed trait Treap[+T] {
    def size: Int
    def findNth(rank: Int): Option[T]
    def insert[TT >: T <: Ordered[TT]](value: TT, priority: Double): Treap[TT]
    def erase[TT >: T <: Ordered[TT]](value: TT): Treap[T]
  }
  case class Node[T <: Ordered[T]](value: T, priority: Double, left: Treap[T], right: Treap[T]) extends Treap[T] {
    override val size: Int = left.size + right.size + 1

    override def findNth(rank: Int): Option[T] = {
      if (left.size >= rank) left.findNth(rank)
      else if (left.size + 1 == rank) Some(value)
      else right.findNth(rank - left.size - 1)
    }

    override def insert[TT >: T <: Ordered[TT]](value: TT, priority: Double): Treap[TT] = {
       value.compare(this.value) match {
        case 0 ⇒ throw new Error(s"$value is already exists")
        case 1 ⇒ right.insert(value, priority) match {
          case Node(v, p, l, r) if p > this.priority ⇒ Node(v, p, Node(this.value, this.priority, left, l), r)
          case r ⇒ Node(this.value, this.priority, left, r)
        }
        case _ ⇒ left.insert(value, priority) match {
          case Node(v, p, l, r) if p > this.priority ⇒ Node(v, p, l, Node(this.value, this.priority, r, right))
          case l ⇒ Node(this.value, this.priority, l, right)
        }
      }
    }

    override def erase[TT >: T <: Ordered[TT]](value: TT): Treap[T] = {
      value.compare(this.value) match {
        case 0 ⇒ (left, right) match {
          case (Node(lv, lp, ll, lr), r@Node(_, rp, _, _)) if lp > rp ⇒ Node(lv, lp, ll, Node(this.value, this.priority, lr, r).erase(value))
          case (l@Node(_, lp, _, _), Node(rv, rp, rl, rr)) if lp < rp ⇒ Node(rv, rp, Node(this.value, this.priority, l, rl).erase(value), rr)
          case (Leaf, r) ⇒ r
          case (l, Leaf) ⇒ l
        }
        case 1 ⇒ Node(this.value, this.priority, left, right.erase(value))
        case _ ⇒ Node(this.value, this.priority, left.erase(value), right)
      }
    }

    override def toString: String = (if (left.isInstanceOf[Node[_]]) left.toString + "," else "") + value.toString + (if (right.isInstanceOf[Node[_]]) "," + right.toString else "")
  }
  case object Leaf extends Treap[Nothing] {
    override val size: Int = 0
    override def findNth(rank: Int): Option[Nothing] = None
    override def insert[TT >: Nothing <: Ordered[TT]](value: TT, priority: Double): Treap[TT] = Node(value, priority, Leaf, Leaf)
    override def erase[TT >: Nothing <: Ordered[TT]](value: TT): Treap[Nothing] = Leaf
  }

  implicit class Extenion[T](val value :T){
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
    def let[R](func: T ⇒ R): R = func(value)
  }
}
/*


 */


Measured memory_bytes: 465096