import scala.io.StdIn


case class Ranking(city: String, count:Int)

object Main extends App {

  val n  = StdIn.readLine().toInt
  var b: Array[Ranking]  = Array.empty

  (1 to n).foreach { i => 
    val Array(city: String, count: String) =  StdIn.readLine.split(" ")
    val c = Ranking(city, count.toInt)
    b = b ++ Array(c)
  }

  var ret :Array[Int] = Array.empty
  b.foreach { v =>
    val cityRank = b.filter(_.city < v.city).length
    val countRank = b.filter(_.city == v.city).filter(_.count > v.count).length + 1
    println(cityRank + countRank)
  }

}
  

