object Main {
  def main(args: Array[String]) {

    val numList = (1 to 13).toSet

    var list: List[String] = List()
    for (line <- scala.io.Source.stdin.getLines()) {
      list = list :+ line
    }
    list = list.slice(1, list.length)

    var cardMap = Map[String, Set[Int]]()

    for (line <- list) {
      var Array(k, v) = line.split(" ")
      var g: Set[Int] = cardMap.getOrElse(k, Set())
      if (g == Set()) {
        cardMap += k -> Set(v.toInt)
      } else {
        g = g + v.toInt
        cardMap += k -> g
      }
    }
    for ((m, v) <- cardMap) {
      for (dv <- (numList &~ v)) println(m + " " + dv)
    }
  }
}