object Main{
  def main(args:Array[String]):Unit={
    var record:Map[Int,Array[Int]] = Map()
    var NM = readLine.split(" ").map(x => x.toInt)
    for(i <- 0 until NM(1)){
      var tmp = readLine.split(" ").map(x => x.toInt)
      var tmpArray = record.getOrElse(tmp(0),Array())
      tmpArray = tmpArray :+ tmp(1)
      record += (tmp(0) -> tmpArray)
    }
    var keys = record.keySet.toArray.sorted
    for(i <- 0 until keys.length){
      var province = keys(i)
      var city = record.getOrElse(keys(i),Array())
      for(j <- 0 until city.length){
        print("%6d",province.toString)
        println("6%",city(j).toString)
      }
    }
}