import scala.io.StdIn.{readInt,readLine}
import scala.collection.mutable.Stack

object Main {
  def getAngle(p0:(Double,Double),p:(Double,Double)):Double =
    (p._1-p0._1)/Math.sqrt(Math.pow(p._1-p0._1,2)+Math.pow(p._2-p0._2,2))

  def product(p1:(Double,Double),p2:(Double,Double),p3:(Double,Double)):Double =
    (p2._1-p1._1)*(p3._2-p1._2) - (p2._2-p1._2)*(p3._1-p1._1)

  def remove(i:Int,j:Int,sorted:Array[(Double,Double)],n:Int):(Int,Int) = {
    if(product(sorted(j-1),sorted(j),sorted(i)) >= 0) (i,j+1)
    else {
      if(j>1) remove(i,j-1,sorted,n) else if(i==n) (i,j+1) else remove(i+1,j,sorted, n)
    }
  }

  def scan(i:Int,j:Int,sorted:Array[(Double,Double)],n:Int):Int = {
    if(i>n) j
    else {
      val (x,y) = remove(i,j,sorted,n)
      val temp = sorted(y); sorted(y) = sorted(x); sorted(x) = temp
      scan(x+1,y,sorted,n)
    }
  }

  def main(args:Array[String]) = {
    val n = readInt
    var minVal = (Double.MaxValue,Double.MaxValue,0)
    val points = {for(i <- 0 until n) yield readLine.split(" ").map(_.toDouble) match {
        case Array(x,y) =>
          if( (y < minVal._2) || (y==minVal._2 && x < minVal._1) ) minVal = (x,y,i)
          (x,y,i)
      }
    }.toArray
    points(minVal._3) = points(0)
    points(0) = minVal

    val sorted = Array((0D,0D)) ++ points.map{ p =>
      (p._1, p._2, getAngle((minVal._1,minVal._2),(p._1,p._2)))
    }.sortWith(_._3 > _._3).map( p => (p._1,p._2) )

    sorted(0) = sorted(n)
    val m = scan(2,1,sorted,n)
    println(m)
    for(i<-1 to m) { println(sorted(i)._1.toInt + " " + sorted(i)._2.toInt) }
  }
}