
fun main(args:Array<String>):Unit {
    println(Array(readLine()!!.toInt()){
        val (x, y) = readLine()!!.split(' ').map(String::toInt)
        Point(x, y)
    }.sorted().joinToString("\n"))
}
data class Point(val x:Int, val y:Int):Comparable<Point> {
    override fun compareTo(other: Point): Int {
        return if (x == other.x) y.compareTo(other.y) else x.compareTo(other.x)
    }

    override fun toString(): String {
        return "$x $y"
    }
}
