import io.StdIn.readLine

object Mahmoud extends App {

  val a = readLine()
  val b = readLine()
  val s = solve(a, b)
  println (s)

  def solve (a: String, b: String) : Int = {

    if (a == b) -1 else a.length.max(b.length)
  }
}

object A766 {

  import IO._
  import collection.{mutable => cu}

  def main(args: Array[String]): Unit = {
    val first = read
    val second = read

    if(first.compareTo(second) == 0) {
      println(-1)
    } else {
      println(math.max(first.length, second.length))
    }
  }

  object IO {
    private val input = new java.io.BufferedReader(new java.io.InputStreamReader(System.in))

    //    private val input = new java.io.BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream("src/input")))
    @inline def read: String = input.readLine()

    @inline def tokenizeLine = new java.util.StringTokenizer(read)

    def readInt: Int = tokenizeLine.nextToken.toInt

    def readInts(n: Int): Array[Int] = {
      val tl = tokenizeLine
      Array.fill(n)(tl.nextToken.toInt)
    }

    def readLongs(n: Int): Array[Long] = {
      val tl = tokenizeLine
      Array.fill(n)(tl.nextToken.toLong)
    }

    def readBigs(n: Int): Array[BigInt] = {
      val tl = tokenizeLine
      Array.fill(n)(BigInt(tl.nextToken))
    }
  }

}

import Utils._, annotation._, collection._, util._, control._, math.Ordering.Implicits._, Searching._

object _766A extends CodeForcesApp {
  override def apply(io: IO) = {import io.{read, write, writeAll, writeLine}
    val a, b = read[String]
    val ans = if (a == b) -1 else (a.length max b.length)
    write(ans)
  }
}
/****************************[Ignore Template Below]****************************************/
trait CodeForcesApp {
  lazy val isOnlineJudge: Boolean = sys.props.get("ONLINE_JUDGE").exists(_.toBoolean)
  def debug(x: => Any): Unit = if (!isOnlineJudge) println(x)
  def apply(io: IO): io.type
  def main(args: Array[String]): Unit = this(new IO(System.in, System.out)).close()
}
object Utils {
  import scala.collection.mutable, mutable.{Map => Dict}
  implicit class GenericExtensions[A](val a: A) extends AnyVal {
    def in(set: collection.Set[A]): Boolean = set(a)
    def some: Option[A] = Some(a)
    def partialMatch[B](f: PartialFunction[A, B]): Option[B] = f lift a
  }
  implicit class TraversableExtensions[A, C[X] <: Traversable[X]](val t: C[A]) extends AnyVal {
    def onlyElement: A = assuming(t.size == 1)(t.head)
    def groupByIdentifier[K](f: A => K): Map[K, A] = t.groupBy(f).mapValues(_.onlyElement)
    def duplicates(implicit b: C of A): C[A] = {
      val elems = mutable.Set.empty[A]
      (t collect {case i if !elems.add(i) => i}).to[C]
    }
    def sumWith[B](f: A => B)(implicit n: Numeric[B]): B = t.foldLeft(n.zero) {case (p, i) => n.plus(p, f(i))}
    def maxWith[B](f: A => B)(implicit ord: Ordering[B]): Option[B] = t.view.map(f).reduceOption(ord.max)
    def minWith[B](f: A => B)(implicit ord: Ordering[B]): Option[B] = t.view.map(f).reduceOption(ord.min)
    def zipWith[B](f: A => B)(implicit b: C of (A, B)): C[(A, B)] = (t map {i => i -> f(i)}).to[C]
    def mapTo[B](f: A => B)(implicit b: C of (A, B)): Map[A, B] = zipWith(f).toUniqueMap
    def whenNonEmpty[B](f: t.type => B): Option[B] = when(t.nonEmpty)(f(t))  // e.g. grades.whenNonEmpty(_.max)
    def collectFirst[B](f: PartialFunction[A, Option[B]]): Option[B] = t.view collect f collectFirst {case Some(x) => x}
    def toMutableMultiSet: Dict[A, Int] = {
      val c = map[A] to 0
      t.foreach(i => c(i) += 1)
      c
    }
    def toMultiSet: Map[A, Int] = toMutableMultiSet.toMap withDefaultValue 0
    def X[B](s: Traversable[B]): Iterator[(A, B)] = for {a <- t.toIterator; b <- s} yield (a, b)
  }
  implicit class ArrayExtensions[A <: AnyRef](val a: Array[A]) extends AnyVal {
    def sort(from: Int, until: Int)(implicit cmp: Ordering[A]): Unit = java.util.Arrays.sort(a, from, until, cmp) //sort [from, until)
  }
  implicit class ArrayExtensions2[A](val a: Array[A]) extends AnyVal {
    def sort(from: Int, until: Int)(implicit cmp: Ordering[A]): Unit = a.view(from, until).sorted.copyToArray(a, from)
  }
  implicit class SeqExtensions[A, C[X] <: Seq[X]](val s: C[A]) extends AnyVal {
    def isRotationOf(t: Seq[A]): Boolean = s ++ s containsSlice t
  }
  implicit class PairExtensions[A, B](val p: (A, B)) extends AnyVal {
    def key = p._1
    def value = p._2
  }
  implicit class PairsExtensions[A, B, C[X] <: Traversable[X]](t: C[(A, B)]) {
    def toUniqueMap: Map[A, B] = t.groupByIdentifier(_.key).mapValues(_.value)
    def toMultiMap(implicit b: C of B): Map[A, C[B]] = t.groupBy(_.key).mapValues(_.map(_.value).to[C])
    def swap(implicit b: C of (B, A)): C[(B, A)] = t.map(_.swap).to[C]
  }
  implicit class MapExtensions[K, V, C[X, Y] <: Map[X, Y]](val m: C[K, V]) extends AnyVal {
    def lastKeyOption: Option[K] = m.lastOption.map(_.key)
    def firstKeyOption: Option[K] = m.headOption.map(_.key)
    def invert: Map[V, Set[K]] = m.toSet[(K, V)].swap.toMultiMap
    def mapKeys[K2](f: K => K2): Map[K2, V] = m map {case (k, v) => f(k) -> v}
    def toMutable: Dict[K, V] = Dict.empty[K, V] ++ m
    def mapValuesSafely[V2](f: V => V2): Map[K, V2] = m.mapValues(f).view.force //Hack to get around https://issues.scala-lang.org/browse/SI-4776
  }
  implicit class MutableMapExtensions[K, V](val m: mutable.Map[K, V]) extends AnyVal {
    def removeLast(): Option[(K, V)] = m.lastOption.map(removeNode)
    def removeFirst(): Option[(K, V)] = m.headOption.map(removeNode)
    private def removeNode(kv: (K, V)): (K, V) = {
      m -= kv.key
      kv
    }
  }
  implicit class SetExtensions[A, C[A] <: Set[A]](val s: C[A]) extends AnyVal {
    def notContains(x: A): Boolean = !(s contains x)
    def toMutable = mutable.Set.empty[A] ++ s
  }
  implicit class IterableExtensions[A, C[A] <: Seq[A]](val s: C[A]) extends AnyVal {
    def indicesWhere(f: A => Boolean): Seq[Int] = s.zipWithIndex.collect {case (a, i) if f(a) => i}
    def deleteAtIndex(i: Int, howMany: Int = 1) = s.patch(i, Nil, howMany)
    def insertAtIndex(i: Int, items: Seq[A]) = s.patch(i, items, 0)
    def findWithIndex(f: A => Boolean): Option[(A, Int)] = s.zipWithIndex find {case (a, _) => f(a)}
    def foldUntil[B](z: B)(f: (B, A) => B)(c: B => Boolean): Option[(B, Int)] = s.view.scanLeft(z)(f).findWithIndex(c)
  }
  implicit class BooleanExtensions(val x: Boolean) extends AnyVal {
    def to[A](implicit n: Numeric[A]) = if(x) n.one else n.zero
    def toEnglish = if(x) "YES" else "NO"
  }
  implicit class IntExtensions(val x: Int) extends AnyVal {
    import java.lang.{Integer => JInt}
    def withHighestOneBit: Int = JInt.highestOneBit(x)
    def withLowestOneBit: Int = JInt.lowestOneBit(x)
    def numberOfLeadingZeroes: Int = JInt.numberOfLeadingZeros(x)
    def numberOfTrailingZeroes: Int = JInt.numberOfTrailingZeros(x)
    def bitCount: Int = JInt.bitCount(x)
    def setLowestBits(n: Int): Int = x | (left(n) - 1)
    def clearLowestBits(n: Int): Int = x & left(n, ~0)
    def setBit(i: Int, set: Boolean): Int = if (set) setBit(i) else clearBit(i)
    def setBit(i: Int): Int = x | left(i)
    def clearBit(i: Int): Int = x & ~left(i)
    def toggleBit(i: Int): Int = x ^ left(i)
    def testBit(i: Int): Boolean = ((x >> i) & 1) == 1
    private def left(bits: Int, num: Int = 1) = assuming(bits >= 0 && bits < JInt.SIZE)(num << bits)
    def X(y: Int): Iterator[(Int, Int)] = until(x) X until(y)
  }
  implicit class LongExtensions(val x: Long) extends AnyVal {
    import java.lang.{Long => JLong}
    def withHighestOneBitSet: Long = JLong.highestOneBit(x)
    def withLowestOneBitSet: Long = JLong.lowestOneBit(x)
    def numberOfLeadingZeroes: Int = JLong.numberOfLeadingZeros(x)
    def numberOfTrailingZeroes: Int = JLong.numberOfTrailingZeros(x)
    def bitCount: Int = JLong.bitCount(x)
    def setLowestBits(n: Int): Long = x | (left(n) - 1)
    def clearLowestBits(n: Int): Long = x & left(n, ~0L)
    def setBit(i: Int, set: Boolean): Long = if (set) setBit(i) else clearBit(i)
    def setBit(i: Int): Long = x | left(i)
    def clearBit(i: Int): Long = x & ~left(i)
    def toggleBit(i: Int): Long = x ^ left(i)
    def testBit(i: Int): Boolean = ((x >> i) & 1) == 1
    private def left(bits: Int, num: Long = 1L) = assuming(bits >= 0 && bits < JLong.SIZE)(num << bits)
  }
  implicit class NumericExtensions[A](val x: A)(implicit n: Numeric[A]) {
    import Numeric.Implicits._
    def **(i: Int): A = if (i == 0) n.one else {
      val h = x ** (i/2)
      if (i%2 == 0) h * h else h * h * x
    }
    def distance(y: A) = (x - y).abs()
    def nonNegative: Option[A] = when(n.gteq(x, n.zero))(x)
    def whenNegative(f: => A): A = nonNegative getOrElse f   //e.g. students indexOf "Greg" whenNegative Int.MaxValue
  }
  implicit class IntegralExtensions[A](val x: A)(implicit n: Integral[A]) {
    import scala.collection.immutable.NumericRange, Integral.Implicits._
    def mod(y: A): A = x - ((x / y) * y) //(x/y)*y + (x mod y) == x
    def -->(y: A): NumericRange.Inclusive[A] = NumericRange.inclusive(x, y, if (n.lteq(x, y)) n.one else -n.one)
    def ceilDiv(y: A): A = if (mod(y) == n.zero) x/y else n.one + (x/y)
  }
  implicit def toPoint[A](p: (A, A))(implicit n: Numeric[A]) = new java.awt.geom.Point2D.Double(n.toDouble(p._1), n.toDouble(p._2))
  def desc[A: Ordering]: Ordering[A] = asc[A].reverse  //e.g. students.sortBy(_.height)(desc)
  def asc[A](implicit order: Ordering[A]): Ordering[A] = order
  def map[K] = new {
    def to[V](default: => V): Dict[K, V] = using(_ => default)
    def using[V](f: K => V): Dict[K, V] = new mutable.HashMap[K, V]() {
      override def apply(key: K) = getOrElseUpdate(key, f(key))
    }
  }
  def newMultiMap[K, V] = map[K] to mutable.Set.empty[V]
  def memoize[A, B](f: A => B): A ==> B = map[A] using f
  implicit class FuzzyDouble(val x: Double) extends AnyVal {
    def  >~(y: Double) = x > y + eps
    def >=~(y: Double) = x >= y + eps
    def  ~<(y: Double) = y >=~ x
    def ~=<(y: Double) = y >~ x
    def  ~=(y: Double) = (x distance y) <= eps
  }
  def toPolygon(points: Traversable[(Int, Int)]): java.awt.Polygon = {
    val (xs, ys) = points.unzip
    new java.awt.Polygon(xs.toArray, ys.toArray, points.size)
  }
  def toShape(points: Traversable[(Double, Double)]): java.awt.geom.GeneralPath = {
    val shape = new java.awt.geom.GeneralPath()
    points.headOption foreach {case (x, y) => shape.moveTo(x, y)}
    points.tail foreach {case (x, y) => shape.lineTo(x, y)}
    shape.closePath()
    shape
  }
  def until(until: Int): Range = 0 until until
  def not[A](f: A => Boolean): A => Boolean = {x: A => !f(x)}
  def assuming[A](cond: => Boolean)(f: => A): A = {require(cond); f}
  @inline def when[A](check: Boolean)(f: => A): Option[A] = if (check) f.some else None
  def repeat[U](n: Int)(f: => U): Unit = (1 to n).foreach(_ => f)
  type of[C[_], A] = scala.collection.generic.CanBuild[A, C[A]]
  type ==>[A, B] = collection.Map[A, B]
  val mod: Int = (1e9 + 7).toInt
  val eps: Double = 1e-9
}
/***********************************[Scala I/O]*********************************************/
import Utils._, java.io._, java.util.StringTokenizer

class IO(in: BufferedReader, out: BufferedWriter) extends Iterator[String] with AutoCloseable with Flushable {
  def this(reader: Reader, writer: Writer) = this(new BufferedReader(reader), new BufferedWriter(writer))
  def this(in: InputStream, out: OutputStream) = this(new InputStreamReader(in), new OutputStreamWriter(out))

  private[this] val tokenizers = Iterator.continually(in.readLine()).takeWhile(_ != null).map(new StringTokenizer(_)).buffered
  val printer = new PrintWriter(out, true)

  @inline private[this] def tokenizer() = {
    while(tokenizers.nonEmpty && !tokenizers.head.hasMoreTokens) tokenizers.next()
    when(tokenizers.nonEmpty)(tokenizers.head)
  }

  def read[A](implicit read: IO.Read[A]): A = read.apply(this)
  def read[C[_], A: IO.Read](n: Int)(implicit b: C of A): C[A] = Iterator.fill(n)(read).to[C]

  def readTill(delim: String): String = tokenizer().get.nextToken(delim)
  def readTillEndOfLine(): String = readTill("\n\r")

  override def next() = tokenizer().get.nextToken()
  override def hasNext = tokenizer().nonEmpty

  def write(obj: Any): this.type = {
    printer.print(obj)
    this
  }
  def writeLine(): this.type = {
    printer.println()
    this
  }
  def writeLine(obj: Any): this.type = {
    printer.println(obj)
    this
  }
  def writeAll(obj: Traversable[Any], separator: String = " "): this.type = write(obj mkString separator)
  def query[A: IO.Read](question: Any): A = writeLine(question).read

  override def flush() = printer.flush()
  def close() = {
    flush()
    in.close()
    printer.close()
  }
}
object IO {
  class Read[A](val apply: IO => A) {
    def map[B](f: A => B): Read[B] = new Read(apply andThen f)
  }
  object Read {
    implicit def collection[C[_], A: Read](implicit b: C of A): Read[C[A]]         = new Read(r => r.read[C, A](r.read[Int]))
    implicit val string                                       : Read[String]       = new Read(_.next())
    implicit val char                                         : Read[Char]         = string.map(_.toTraversable.onlyElement)
    implicit val int                                          : Read[Int]          = string.map(_.toInt)
    implicit val long                                         : Read[Long]         = string.map(_.toLong)
    implicit val bigInt                                       : Read[BigInt]       = string.map(BigInt(_))
    implicit val double                                       : Read[Double]       = string.map(_.toDouble)
    implicit val bigDecimal                                   : Read[BigDecimal]   = string.map(BigDecimal(_))
    implicit def tuple2[A: Read, B: Read]                     : Read[(A, B)]       = new Read(r => (r.read[A], r.read[B]))
    implicit def tuple3[A: Read, B: Read, C: Read]            : Read[(A, B, C)]    = new Read(r => (r.read[A], r.read[B], r.read[C]))
    implicit def tuple4[A: Read, B: Read, C: Read, D: Read]   : Read[(A, B, C, D)] = new Read(r => (r.read[A], r.read[B], r.read[C], r.read[D]))
    implicit val boolean                                      : Read[Boolean]      = string map {s =>
      s.toLowerCase match {
        case "yes" | "true" | "1" => true
        case "no" | "false" | "0" => false
        case _ => s.toBoolean
      }
    }
  }
}

import scala.io.StdIn.readLine
object UncommonSeq extends App {
  val x = readLine
  val y = readLine
  println(if (x == y) -1 else x.length.max(y.length))
}

object A766 {

  import IO._
  import collection.{mutable => cu}

  def main(args: Array[String]): Unit = {
    val first = read
    val second = read

    if(first.distinct.length == 1 && second.distinct.length == 1) {
      if(first.head == second.head)
        println(-1)
      else
        println(1)
    } else if(first.length == second.length) {
      println(first.length - 1)
    } else {
      println(math.max(first.length, second.length))
    }
  }

  object IO {
    private val input = new java.io.BufferedReader(new java.io.InputStreamReader(System.in))

    //    private val input = new java.io.BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream("src/input")))
    @inline def read: String = input.readLine()

    @inline def tokenizeLine = new java.util.StringTokenizer(read)

    def readInt: Int = tokenizeLine.nextToken.toInt

    def readInts(n: Int): Array[Int] = {
      val tl = tokenizeLine
      Array.fill(n)(tl.nextToken.toInt)
    }

    def readLongs(n: Int): Array[Long] = {
      val tl = tokenizeLine
      Array.fill(n)(tl.nextToken.toLong)
    }

    def readBigs(n: Int): Array[BigInt] = {
      val tl = tokenizeLine
      Array.fill(n)(BigInt(tl.nextToken))
    }
  }

}

object A766 {

  import IO._
  import collection.{mutable => cu}

  def main(args: Array[String]): Unit = {
    val first = read
    val second = read

    if(first.distinct.length == 1 && second.distinct.length == 1) {
      if(first.head == second.head)
        println(-1)
      else
        println(1)
    } else if(first.compareTo(second) == 0) {
      println(first.length - 1)
    } else {
      println(math.max(first.length, second.length))
    }
  }

  object IO {
    private val input = new java.io.BufferedReader(new java.io.InputStreamReader(System.in))

    //    private val input = new java.io.BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream("src/input")))
    @inline def read: String = input.readLine()

    @inline def tokenizeLine = new java.util.StringTokenizer(read)

    def readInt: Int = tokenizeLine.nextToken.toInt

    def readInts(n: Int): Array[Int] = {
      val tl = tokenizeLine
      Array.fill(n)(tl.nextToken.toInt)
    }

    def readLongs(n: Int): Array[Long] = {
      val tl = tokenizeLine
      Array.fill(n)(tl.nextToken.toLong)
    }

    def readBigs(n: Int): Array[BigInt] = {
      val tl = tokenizeLine
      Array.fill(n)(BigInt(tl.nextToken))
    }
  }

}

object A766 {

  import IO._
  import collection.{mutable => cu}

  def main(args: Array[String]): Unit = {
    val first = read
    val second = read

    if(first.distinct.length == 1 && second.distinct.length == 1 && first.head == second.head) {
      println(-1)
    } else if(first.compareTo(second) == 0) {
      println(first.length - 1)
    } else {
      println(math.max(first.length, second.length))
    }
  }

  object IO {
    private val input = new java.io.BufferedReader(new java.io.InputStreamReader(System.in))

    //    private val input = new java.io.BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream("src/input")))
    @inline def read: String = input.readLine()

    @inline def tokenizeLine = new java.util.StringTokenizer(read)

    def readInt: Int = tokenizeLine.nextToken.toInt

    def readInts(n: Int): Array[Int] = {
      val tl = tokenizeLine
      Array.fill(n)(tl.nextToken.toInt)
    }

    def readLongs(n: Int): Array[Long] = {
      val tl = tokenizeLine
      Array.fill(n)(tl.nextToken.toLong)
    }

    def readBigs(n: Int): Array[BigInt] = {
      val tl = tokenizeLine
      Array.fill(n)(BigInt(tl.nextToken))
    }
  }

}


object _1605B extends CodeForcesApp {
  import Utils._, annotation._, collection.{mutable, Searching}, util._, control._, math.Ordering.Implicits._, Searching._, Math._

  override def solve(io: IO) = io.repeat {
    val n = io.read[Int]
    val s = io.read[String].map(c => c - '0').toArray

    @tailrec
    def solve(l: Int, r: Int): Seq[Int] = {
      if (l < r) {
        if (s(r) == 1) solve(l, r-1)
        else if (s(l) == 0) solve(l+1, r)
        else {
          val t = s.slice(l, r+1)
          val ts = t.sorted
          for {
            i <- l to r if t(i - l) != ts(i - l)
          } yield i
        }
      } else {
        Nil
      }
    }

    val ans = solve(0, n-1).map(_ + 1)

    if (ans.isEmpty) {
      io.write(0)
    } else {
      io.writeLine(1).write(ans.length, ans.mkString(" "))
    }
  }

  implicit class IntegralExtensions[A](x: A)(implicit n: Integral[A]) {
    import scala.collection.immutable.NumericRange, Integral.Implicits._
    def -->(y: A): NumericRange.Inclusive[A] = NumericRange.inclusive(x, y, if (n.lteq(x, y)) n.one else -n.one)
  }
}
/****************************[Ignore Template Below]****************************************/
trait CodeForcesApp {
  lazy val isOnlineJudge: Boolean = sys.props.get("ONLINE_JUDGE").exists(_.toBoolean)
  def debug(x: => Any): Unit = if (!isOnlineJudge) println(x)
  def solve(io: IO): Any
  def main(args: Array[String]): Unit = {
    val io = new IO(System.in, System.out)
    try solve(io) finally io.close()
  }
}
/****************************[Scala Collection Utils]****************************************/
object Utils {
  import scala.collection.mutable

  type of[C[_], A] = scala.collection.generic.CanBuild[A, C[A]]

  def when[A](check: Boolean)(f: => A): Option[A] = if (check) Some(f) else None

  def repeat[U](n: Int)(f: => U): Unit = (1 to n).foreach(_ => f)

  val charToInt: Char => Int = Character.getNumericValue
  val intToChar: Int => Char = Character.forDigit(_, 10)

  implicit class GenericExtensions[A](a: A) {
    def partialMatch[B](f: PartialFunction[A, B]): Option[B] = f lift a
  }

  implicit class TraversableExtensions[A, C[X] <: Traversable[X]](t: C[A]) {
    def zipWith[B](f: A => B)(implicit b: C of (A, B)): C[(A, B)] = (t map {i => i -> f(i)}).to[C]

    def whenNonEmpty[B](f: t.type => B): Option[B] = when(t.nonEmpty)(f(t))  // e.g. grades.whenNonEmpty(_.max)

    def toMultiSet(withDefaultZero: Boolean): Map[A, Int] = {
      val freqTable = t.groupBy(identity).mapValues(_.size)
      if (withDefaultZero) freqTable.withDefaultValue(0) else freqTable
    }
  }

  implicit class PairExtensions[A, B](p: (A, B)) {
    def key = p._1
    def value = p._2
    def toSeq(implicit ev: B =:= A): Seq[A] = Seq(p.key, ev(p.value))
  }

  implicit class PairsExtensions[A, B, C[X] <: Traversable[X]](t: C[(A, B)]) {
    def toMultiMap(implicit b: C of B): Map[A, C[B]] = t.groupBy(_.key).mapValues(_.map(_.value).to[C]).withDefaultValue(b().result())
  }

  implicit class MapExtensions[K, V, C[X, Y] <: Map[X, Y]](m: C[K, V]) {
    def toMutable: mutable.Map[K, V] = mutable.Map.empty[K, V] ++ m
  }

  implicit class SetExtensions[A, C[A] <: Set[A]](s: C[A]) {
    def notContains(x: A): Boolean = !(s contains x)
    def toMutable = mutable.Set.empty[A] ++ s
  }

  implicit class IterableExtensions[A, C[A] <: Seq[A]](s: C[A]) {
    def indicesWhere(f: A => Boolean): Seq[Int] = s.zipWithIndex.collect {case (a, i) if f(a) => i}
    def deleteAtIndex(i: Int, howMany: Int = 1) = s.patch(i, Nil, howMany)
    def insertAtIndex(i: Int, items: Seq[A]) = s.patch(i, items, 0)
    def findWithIndex(f: A => Boolean): Option[(A, Int)] = s.zipWithIndex find {case (a, _) => f(a)}
  }

  implicit class BooleanExtensions(x: Boolean) {
    def to[A](implicit n: Numeric[A]) = if(x) n.one else n.zero
    def toEnglish = if(x) "Yes" else "No"
  }

  implicit class IntExtensions(val x: Int) extends AnyVal {
    @inline def isEven = x%2 == 0
    @inline def isOdd = x%2 == 1
  }

  def desc[A](implicit order: Ordering[A]): Ordering[A] = order.reverse  //e.g. students.sortBy(_.height)(desc)

  def map[K] = new {
    def to[V](default: => V): mutable.Map[K, V] = using(_ => default)
    def using[V](f: K => V): mutable.Map[K, V] = new mutable.HashMap[K, V]() {
      override def apply(key: K) = getOrElseUpdate(key, f(key))
    }
  }

  def newMultiMap[K, V] = map[K] to mutable.Set.empty[V]

  def memoize[A, B](f: A => B): A => B = map[A] using f
}
/***********************************[Scala I/O]*********************************************/
import java.io._, java.util.StringTokenizer
import scala.collection.generic.CanBuild

class IO(in: BufferedReader, out: BufferedWriter) extends Iterator[String] with AutoCloseable with Flushable {
  def this(reader: Reader, writer: Writer) = this(new BufferedReader(reader), new BufferedWriter(writer))
  def this(in: InputStream, out: OutputStream) = this(new InputStreamReader(in), new OutputStreamWriter(out))

  private[this] val tokenizers = Iterator.continually(in.readLine()).takeWhile(_ != null).map(new StringTokenizer(_)).buffered
  val printer = new PrintWriter(out, true)

  @inline private[this] def tokenizer() = {
    while(tokenizers.nonEmpty && !tokenizers.head.hasMoreTokens) tokenizers.next()
    tokenizers.headOption
  }

  def read[A](implicit read: IO.Read[A]): A = read.apply(this)
  def read[C[_], A: IO.Read](n: Int)(implicit b: CanBuild[A, C[A]]): C[A] = Iterator.fill(n)(read).to[C]
  def readTill(delim: String): String = tokenizer().get.nextToken(delim)
  def readTillEndOfLine(): String = readTill("\n\r")

  override def next() = tokenizer().get.nextToken()
  override def hasNext = tokenizer().nonEmpty

  def write(obj: Any*): this.type = writeAll(obj)
  def writeLine(obj: Any*): this.type = {if (obj.isEmpty) printer.println() else obj.foreach(printer.println); this}
  def writeAll(obj: Traversable[Any], separator: String = " "): this.type = {printer.print(obj.mkString(separator)); this}
  def query[A: IO.Read](question: Any): A = writeLine(question).read

  def repeat(f: => Unit): Unit = Utils.repeat(read[Int]){f; writeLine()}

  override def flush() = printer.flush()
  def close() = {
    flush()
    in.close()
    printer.close()
  }
}
object IO {
  class Read[A](val apply: IO => A) {
    def map[B](f: A => B): Read[B] = new Read(apply andThen f)
  }
  object Read {
    implicit def collection[C[_], A: Read](implicit b: CanBuild[A, C[A]]) : Read[C[A]]         = new Read(r => r.read[C, A](r.read[Int]))
    implicit val string                                                   : Read[String]       = new Read(_.next())
    implicit val int                                                      : Read[Int]          = string.map(_.toInt)
    implicit val long                                                     : Read[Long]         = string.map(_.toLong)
    implicit val bigInt                                                   : Read[BigInt]       = string.map(BigInt(_))
    implicit val double                                                   : Read[Double]       = string.map(_.toDouble)
    implicit val bigDecimal                                               : Read[BigDecimal]   = string.map(BigDecimal(_))
    implicit def tuple2[A: Read, B: Read]                                 : Read[(A, B)]       = new Read(r => (r.read[A], r.read[B]))
    implicit def tuple3[A: Read, B: Read, C: Read]                        : Read[(A, B, C)]    = new Read(r => (r.read[A], r.read[B], r.read[C]))
    implicit def tuple4[A: Read, B: Read, C: Read, D: Read]               : Read[(A, B, C, D)] = new Read(r => (r.read[A], r.read[B], r.read[C], r.read[D]))
    implicit val boolean                                                  : Read[Boolean]      = string map {s =>
      s.toLowerCase match {
        case "yes" | "true" | "1" => true
        case "no" | "false" | "0" => false
        case _ => s.toBoolean
      }
    }
  }
}

import java.io._
import java.util.StringTokenizer
import scala.+:
import scala.collection.mutable
import scala.collection.mutable._
import scala.collection.immutable._
import scala.util.Sorting.quickSort
import scala.math._

object Main extends App {
    val writer =  new PrintWriter(System.out, false)
    val reader = new BufferedReader(new InputStreamReader(System.in))
    var st = new StringTokenizer("")
    def next(): String = {while (!st.hasMoreTokens) {st = new StringTokenizer(reader.readLine())};st.nextToken()}
    def readInt(): Int = next().toInt
    def readLong(): Long = next().toLong
    def readString(): String = next()

    case class fenwick(n: Int) {
        val tree = new Array[Long](n+1)
        def query(ind: Int): Long = {
            var idx = ind
            var ans = 0L
            while (idx > 0) {
                ans += tree(idx)
                idx -= (idx & -idx)
            }
            return ans
        }
        def update(ind: Int, value: Long): Unit = {
            var idx = ind
            while (idx <= n) {
                tree(idx) += value
                idx += (idx & -idx)
            }
        }
    }

    case class pair(val a: Int, val b:  Int)extends Ordered[pair] {
        override def compare(that: pair): Int = {
            return a.compareTo(that.a)
        }
    }

    def gcd(a: Int, b: Int): Int = b match {
        case 0 => a
        case n => gcd(b, a % b)
    }
    val rem = 1000000007
    val mp = mutable.Map[Char, Int]()

    val t = readInt()
    for (tt <- 1 to t) {
        val n = readInt()
        var s = readString()
        var ans = Vector[Int]()
        var cnt = 0
        for (c <- s) {
            if (c == '0')
                cnt += 1
        }
        for (i <- 1 to s.length) {
            if (i <= cnt && s(i-1) == '1')
                ans :+= i
            if (i > cnt && s(i-1) == '0')
                ans :+= i
        }
        if (ans.nonEmpty) {
            writer.println(1)
            writer.print(ans.length)
            for (idx <- ans)
                writer.print(" " + idx)
            writer.println()
        } else {
            writer.println(0)
        }
    }
    writer.flush()
}


object A extends App {
  import scala.io.StdIn._

  val t = readInt()

  (0 until t).foreach { _ =>
    val n = readInt()
    val s = readLine()

    val k = (s zip s.sorted).count { case (a, b) => a != b }

    println(k)
  }
}

//package global15

object A {

  /** TODO: Check! */
  private val multipleTests: Boolean = true

  def run(testNum: Int): Unit = {
    val n = int()
    val s = string()
    println(s.zip(s.sorted).count { case (a, b) => a != b })
  }

  /** Template. */

  private val onlineJudge = System.getProperty("ONLINE_JUDGE") != null

  def main(args: Array[String]): Unit = {
    val t = if (multipleTests) reader.int() else 1
    (1 to t).foreach(run)
  }

  /** I/O */

  import java.io._
  import java.nio.file._

  private val inputFileName = "input.txt"
  private val reader = if (onlineJudge) FastReader.fromConsole() else FastReader.fromFile(inputFileName)

  private def string(): String = reader.string()
  private def int(): Int = reader.int()
  private def long(): Long = reader.long()
  private def double(): Double = reader.double()

  final case class FastReader(delegate: BufferedReader) extends Iterator[String] with AutoCloseable {
    import java.util.StringTokenizer

    def string(): String = next()
    def line(): String = tokenizer().get.nextToken("\n\r")
    def boolean(): Boolean = next().toBoolean
    def byte(radix: Int = 10): Byte = java.lang.Byte.parseByte(next(), radix)
    def short(radix: Int = 10): Short = java.lang.Short.parseShort(next(), radix)
    def int(radix: Int = 10): Int = java.lang.Integer.parseInt(next(), radix)
    def long(radix: Int = 10): Long = java.lang.Long.parseLong(next(), radix)
    def bigInt(radix: Int = 10): BigInt = BigInt(next(), radix)
    def float(): Float = next().toFloat
    def double(): Double = next().toDouble
    def bigDecimal(): BigDecimal = BigDecimal(next())
    def lineNumber(): Int = linedDelegate.getLineNumber

    @inline def nextLine(): String = {
      current = None // reset the rest of current line
      delegate.readLine()
    }

    override def hasNext: Boolean = tokenizer().nonEmpty
    override def next(): String = tokenizer().getOrElse(throw new RuntimeException("End of input")).nextToken()
    override def close(): Unit = delegate.close()

    private lazy val linedDelegate = new LineNumberReader(delegate)
    private val tokenizers = Iterator.continually(delegate.readLine())
      .takeWhile(_ != null)
      .map(new StringTokenizer(_))
      .filter(_.hasMoreTokens)
    private[this] var current: Option[StringTokenizer] = None

    @inline private def tokenizer(): Option[StringTokenizer] = current.find(_.hasMoreTokens) orElse {
      current = if (tokenizers.hasNext) Some(tokenizers.next()) else None
      current
    }
  }

  object FastReader {
    import scala.io.Codec

    def fromConsole()(implicit codec: Codec): FastReader = fromStream(System.in)
    def fromFile(fileName: String)(implicit codec: Codec): FastReader = FastReader {
      Files.newBufferedReader(Paths.get(fileName), codec.charSet)
    }
    def fromString(string: String): FastReader = FastReader(new BufferedReader(new StringReader(string)))
    def fromStream(inputStream: InputStream)(implicit codec: Codec): FastReader = FastReader {
      new BufferedReader(new InputStreamReader(inputStream, codec.charSet))
    }
  }
}

object A {
  import InOut._
  def main(args: Array[String]): Unit = {

    for (_ <- 1 to nextInt) {
      val n = nextInt
      val s = nextLine
      val ss = s.sorted
      var res = 0
      for (i <- 0 until s.length) {
        if (s(i) != ss(i)) res += 1
      }

      out.println(res)
    }

    out.flush()
  }

  final object InOut {
    val in = new java.io.BufferedReader(new java.io.InputStreamReader(System.in))
    val out = new java.io.PrintWriter(System.out, false)
    private[this] var tokenizer: java.util.StringTokenizer = _
    def nextToken: String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new java.util.StringTokenizer(in.readLine)
      tokenizer.nextToken
    }
    def nextInt = Integer.parseInt(nextToken)
    def nextLong = java.lang.Long.parseLong(nextToken)
    def nextBig = BigInt(nextToken)
    def nextInts(n: Int) = Array.fill(n) { nextInt }
    def nextLongs(n: Int) = Array.fill(n) { nextLong }
    def nextBigs(n: Int) = Array.fill(n) { nextBig }
    def nextLine = in.readLine
  }
}

import scala.io.StdIn._;

object Main extends App {

//  def a(ignored: Int, z: Array[Long]): Long = z.zip(z.slice(1, z.length)).map(l => l._1 * l._2).max
//  for (_ <- 0 until readInt()) println(a(readInt(), readLine().split(" ").map(_.toLong)))
//  def b(l: Long): Long = (l + 1)/10

  def b(i: Int, s: String): Int = s.zip(s.sorted).map(k => if (k._1 == k._2) 0 else 1).sum

  for (_ <- 0 until readInt()) println(b(readInt(), readLine()))
}


import io.StdIn.readLine

object A extends App {
  readLine()
  val cities = readLine().split("\\s+").map(_.toInt).sorted
  val (minDist, count) = cities.zip(cities.tail).map { case (a, b) ⇒ b - a }.foldLeft((Int.MaxValue, 0)) {
    case ((mdist, _), dist) if dist < mdist ⇒ (dist, 1)
    case ((mdist, count), dist) if dist == mdist ⇒ (dist, count + 1)
    case (prev, _) ⇒ prev
  }
  println(s"$minDist $count")
}

object Main extends App {
  scala.io.StdIn.readInt()
  val arr = scala.io.StdIn.readLine().split(" ").map(_.toInt).sorted
  val d = arr.zip(arr.tail).map(t => Math.abs(t._2 - t._1))
  val min = d.min
  println(min + " " + d.count(_ == min))
}

object Main extends App {
  scala.io.StdIn.readInt()
  val arr = scala.io.StdIn.readLine().split(" ").map(_.toInt)
  val d = arr.zip(arr.tail).map(t => Math.abs(t._2 - t._1))
  println(d.min + " " + d.count(_ == d.min))
}


import io.Source
import java.util.StringTokenizer

/**
 * User: eireksten
 * Date: 7/28/12
 * Time: 10:20 AM
 */

object Runner extends App {

  val input = Source.fromInputStream(System.in).bufferedReader()
  var token: StringTokenizer = null

  def TOKEN() = {
    while (token == null || !token.hasMoreTokens)
      token = new StringTokenizer(input.readLine())
    token.nextToken()
  }

  def LONG() = TOKEN().toLong
  def INT() = TOKEN().toInt

  val n = INT()
  val wrappings = for (i <- 1 to n) yield LONG()
  val prizeCosts = for (i <- 1 to 5) yield LONG()

  new Solution().go(wrappings, prizeCosts)

}

class Solution {

  def go(wrappings : IndexedSeq[Long], prizeCosts : IndexedSeq[Long]) = {

    var sum = 0L
    val prizes = new Array[Long](5)
    for(wrap <- wrappings) {
      sum += wrap
      for (i <- prizeCosts.length-1 to 0 by -1) {
        val count = sum / prizeCosts(i);
        prizes(i) += count
        sum -= count * prizeCosts(i);
      }
    }
    println(prizes.mkString(" "))
    println(sum)
  }

}

object Main {
  def main(args: Array[String]) {
    val n = readInt()
    val ls = readLine().split(" ").map(_.toLong)
    val prices = readLine().split(" ").map(_.toLong).zipWithIndex
    var count = Array.fill(5)(0L)
    var sum = 0L
    ls.foreach { e =>
      sum += e
      while(prices.count(_._1 <= sum) != 0) {
        val t = prices.filter(_._1 <= sum).last
        val div = (sum / t._1)
        sum -= div * t._1
        count(t._2) += div
      }
    }
    println(count.mkString(" "))
    println(sum)
  }
}

import BigInt._
object Main {
  def main(args: Array[String]) {
  def readArray = readLine.split(' ').map(x => BigInt(x.toInt))
  val n = readInt
  val a = readArray.toList
  val p = readArray
  var acc:Array[BigInt] = Array(0,0,0,0,0)

  def solve(a: List[BigInt], money: BigInt): BigInt = {
    if (a == List()) {
      println(acc.mkString(" "))
      return money
    }
    var m = money + a.head
    for (i <- 4 to 0 by -1) {
      val k = BigInt((m / p(i)).toInt)
      acc(i) += k
      m -= k * p(i)
    }
    solve(a.tail, m)
  }

  val answer = solve(a, 0)
  println(answer)
  }
}

object Solution extends App {

  val in = scala.io.Source.stdin.getLines()
  val n = in.next()
  val data = in.next().split(' ').map(_.toInt)
  val prices = in.next().split(' ').map(_.toInt)
  val count = Array.ofDim[Long](5)

  val l = data.foldLeft(0l) {
    case(balance, ball) =>
      var left = ball + balance
      (4 to 0 by -1).foreach {
        i => count(i) += left / prices(i)
          left %= prices(i)
      }
      left
  }

  println(count.mkString(" "))
  print(l)

}

import scala.collection.mutable
object Main {
  def main(args: Array[String]) {
  def readArray = readLine.split(' ').map(x => BigInt(x))
  val n = readInt
  val a = readArray.toList
  val p = readArray
  var acc = mutable.ArrayBuffer[BigInt](0,0,0,0,0)

  def solve(a: List[BigInt], money: BigInt): BigInt = {
    if (a == List()) {
      println(acc.mkString(" "))
      return money
    }
    var m = money + a.head
    for (i <- 4 to 0 by -1) {
      val k = BigInt((m / p(i)).toInt)
      acc(i) += k
      m -= k * p(i)
    }
    solve(a.tail, m)
  }

  val answer = solve(a, 0)
  println(answer)
  }
}

object Solution extends App {

  val in = scala.io.Source.stdin.getLines()
  val n = in.next()
  val data = in.next().split(' ').map(_.toInt)
  val prices = in.next().split(' ').map(_.toInt)
  val count = Array.ofDim[Int](5)

  val l = data.foldLeft(0) {
    case(balance, ball) =>
      var left = ball + balance
      (4 to 0 by -1).foreach {
        i => count(i) += left / prices(i)
          left %= prices(i)
      }
      left
  }

  println(count.mkString(" "))
  print(l)

}

object Main {
  def main(args: Array[String]) {
  def readArray = readLine.split(' ').map(x => x.toLong)
  val n = readInt
  val a = readArray.toList
  val p = readArray
  var acc = Array(0,0,0,0,0)

  def solve(a: List[Long], money: Long): Long = {
    if (a == List()) {
      println(acc.mkString(" "))
      return money
    }
    var m = money + a.head
    for (i <- 4 to 0 by -1) {
      val k = m / p(i)
      acc(i) += k.toInt
      m -= k * p(i)
    }
    solve(a.tail, m)
  }

  val answer = solve(a, 0)
  println(answer)
  }
}

object Main {
  def main(args: Array[String]) {
  val n = readInt
  val a = readLine.split(' ').map(x => x.toInt).toList
  val p = readLine.split(' ').map(x => x.toInt).reverse
  var acc = Array(0,0,0,0,0)
  def solve(a: List[Int], money: Int): Int = {
    if (a == List()) {
      println(acc.reverse.mkString(" "))
      return money
    }
    var m = money + a.head
    for (i <- 0 to 4) {
      val k = m / p(i)
      acc(i) += k
      m -= k * p(i)
    }
    solve(a.tail, m)
  }
  val answer = solve(a, 0)
  println(answer)
  }
}

import io.Source
import java.util.StringTokenizer

/**
 * User: eireksten
 * Date: 7/28/12
 * Time: 10:20 AM
 */

object Runner extends App {

  val input = Source.fromInputStream(System.in).bufferedReader()
  var token: StringTokenizer = null

  def TOKEN() = {
    while (token == null || !token.hasMoreTokens)
      token = new StringTokenizer(input.readLine())
    token.nextToken()
  }

  def INT() = TOKEN().toInt

  val n = INT()
  val wrappings = for (i <- 1 to n) yield INT()
  val prizeCosts = for (i <- 1 to 5) yield INT()

  new Solution().go(wrappings, prizeCosts)

}

class Solution {

  def go(wrappings : IndexedSeq[Int], prizeCosts : IndexedSeq[Int]) = {

    var sum = 0
    val prizes = new Array[Int](5)
    for(wrap <- wrappings) {
      sum += wrap
      val prize = findPrize(sum, prizeCosts)
      if (prize >= 0) {
        prizes(prize) += 1
        sum -= prizeCosts(prize);
      }
    }
    println(prizes.mkString(" "))
    println(sum)
  }

  def findPrize(sum: Int, prizeCosts : IndexedSeq[Int]) = {
    var best = -1
    for(i <- 0 until prizeCosts.length) {
      if(sum >= prizeCosts(i) && (best == -1 || prizeCosts(i) > prizeCosts(best)))
        best = i
    }
    best
  }

}


import scala.io.StdIn

object Codeforces1100C {

  def getOuterCircleRadius(n: Int, r: Double): Double = {
    val totalAngle = 2 * math.Pi
    val eachAngle = totalAngle / n
    val cosAngle = math.cos(eachAngle)
    val k = 2 / (1 - cosAngle)

    val a = 1 - k
    val b = 2 * r
    val c = r * r

    val d = b * b - 4 * a * c

    val x1 = (-b + math.sqrt(d)) / (2 * a)
    val x2 = (-b - math.sqrt(d)) / (2 * a)

    math.max(x1, x2)
  }

  def main(args: Array[String]): Unit = {
    val Array(n, r) = StdIn.readLine().trim.split(" ")
    val R = getOuterCircleRadius(n.toInt, r.toDouble)
    println(R)
  }
}

object Main {
  def main(args: Array[String]): Unit = {
    val s = new Main()
    s.solve()
    s.out.flush()
  }
}

class Main {
  import java.io._
  import java.util.StringTokenizer

  import scala.collection.mutable
  import scala.util.Sorting
  import math.{abs, max, min}
  import mutable.{ArrayBuffer, ListBuffer}
  import scala.reflect.ClassTag

  val MOD = 1000000007
  val out = new PrintWriter(System.out)

  def solve(): Unit = {
    val n, r = ni()
    val S = math.sin(Math.PI / n)
    val r2 = r * S / (1 - S)
    out.println(f"$r2%.7f")
  }

  def debug(as: Array[Boolean]): Unit = {
    System.err.println(as.map(x => if(x) "1" else "0").mkString)
  }

  def debug(as: Array[Int]): Unit = {
    System.err.println(as.mkString(" "))
  }

  def debug(as: Array[Long]): Unit = {
    System.err.println(as.mkString(" "))
  }

  def debug(s: String): Unit = {
    System.err.println(s)
  }

  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = _

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  val sc = new InputReader(System.in)
  def ni(): Int = sc.nextInt()
  def nl(): Long = sc.nextLong()
  def nc(): Char = sc.nextChar()
  def ns(): String = sc.next()
  def ns(n: Int): Array[Char] = ns().toCharArray
  def na(n: Int, offset: Int = 0): Array[Int] = map(n)(_ => ni() + offset)
  def na2(n: Int, offset: Int = 0): (Array[Int], Array[Int]) = {
    val A1, A2 = Array.ofDim[Int](n)
    REP(n) { i =>
      A1(i) = ni() + offset
      A2(i) = ni() + offset
    }
    (A1, A2)
  }
  def nm(n: Int, m: Int): Array[Array[Int]] = {
    val A = Array.ofDim[Int](n, m)
    REP(n) { i =>
      REP(m) { j =>
        A(i)(j) = ni()
      }
    }
    A
  }
  def nal(n: Int): Array[Long] = map(n)(_ => nl())
  def nm_c(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))
  def REP(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }
  def REP_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while(i >= offset) { f(i); i -= 1 }
  }

  def map[@specialized A: ClassTag](n: Int, offset: Int = 0)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    REP(n)(i => res(i) = f(i + offset))
    res
  }

  def sumL(as: Array[Int]): Long = {
    var s = 0L
    REP(as.length)(i => s += as(i))
    s
  }

  def cumSum(as: Array[Int]) = {
    val cum = Array.ofDim[Long](as.length + 1)
    REP(as.length) { i =>
      cum(i + 1) = cum(i) + as(i)
    }
    cum
  }
}


object Main extends App {
  val MOD: Int = 998244353
  val n: Int = scala.io.StdIn.readInt()
  def solve: Long = {
    def calc(k: Int = n, pr: Long = 1, acc: Long = 0): Long = {
      if (k == 1) (acc + n * pr) % MOD
      else {
        val npr = (pr * k) % MOD
        calc(k - 1, npr, (acc - npr + MOD) % MOD)
      }
    }
    calc()
  }
  println(solve)
}

object D extends App {

  @inline def tokenizeLine = new java.util.StringTokenizer(scala.io.StdIn.readLine)
  def readInts(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt) }
  def readLongs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong) }
  def readBigs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken)) }

  val Array(n) = readInts(1)
  val MOD = 998244353L

  var prev = 1L
  var fac = 1L
  for (i <- 1 to n) {
    fac = (fac * i) % MOD
    prev = (fac + (MOD + prev - 1L) * i) % MOD
  }

  println(prev)
}

import java.io.BufferedReader
import java.io.InputStreamReader
import java.util.StringTokenizer
import scala.annotation.tailrec

object Main extends App {
  val MOD: Int = 998244353
  val st = new StringTokenizer(new BufferedReader(new InputStreamReader(System.in)).readLine())
  val n: Int = Integer.parseInt(st.nextToken())
  def solve: Long = {
    @tailrec
    def calc(k: Int = n, pr: Long = 1, acc: Long = 0): Long = {
      if (k == 1) (acc + n * pr) % MOD
      else {
        val npr = (pr * k) % MOD
        calc(k - 1, npr, (acc - npr + MOD) % MOD)
      }
    }
    calc()
  }
  System.out.print(solve)
}

import scala.annotation.tailrec

object Main extends App {
  val MOD: Int = 998244353
  val n: Int = scala.io.StdIn.readInt()
  def solve: Long = {
    @tailrec
    def calc(k: Int = n, pr: Long = 1, acc: Long = 0): Long = {
      if (k == 1) (acc + n * pr) % MOD
      else {
        val npr = (pr * k) % MOD
        calc(k - 1, npr, (acc - npr + MOD) % MOD)
      }
    }
    calc()
  }
  println(solve)
}


import scala.collection._

object C extends App {

  @inline def tokenizeLine = new java.util.StringTokenizer(readLine)
  def readInts(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt) }
  def readLongs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong) }
  def readBigs(n: Int) = { val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken)) }

  val Array(n, m) = readInts(2)
  val ds, hs = Array.ofDim[Int](m)

  for (i <- 0 until m) {
    val Array(d, h) = readInts(2)
    ds(i) = d
    hs(i) = h
  }

  var maxH = (hs.head + ds.head - 1) max (hs.last + (n - ds.last))

  for (i <- 1 until m) {
    val dd = ds(i) - ds(i - 1)
    val dh = hs(i) - hs(i - 1)
    if (dd < math.abs(dh)) {
      println("IMPOSSIBLE")
      System.exit(0)
    }
    val ch = (hs(i) max hs(i - 1)) + (dd - math.abs(dh)) / 2
    if (ch > maxH) maxH = ch
  }

  println(maxH)
}

import java.io._
import java.util
import java.util._

import scala.collection.mutable

object C {

  var out: PrintWriter = null
  var br: BufferedReader = null
  var st: StringTokenizer = null

  def main(args: Array[String]): Unit = {
    br = new BufferedReader(new InputStreamReader(System.in))
    out = new PrintWriter(new BufferedOutputStream(System.out))
    solve
    out.close
  }

  def next: String = {
    while (st == null || !st.hasMoreTokens) {
      st = new StringTokenizer(br.readLine)
    }
    return st.nextToken
  }

  def nextInt: Int = return Integer.parseInt(next)

  def nextLong: Long = return java.lang.Long.parseLong(next)

  def nextDouble: Double = return java.lang.Double.parseDouble(next)

  class MultiHashSet[T <% Comparable[T]] {
    val map = new mutable.HashMap[T, Int]()

    def count(x: T): Int = {
      return map.getOrElse(x, 0)
    }

    def add(x: T): Unit = map.put(x, count(x) + 1)

    def remove(x: T): Boolean = {
      val prev = count(x)
      if (prev == 0)
        return false
      if (prev == 1) {
        map.remove(x)
      } else {
        map.put(x, prev - 1)
      }
      return true
    }
  }

  class MultiTreeSet[T <% Comparable[T]] {
    val map = new TreeMap[T, Int]()

    def count(x: T): Int = {
      val res = map.get(x)
      if (res == null)
        return 0
      return res
    }

    def add(x: T): Unit = map.put(x, count(x) + 1)

    def first(): T = return map.firstKey()

    def last(): T = return map.lastKey()

    def remove(x: T): Boolean = {
      val prev = count(x)
      if (prev == 0)
        return false
      if (prev == 1) {
        map.remove(x)
      } else {
        map.put(x, prev - 1)
      }
      return true
    }
  }

  def solve: Int = {
    val n = nextInt
    val m = nextInt
    val records = new Array[(Int, Int)](m)
    for (i <- 0 until m ){
      records(i) = (nextInt, nextInt)
    }
    var max = records(0)._2 + records(0)._1 - 1
    for (i <- 1 until m) {
      val diff = records(i)._1 - records(i - 1)._1
      val hDiff = records(i)._2 - records(i - 1)._2
      max = Math.max(records(i)._2, max)
      if (Math.abs(hDiff) > diff) {
        out.println("IMPOSSIBLE")
        return 1
      }
      val x = (diff - hDiff) / 2
      max = Math.max(records(i)._2 + x, max)
    }
    max = Math.max(records(m - 1)._2 + n - records(m - 1)._1, max)
    out.println(max)
    return 0
  }
}

/**
 * Created by slie742 on 9/09/2015.
 */

import scala.io.StdIn.readLine
import scala.io.StdIn.readInt

import Math.abs
import Math.max
import Math.min

object TouristNotes {

  def readInts() : Array[Int] =
    readLine.split(' ').map(_.toInt)

  def readLongs() : Array[Long] =
    readLine.split(' ').map(_.toLong)

  def readTuple() : (Int,Int) = {
    val line = readInts
    (line(0),line(1))
  }
  def readTupleLong() : (Long,Long) = {
    val line = readLongs
    (line(0),line(1))
  }

  def readTriple() : (Int,Int,Int) = {
    val line = readInts
    (line(0),line(1),line(2))
  }
  def readQuad() : (Int,Int,Int,Int) = {
    val line = readInts
    (line(0),line(1),line(2),line(3))
  }

  def solve(notes: List[(Int,Int)]) : Option[Int] = {
    def go(prev: (Int,Int), remNotes: List[(Int,Int)],maxHeight: Int) : Option[Int] = remNotes match {
      case Nil => Some(maxHeight)
      case (d,h) :: rest if abs(h-prev._2) > d - prev._1 =>
        None
      case (d,h) :: rest =>
        //println(s"current = ($d,$h), maxHeight=$maxHeight, between=${(abs(h-prev._2)+ (d - prev._1))/2}")
        val newMax = max(maxHeight, min(h,prev._2) + (abs(h-prev._2)+ (d - prev._1))/2)
        go ( (d,h), rest, newMax)
    }
    go(notes.head, notes.tail, notes.head._2+notes.head._1 - 1)
  }

  def main(args: Array[String]) {
    val (n,m) = readTuple()
    val notes = for {
      i <- 1 to m
      (d,h) = readTuple()
    } yield (d,h)
    solve(notes.toList) match {
      case None => println("IMPOSSIBLE")
      case Some(h) => println(max(h, notes.last._2 + (n-notes.last._1) ))
    }
  }

}

/**
 * Created by slie742 on 9/09/2015.
 */

import scala.io.StdIn.readLine
import scala.io.StdIn.readInt

import Math.abs
import Math.max

object TouristNotes {

  def readInts() : Array[Int] =
    readLine.split(' ').map(_.toInt)

  def readLongs() : Array[Long] =
    readLine.split(' ').map(_.toLong)

  def readTuple() : (Int,Int) = {
    val line = readInts
    (line(0),line(1))
  }
  def readTupleLong() : (Long,Long) = {
    val line = readLongs
    (line(0),line(1))
  }

  def readTriple() : (Int,Int,Int) = {
    val line = readInts
    (line(0),line(1),line(2))
  }
  def readQuad() : (Int,Int,Int,Int) = {
    val line = readInts
    (line(0),line(1),line(2),line(3))
  }

  def solve(notes: List[(Int,Int)]) : Option[Int] = {
    def go(prev: (Int,Int), remNotes: List[(Int,Int)],maxHeight: Int) : Option[Int] = remNotes match {
      case Nil => Some(maxHeight)
      case (d,h) :: rest if abs(h-prev._2) > d - prev._1 =>
        None
      case (d,h) :: rest =>
        val newMax = max(maxHeight, (abs(h-prev._2)+ (d - prev._1))/2)
        go ( (d,h), rest, newMax)
    }
    go(notes.head, notes.tail, notes.head._2+notes.head._1 - 1)
  }

  def main(args: Array[String]) {
    val (n,m) = readTuple()
    val notes = for {
      i <- 1 to m
      (d,h) = readTuple()
    } yield (d,h)
    solve(notes.toList) match {
      case None => println("IMPOSSIBLE")
      case Some(h) => println(max(h, notes.last._2 + (n-notes.last._1) ))
    }
  }

}


import java.io._
import java.util.StringTokenizer
import scala.collection.mutable
import scala.collection.mutable._
import scala.collection.immutable._
import scala.util.Sorting.quickSort
import scala.math._

object sample extends App {
    val writer =  new PrintWriter(System.out, false)
    val reader = new BufferedReader(new InputStreamReader(System.in))
    var st = new StringTokenizer("")
    def next(): String = {while (!st.hasMoreTokens) {st = new StringTokenizer(reader.readLine())};st.nextToken()}
    def readInt(): Int = next().toInt
    def readLong(): Long = next().toLong
    def readString(): String = next()

    case class myType(var social: Int, var cp:  Int, var ind: Int)extends Ordered[myType] {
        override def compare(that: myType): Int = {
            if (social < that.social)
                return -1
            else if (social == that.social)
                return 0
            else
                return 1
        }
    }
    val rem = 1000000007

    val t = readInt()
    for (tt <- 1 to t) {
        val n = readLong()
        var k = readInt()
        var sum = 0L
        var pow = 1L
        while (k > 0) {
            if (k % 2 == 1) {
                sum += pow
                sum %= rem
            }
            pow *= n
            pow %= rem
            k /= 2
        }
        writer.println(sum)
    }
    writer.flush()
}

object B extends App {

  lazy val Mod = (1e9 + 7).toLong

  def kthSpecialNumber(n: Int, k: Int): Long =
    (0 to 31)
      .foldLeft((0L, 1L)) {
        case ((result, power), i) if (1 & (k >> i)) == 1 => ((result + power) % Mod, (n * power) % Mod)
        case ((result, power), _)                        => (result, (n * power) % Mod)
      }
      ._1

  import InOut._

  val t = nextInt()

  (0 until t).foreach { _ =>
    val n = nextInt()
    val k = nextInt()

    out.println(kthSpecialNumber(n, k))
  }

  out.flush()

  final object InOut {
    val in  = new java.io.BufferedReader(new java.io.InputStreamReader(System.in))
    val out = new java.io.PrintWriter(System.out, false)

    def nextInt()        = Integer.parseInt(nextToken())
    def nextInts(n: Int) = Array.fill(n)(nextInt())

    def nextLong()        = java.lang.Long.parseLong(nextToken())
    def nextLongs(n: Int) = Array.fill(n)(nextLong())

    def nextBig()        = BigInt(nextToken())
    def nextBigs(n: Int) = Array.fill(n)(nextBig())

    def nextLine() = in.readLine()

    private[this] var tokenizer: java.util.StringTokenizer = _

    def nextToken(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens())
        tokenizer = new java.util.StringTokenizer(in.readLine())
      tokenizer.nextToken()
    }
  }

}

object B extends App {

  lazy val Mod = (1e9 + 7).toLong

  def log2(n: Int): Int = 31 - Integer.numberOfLeadingZeros(n)

  def specialNumbers(n: Int, k: Int): Long = {

    val powers: Array[Long] = {
      val size = log2(k) + 1
      val data = Array.fill(size)(1L)
      (1 until size).foreach { i => data(i) = (n * data(i - 1)) % Mod }
      data
    }

    @annotation.tailrec
    def go(k: Int, result: Long): Long = k match {
      case 0 => result
      case k =>
        val l = log2(k)
        val i = k - (1 << l)

        go(i, (result + powers(l)) % Mod)
    }

    go(k, 0L)
  }

  import InOut._

  val t = nextInt()

  (0 until t).foreach { _ =>
    val n = nextInt()
    val k = nextInt()

    out.println(specialNumbers(n, k))
  }

  out.flush()

  final object InOut {
    val in  = new java.io.BufferedReader(new java.io.InputStreamReader(System.in))
    val out = new java.io.PrintWriter(System.out, false)

    def nextInt()        = Integer.parseInt(nextToken())
    def nextInts(n: Int) = Array.fill(n)(nextInt())

    def nextLong()        = java.lang.Long.parseLong(nextToken())
    def nextLongs(n: Int) = Array.fill(n)(nextLong())

    def nextBig()        = BigInt(nextToken())
    def nextBigs(n: Int) = Array.fill(n)(nextBig())

    def nextLine() = in.readLine()

    private[this] var tokenizer: java.util.StringTokenizer = _

    def nextToken(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens())
        tokenizer = new java.util.StringTokenizer(in.readLine())
      tokenizer.nextToken()
    }
  }

}


import java.util._
import java.lang._
import java.io._

object B {

  var out: PrintWriter = null
  var br: BufferedReader = null
  var st: StringTokenizer = null

  def next: String = {
    while (st == null || !st.hasMoreTokens) {
      st = new StringTokenizer(br.readLine)
    }
    return st.nextToken
  }

  def nextInt: Int = {
    return Integer.parseInt(next)
  }

  def nextLong: Long = {
    return Long.parseLong(next)
  }

  def solve = {
    val n = nextInt
    val k = nextInt
    val cinema = new Array[Array[Int]](k)
    val xc = Math.ceil(k / 2).toInt
    for (i <- 0 until k) {
      cinema(i) = new Array[Int](k)
    }
    for (i <- 0 until k) {
      for (j <- 0 until k) {
        cinema(i)(j) = func(xc, i, j)
      }
    }
    for (t <- 0 until n) {
      val m = nextInt
      var sum = Int.MaxValue
      var start = 0
      var row = 0
      for (i <- 0 until k) {
        var interSum = 0
        for (j <- 0 until m) {
          interSum += cinema(i)(j)
        }
        if (interSum < sum) {
          sum = interSum
          row = i
          start = 0
        }
        for (j <- m until k) {
          interSum += cinema(i)(j)
          interSum -= cinema(i)(j - m)
          if (interSum < sum) {
            sum = interSum
            row = i
            start = j - m + 1
          }
        }
      }
      if (sum < 100000) {
//        out.println(sum)
        out.println((row + 1) + " " + (start + 1) + " " + (start + m))
        for (j <- start until start + m) {
          cinema(row)(j) = 100000
        }
      } else {
        out.println(-1)
      }
//      for (i <- 0 until k) {
//        for (j <- 0 until k) {
//          out.print(cinema(i)(j) + " ")
//        }
//        out.println
//      }
    }
  }

  def func(xc: Int, x: Int, y: Int) = {
    Math.abs(x - xc) + Math.abs(y - xc)
  }

  def main(args: Array[String]): Unit = {
    br = new BufferedReader(new InputStreamReader(System.in))
    out = new PrintWriter(new BufferedOutputStream(System.out))
    solve
    out.close
  }
}

//package me.jetblack.cf

import java.util.Scanner

object Cashier extends App {

  val s = new Scanner(System.in)

  val n = s.nextInt()
  val k = s.nextInt()
  val hall = Array.ofDim[Boolean](k + 1, k + 1)
  val trace = Array.fill[String](n)("-1")
  val q = (0 until n).map(_ => s.nextInt()).toArray
  val c = (k / 2) + 1
  var cur = 0

  while (cur < n) {
    var best = Integer.MAX_VALUE
    var bestCoord = (0, 0)
    var x = 1
    while (x < k + 1) {
      var y = 1
      while (y < k - q(cur) + 2) {
        var fits = true
        var cnt = y
        var score = 0
        while (fits && cnt < y + q(cur)) {
          if (hall(x)(cnt)) fits = false
          score += math.abs(x - c) + math.abs(cnt - c)
          cnt += 1
        }
        if (fits && score < best) {
          best = score
          bestCoord = (x, y)
        }
        y += 1
      }
      x += 1
    }
    if (best != Integer.MAX_VALUE) {
      trace(cur) = s"${bestCoord._1} ${bestCoord._2} ${bestCoord._2 + q(cur) - 1} "
      var cnt = bestCoord._2
      while (cnt < bestCoord._2 + q(cur)) {
        hall(bestCoord._1)(cnt) = true
        cnt += 1
      }
    }
    cur += 1
  }

  print(trace.mkString("\n"))

}

import java.util._
import java.lang._
import java.io._

object B {

  var out: PrintWriter = null
  var br: BufferedReader = null
  var st: StringTokenizer = null

  def next: String = {
    while (st == null || !st.hasMoreTokens) {
      st = new StringTokenizer(br.readLine)
    }
    return st.nextToken
  }

  def nextInt: Int = {
    return Integer.parseInt(next)
  }

  def nextLong: Long = {
    return Long.parseLong(next)
  }

  def solve = {
    val n = nextInt
    val k = nextInt
    val cinema = new Array[Array[Int]](k)
    val xc = Math.ceil(k / 2).toInt
    for (i <- 0 until k) {
      cinema(i) = new Array[Int](k)
    }
    for (i <- 0 until k) {
      for (j <- 0 until k) {
        cinema(i)(j) = func(xc, i, j)
      }
    }
    for (t <- 0 until n) {
      val m = nextInt
      var sum = Int.MaxValue
      var start = 0
      var row = 0
      for (i <- 0 until k) {
        var interSum = 0
        for (j <- 0 until m) {
          interSum += cinema(i)(j)
        }
        if (interSum < sum) {
          sum = interSum
          row = i
          start = 0
        }
        for (j <- m until k) {
          if (interSum < sum) {
            sum = interSum
            row = i
            start = j - m
          }
          interSum += cinema(i)(j)
          interSum -= cinema(i)(j - m)
        }
      }
      if (sum < 100000) {
//        out.println(sum)
        out.println((row + 1) + " " + (start + 1) + " " + (start + m))
        for (j <- start until start + m) {
          cinema(row)(j) = 100000
        }
      } else {
        out.println(-1)
      }
//      for (i <- 0 until k) {
//        for (j <- 0 until k) {
//          out.print(cinema(i)(j) + " ")
//        }
//        out.println
//      }
    }
  }

  def func(xc: Int, x: Int, y: Int) = {
    Math.abs(x - xc) + Math.abs(y - xc)
  }

  def main(args: Array[String]): Unit = {
    br = new BufferedReader(new InputStreamReader(System.in))
    out = new PrintWriter(new BufferedOutputStream(System.out))
    solve
    out.close
  }
}


object _975A extends CodeForcesApp {
  import annotation._, collection.{mutable, Searching}, util._, control._, math.Ordering.Implicits._, Searching._, Math._

  override def apply(io: IO): io.type = {
    val words = io.read[Set[String]]
    val ans = words.map(_.distinct.sorted).size
    io.write(ans)
  }
}
/****************************[Ignore Template Below]****************************************/
trait CodeForcesApp {
  lazy val isOnlineJudge: Boolean = sys.props.get("ONLINE_JUDGE").exists(_.toBoolean)
  def debug(x: => Any): Unit = if (!isOnlineJudge) println(x)
  def apply(io: IO): io.type
  def main(args: Array[String]): Unit = this(new IO(System.in, System.out)).close()
}
/***********************************[Scala I/O]*********************************************/
import java.io._, java.util.StringTokenizer
import scala.collection.generic.CanBuild

class IO(in: BufferedReader, out: BufferedWriter) extends Iterator[String] with AutoCloseable with Flushable {
  def this(reader: Reader, writer: Writer) = this(new BufferedReader(reader), new BufferedWriter(writer))
  def this(in: InputStream, out: OutputStream) = this(new InputStreamReader(in), new OutputStreamWriter(out))

  private[this] val tokenizers = Iterator.continually(in.readLine()).takeWhile(_ != null).map(new StringTokenizer(_)).buffered
  val printer = new PrintWriter(out, true)

  @inline private[this] def tokenizer() = {
    while(tokenizers.nonEmpty && !tokenizers.head.hasMoreTokens) tokenizers.next()
    tokenizers.headOption
  }

  def read[A](implicit read: IO.Read[A]): A = read.apply(this)
  def read[C[_], A: IO.Read](n: Int)(implicit b: CanBuild[A, C[A]]): C[A] = Iterator.fill(n)(read).to[C]

  def readTill(delim: String): String = tokenizer().get.nextToken(delim)
  def readTillEndOfLine(): String = readTill("\n\r")

  def readAll[A: IO.Read]: (Int, Vector[A]) = {
    val data = read[Vector[A]]
    (data.length, data)
  }

  override def next() = tokenizer().get.nextToken()
  override def hasNext = tokenizer().nonEmpty

  def write(obj: Any): this.type = {
    printer.print(obj)
    this
  }
  def writeLine(): this.type = {
    printer.println()
    this
  }
  def writeLine(obj: Any): this.type = {
    printer.println(obj)
    this
  }
  def writeAll(obj: Traversable[Any], separator: String = " "): this.type = write(obj mkString separator)
  def query[A: IO.Read](question: Any): A = writeLine(question).read

  override def flush() = printer.flush()
  def close() = {
    flush()
    in.close()
    printer.close()
  }
}
object IO {
  class Read[A](val apply: IO => A) {
    def map[B](f: A => B): Read[B] = new Read(apply andThen f)
  }

  object Read {
    implicit def collection[C[_], A: Read](implicit b: CanBuild[A, C[A]]) : Read[C[A]]         = new Read(r => r.read[C, A](r.read[Int]))
    implicit val string                                                   : Read[String]       = new Read(_.next())
    implicit val int                                                      : Read[Int]          = string.map(_.toInt)
    implicit val long                                                     : Read[Long]         = string.map(_.toLong)
    implicit val bigInt                                                   : Read[BigInt]       = string.map(BigInt(_))
    implicit val double                                                   : Read[Double]       = string.map(_.toDouble)
    implicit val bigDecimal                                               : Read[BigDecimal]   = string.map(BigDecimal(_))
    implicit def tuple2[A: Read, B: Read]                                 : Read[(A, B)]       = new Read(r => (r.read[A], r.read[B]))
    implicit def tuple3[A: Read, B: Read, C: Read]                        : Read[(A, B, C)]    = new Read(r => (r.read[A], r.read[B], r.read[C]))
    implicit def tuple4[A: Read, B: Read, C: Read, D: Read]               : Read[(A, B, C, D)] = new Read(r => (r.read[A], r.read[B], r.read[C], r.read[D]))
    implicit val boolean                                                  : Read[Boolean]      = string map {s =>
      s.toLowerCase match {
        case "yes" | "true" | "1" => true
        case "no" | "false" | "0" => false
        case _ => s.toBoolean
      }
    }
  }
}

import scala.annotation.tailrec

object Prg1 extends App {

  @tailrec
  def wordsAramic(s: List[String], presentStr:List[String]=List[String](), count:Int = 0):Int = {
    if (s.length == 0) count
    else {
      val uniqueString = s.head.sorted.distinct
      if (presentStr.contains(uniqueString))
        wordsAramic(s.tail, presentStr, count)
      else wordsAramic(s.tail, presentStr :+ uniqueString, count + 1)
    }
  }

  val t = scala.io.StdIn.readLine.toInt
  val listOfStr = scala.io.StdIn.readLine.split(" ").toList
  println(wordsAramic(listOfStr))
}

object CF975A extends App {
  import scala.io.Source
  //val src = Source.fromFile("data.txt")
  val src = Source.stdin
  val lines = src.getLines

  def readString(): String =  {
    val line = if (lines.hasNext) lines.next else null
    if (line == null) throw new RuntimeException("Premature end of source encountered")
    line
  }

  def readStrings(): Array[String] = readString().split(" ")

  readString()
  val nObj = readStrings().map(x => x.toSet).toSet.size
  println(nObj)
}


object A706 {
  @inline def read = scala.io.StdIn.readLine

  @inline def tokenizeLine = new java.util.StringTokenizer(read)

  def readInts(n: Int) = {
    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt)
  }

  def readLongs(n: Int) = {
    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong)
  }

  def readBigs(n: Int) = {
    val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken))
  }

  def main(args: Array[String]): Unit = {
    val Array(a, b) = readInts(2)
    val Array(n) = readInts(1)
    println(Array.fill(n)(readInts(3)).map{ arr =>
      math.sqrt(math.pow(a-arr(0), 2) + math.pow(b-arr(1), 2)) / arr(2).toDouble
    }.min)
  }
}

import io.StdIn._
object Euclid extends App {

  val l1 = readLine().split(" ").map(_.toInt)
  val (a:Int, b:Int) = (l1(0), l1(1))

  val cars = readLine().toInt
  var i = 0
  var result:Option[Double] = None
  while(i<cars){
    val t = readLine().split(' ').map(_.toInt)
    val (x:Int,y:Int,v:Int) = (t(0),t(1),t(2))
    val s:Double = math.sqrt( math.pow(a-x, 2) + math.pow(b-y,2) )
//    println("s: is " + s)
    result = if (result.isEmpty || (s/v < result.get)) Some(s/v) else result
//    println("result: " + result)
    i +=1
  }
  println(result.get)
}

object Solution extends App {
  val lines = io.Source.stdin.getLines()
  val Array(a, b) = lines.next().split(' ').map(_.toInt)
  val n = lines.next().toInt
  val result = lines.take(n).map(_.split(' ').map(_.toInt)).map{case Array(a1, b1, v) => Math.sqrt((a1 - a) * (a1 - a) + (b1 - b) * (b1 - b)) / v}.min
  println(result)
}

import scala.io.StdIn._

object Main {
    def main(args: Array[String]): Unit = {
        var line = readLine().split(" ")
        val x = line(0).toDouble
        val y = line(1).toDouble

        val n = readInt()

        var minTime: Double = -1
        (1 to n).foreach(i => {
            line = readLine().split(" ")
            val ix = line(0).toDouble
            val iy = line(1).toDouble
            val iz = line(2).toDouble

            val time = Math.hypot(ix-x, iy-y) / iz
            if(minTime == -1){
                minTime = time
            }
            minTime = minTime.min(time)
        })

        println(f"$minTime%1.10f")
    }
}

import Utils._, annotation.tailrec, collection.mutable, util._, control._, math.Ordering.Implicits._

object _706A extends CodeForcesApp {
  override def apply(io: IO) = {import io.{read, write}
    val a, b = read[Int]
    var ans = Double.MaxValue
    repeat(read[Int]) {
      val x, y, v = read[Double]
      val dist = Math.hypot(a - x, b - y)
      ans = ans min (dist/v)
    }

    write(ans)
  }
}
/****************************[Ignore Template Below]****************************************/
trait CodeForcesApp {
  lazy val isOnlineJudge: Boolean = sys.props.get("ONLINE_JUDGE").exists(_.toBoolean)
  def debug(x: => Any): Unit = if (!isOnlineJudge) println(x)
  def apply(io: IO): io.type
  def main(args: Array[String]): Unit = this(new IO(System.in, System.out)).close()
}
object Utils {
  import scala.collection.mutable, mutable.{Map => Dict}
  implicit class GenericExtensions[A](val a: A) extends AnyVal {
    def in(set: collection.Set[A]): Boolean = set(a)
    def some: Option[A] = Some(a)
    def partialMatch[B](f: PartialFunction[A, B]): Option[B] = f lift a
  }
  implicit class TraversableExtensions[A, C[X] <: Traversable[X]](val t: C[A]) extends AnyVal {
    def onlyElement: A = assuming(t.size == 1)(t.head)
    def groupByIdentifier[K](f: A => K): Map[K, A] = t.groupBy(f).mapValues(_.onlyElement)
    def duplicates(implicit b: C of A): C[A] = {
      val elems = mutable.Set.empty[A]
      (t collect {case i if !elems.add(i) => i}).to[C]
    }
    def sumWith[B](f: A => B)(implicit n: Numeric[B]): B = t.foldLeft(n.zero) {case (p, i) => n.plus(p, f(i))}
    def zipWith[B](f: A => B)(implicit b: C of (A, B)): C[(A, B)] = (t map {i => i -> f(i)}).to[C]
    def mapTo[B](f: A => B)(implicit b: C of (A, B)): Map[A, B] = zipWith(f).toUniqueMap
    def whenNonEmpty[B](f: t.type => B): Option[B] = when(t.nonEmpty)(f(t))  // e.g. grades.whenNonEmpty(_.max)
    def collectFirst[B](f: PartialFunction[A, Option[B]]): Option[B] = t.view collect f collectFirst {case Some(x) => x}
    def toMutableMultiSet: Dict[A, Int] = {
      val c = map[A] to 0
      t.foreach(i => c(i) += 1)
      c
    }
    def toMultiSet: Map[A, Int] = toMutableMultiSet.toMap withDefaultValue 0
    def X[B](s: Traversable[B]): Iterator[(A, B)] = for {a <- t.toIterator; b <- s} yield (a, b)
  }
  implicit class ArrayExtensions[A <: AnyRef](val a: Array[A]) extends AnyVal {
    def sort(from: Int, until: Int)(implicit cmp: Ordering[A]): Unit = java.util.Arrays.sort(a, from, until, cmp) //sort [from, until)
  }
  implicit class ArrayExtensions2[A](val a: Array[A]) extends AnyVal {
    def sort(from: Int, until: Int)(implicit cmp: Ordering[A]): Unit = a.view(from, until).sorted.copyToArray(a, from)
  }
  implicit class SeqExtensions[A, C[X] <: Seq[X]](val s: C[A]) extends AnyVal {
    def isRotationOf(t: Seq[A]): Boolean = s ++ s containsSlice t
  }
  implicit class PairExtensions[A, B](val p: (A, B)) extends AnyVal {
    def key = p._1
    def value = p._2
  }
  implicit class PairsExtensions[A, B, C[X] <: Traversable[X]](t: C[(A, B)]) {
    def toUniqueMap: Map[A, B] = t.groupByIdentifier(_.key).mapValues(_.value)
    def toMultiMap(implicit b: C of B): Map[A, C[B]] = t.groupBy(_.key).mapValues(_.map(_.value).to[C])
    def swap(implicit b: C of (B, A)): C[(B, A)] = t.map(_.swap).to[C]
  }
  implicit class MapExtensions[K, V, C[X, Y] <: Map[X, Y]](val m: C[K, V]) extends AnyVal {
    def lastKeyOption: Option[K] = m.lastOption.map(_.key)
    def firstKeyOption: Option[K] = m.headOption.map(_.key)
    def invert: Map[V, Set[K]] = m.toSet[(K, V)].swap.toMultiMap
    def mapKeys[K2](f: K => K2): Map[K2, V] = m map {case (k, v) => f(k) -> v}
    def toMutable: Dict[K, V] = Dict.empty[K, V] ++ m
  }
  implicit class MutableMapExtensions[K, V](val m: mutable.Map[K, V]) extends AnyVal {
    def removeLast(): Option[(K, V)] = m.lastOption.map(removeNode)
    def removeFirst(): Option[(K, V)] = m.headOption.map(removeNode)
    private def removeNode(kv: (K, V)): (K, V) = {
      m -= kv.key
      kv
    }
  }
  implicit class SetExtensions[A, C[A] <: Set[A]](val s: C[A]) extends AnyVal {
    def notContains(x: A): Boolean = !(s contains x)
    def toMutable = mutable.Set.empty[A] ++ s
  }
  implicit class IterableExtensions[A, C[A] <: Seq[A]](val s: C[A]) extends AnyVal {
    def deleteAtIndex(i: Int, howMany: Int = 1) = s.patch(i, Nil, howMany)
    def insertAtIndex(i: Int, items: Seq[A]) = s.patch(i, items, 0)
    def findWithIndex(f: A => Boolean): Option[(A, Int)] = s.zipWithIndex find {case (a, _) => f(a)}
    def foldUntil[B](z: B)(f: (B, A) => B)(c: B => Boolean): Option[(B, Int)] = s.view.scanLeft(z)(f).findWithIndex(c)
  }
  implicit class BooleanExtensions(val x: Boolean) extends AnyVal {
    def to[A](implicit n: Numeric[A]) = if(x) n.one else n.zero
    def toEnglish = if(x) "YES" else "NO"
  }
  implicit class IntExtensions(val x: Int) extends AnyVal {
    import java.lang.{Integer => JInt}
    def withHighestOneBit: Int = JInt.highestOneBit(x)
    def withLowestOneBit: Int = JInt.lowestOneBit(x)
    def numberOfLeadingZeroes: Int = JInt.numberOfLeadingZeros(x)
    def numberOfTrailingZeroes: Int = JInt.numberOfTrailingZeros(x)
    def bitCount: Int = JInt.bitCount(x)
    def setLowestBits(n: Int): Int = x | (left(n) - 1)
    def clearLowestBits(n: Int): Int = x & left(n, ~0)
    def setBit(i: Int, set: Boolean): Int = if (set) setBit(i) else clearBit(i)
    def setBit(i: Int): Int = x | left(i)
    def clearBit(i: Int): Int = x & ~left(i)
    def toggleBit(i: Int): Int = x ^ left(i)
    def testBit(i: Int): Boolean = ((x >> i) & 1) == 1
    private def left(bits: Int, num: Int = 1) = assuming(bits >= 0 && bits < JInt.SIZE)(num << bits)
    def X(y: Int): Iterator[(Int, Int)] = until(x) X until(y)
  }
  implicit class LongExtensions(val x: Long) extends AnyVal {
    import java.lang.{Long => JLong}
    def withHighestOneBitSet: Long = JLong.highestOneBit(x)
    def withLowestOneBitSet: Long = JLong.lowestOneBit(x)
    def numberOfLeadingZeroes: Int = JLong.numberOfLeadingZeros(x)
    def numberOfTrailingZeroes: Int = JLong.numberOfTrailingZeros(x)
    def bitCount: Int = JLong.bitCount(x)
    def setLowestBits(n: Int): Long = x | (left(n) - 1)
    def clearLowestBits(n: Int): Long = x & left(n, ~0L)
    def setBit(i: Int, set: Boolean): Long = if (set) setBit(i) else clearBit(i)
    def setBit(i: Int): Long = x | left(i)
    def clearBit(i: Int): Long = x & ~left(i)
    def toggleBit(i: Int): Long = x ^ left(i)
    def testBit(i: Int): Boolean = ((x >> i) & 1) == 1
    private def left(bits: Int, num: Long = 1L) = assuming(bits >= 0 && bits < JLong.SIZE)(num << bits)
  }
  implicit class NumericExtensions[A](val x: A)(implicit n: Numeric[A]) {
    import Numeric.Implicits._
    def **(i: Int): A = if (i == 0) n.one else {
      val h = x ** (i/2)
      if (i%2 == 0) h * h else h * h * x
    }
    def distance(y: A) = (x - y).abs()
    def nonNegative: Option[A] = when(n.gteq(x, n.zero))(x)
    def whenNegative(f: => A): A = nonNegative getOrElse f   //e.g. students indexOf "Greg" whenNegative Int.MaxValue
  }
  implicit class IntegralExtensions[A](val x: A)(implicit n: Integral[A]) {
    import scala.collection.immutable.NumericRange, Integral.Implicits._
    def mod(y: A): A = x - ((x / y) * y) //(x/y)*y + (x mod y) == x
    def -->(y: A): NumericRange.Inclusive[A] = NumericRange.inclusive(x, y, if (n.lteq(x, y)) n.one else -n.one)
    def ceilDiv(y: A): A = if (mod(y) == n.zero) x/y else n.one + (x/y)
  }
  implicit def toPoint[A](p: (A, A))(implicit n: Numeric[A]) = new java.awt.geom.Point2D.Double(n.toDouble(p._1), n.toDouble(p._2))
  def desc[A: Ordering]: Ordering[A] = asc[A].reverse  //e.g. students.sortBy(_.height)(desc)
  def asc[A](implicit order: Ordering[A]): Ordering[A] = order
  def map[K] = new {
    def to[V](default: => V): Dict[K, V] = using(_ => default)
    def using[V](f: K => V): Dict[K, V] = new mutable.HashMap[K, V]() {
      override def apply(key: K) = getOrElseUpdate(key, f(key))
    }
  }
  def newMultiMap[K, V] = map[K] to mutable.Set.empty[V]
  def memoize[A, B](f: A => B): A ==> B = map[A] using f
  implicit class FuzzyDouble(val x: Double) extends AnyVal {
    def  >~(y: Double) = x > y + eps
    def >=~(y: Double) = x >= y + eps
    def  ~<(y: Double) = y >=~ x
    def ~=<(y: Double) = y >~ x
    def  ~=(y: Double) = (x distance y) <= eps
  }
  def toPolygon(points: Traversable[(Int, Int)]): java.awt.Polygon = {
    val (xs, ys) = points.unzip
    new java.awt.Polygon(xs.toArray, ys.toArray, points.size)
  }
  def toShape(points: Traversable[(Double, Double)]): java.awt.geom.GeneralPath = {
    val shape = new java.awt.geom.GeneralPath()
    points.headOption foreach {case (x, y) => shape.moveTo(x, y)}
    points.tail foreach {case (x, y) => shape.lineTo(x, y)}
    shape.closePath()
    shape
  }
  def until(until: Int): Range = 0 until until
  def not[A](f: A => Boolean): A => Boolean = {x: A => !f(x)}
  def assuming[A](cond: => Boolean)(f: => A): A = {require(cond); f}
  @inline def when[A](check: Boolean)(f: => A): Option[A] = if (check) f.some else None
  def repeat[U](n: Int)(f: => U): Unit = (1 to n).foreach(_ => f)
  type of[C[_], A] = scala.collection.generic.CanBuild[A, C[A]]
  type ==>[A, B] = collection.Map[A, B]
  val mod: Int = (1e9 + 7).toInt
  val eps: Double = 1e-9
}
/***********************************[Scala I/O]*********************************************/
import Utils._, java.io._, java.util.StringTokenizer

class IO(in: BufferedReader, out: BufferedWriter) extends Iterator[String] with AutoCloseable with Flushable {
  def this(reader: Reader, writer: Writer) = this(new BufferedReader(reader), new BufferedWriter(writer))
  def this(in: InputStream, out: OutputStream) = this(new InputStreamReader(in), new OutputStreamWriter(out))

  private[this] val tokenizers = Iterator.continually(in.readLine()).takeWhile(_ != null).map(new StringTokenizer(_)).buffered
  val printer = new PrintWriter(out, true)

  @inline private[this] def tokenizer() = {
    while(tokenizers.nonEmpty && !tokenizers.head.hasMoreTokens) tokenizers.next()
    when(tokenizers.nonEmpty)(tokenizers.head)
  }

  def read[A](implicit read: IO.Read[A]): A = read.apply(this)
  def read[C[_], A: IO.Read](n: Int)(implicit b: C of A): C[A] = Iterator.fill(n)(read).to[C]

  def readTill(delim: String): String = tokenizer().get.nextToken(delim)
  def readTillEndOfLine(): String = readTill("\n\r")

  override def next() = tokenizer().get.nextToken()
  override def hasNext = tokenizer().nonEmpty

  def write(obj: Any, more: Any*): this.type = {
    printer.print(obj)
    more foreach {i =>
      printer.print(' ')
      printer.print(i)
    }
    this
  }
  def writeOnNextLine(obj: Any, more: Any*): this.type = {
    printer.println()
    write(obj, more: _*)
    this
  }
  def writeAll(obj: Traversable[Any], separator: String = " "): this.type = write(obj mkString separator)

  override def flush() = printer.flush()
  def close() = {
    flush()
    in.close()
    printer.close()
  }
}
object IO {
  class Read[A](val apply: IO => A) {
    def map[B](f: A => B): Read[B] = new Read(apply andThen f)
  }
  object Read {
    implicit def collection[C[_], A: Read](implicit b: C of A): Read[C[A]]         = new Read(r => r.read[C, A](r.read[Int]))
    implicit val string                                       : Read[String]       = new Read(_.next())
    implicit val char                                         : Read[Char]         = string.map(_.toTraversable.onlyElement)
    implicit val int                                          : Read[Int]          = string.map(_.toInt)
    implicit val long                                         : Read[Long]         = string.map(_.toLong)
    implicit val bigInt                                       : Read[BigInt]       = string.map(BigInt(_))
    implicit val double                                       : Read[Double]       = string.map(_.toDouble)
    implicit val bigDecimal                                   : Read[BigDecimal]   = string.map(BigDecimal(_))
    implicit def tuple2[A: Read, B: Read]                     : Read[(A, B)]       = new Read(r => (r.read[A], r.read[B]))
    implicit def tuple3[A: Read, B: Read, C: Read]            : Read[(A, B, C)]    = new Read(r => (r.read[A], r.read[B], r.read[C]))
    implicit def tuple4[A: Read, B: Read, C: Read, D: Read]   : Read[(A, B, C, D)] = new Read(r => (r.read[A], r.read[B], r.read[C], r.read[D]))
    implicit val boolean                                      : Read[Boolean]      = string map {s =>
      s.toLowerCase match {
        case "yes" | "true" | "1" => true
        case "no" | "false" | "0" => false
        case _ => s.toBoolean
      }
    }
  }
}

object Main extends App {
  import scala.io._
  val input = Source.stdin
  val inputit:Iterator[String] = input.getLines()
  var lineit:Iterator[String] = List.empty.iterator
  def rs() : String = {
    if (lineit.hasNext) lineit.next
    else {
      lineit = inputit.next.split(" ").iterator
      rs()
    }
  }
  def ri(): Int = rs().toInt
  val a = ri ()
  val b = ri ()
  val n = ri ()
  println(
    (for (i <- 1 to n)
      yield {
       val x = ri ();
       val y = ri ();
       val v = ri ();
       math.sqrt ((x - a) * (x - a) + (y - b) * (y - b)) / v} )
  .toList.min)
}

import scala.io.StdIn._

object A extends App {
  val Array(a, b) = readLine().split(" ").map(_.toInt)
  val n = readInt()

  var time = Double.MaxValue
  1 to n foreach { _ =>
    val Array(x, y, v) = readLine().split(" ").map(_.toInt)
    val dist = Math.sqrt((x.toDouble - a) * (x - a) + (y.toDouble - b) * (y - b))
    val newTime = dist / v
    if (time > newTime) {
      time = newTime
    }
  }

  println(time)
}

object A706 {
  @inline def read = scala.io.StdIn.readLine

  @inline def tokenizeLine = new java.util.StringTokenizer(read)

  def readInts(n: Int) = {
    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toInt)
  }

  def readLongs(n: Int) = {
    val tl = tokenizeLine; Array.fill(n)(tl.nextToken.toLong)
  }

  def readBigs(n: Int) = {
    val tl = tokenizeLine; Array.fill(n)(BigInt(tl.nextToken))
  }

  def main(args: Array[String]): Unit = {
    val Array(a, b) = readInts(2)
    val Array(n) = readInts(1)
    println(Array.fill(n)(readInts(3)).map(arr => (math.abs(a- arr(0)) + math.abs(b-arr(1))).toDouble / arr(2).toDouble).min)
  }
}


object _1015A extends CodeForcesApp {
  import annotation._, collection.{mutable, Searching}, util._, control._, math.Ordering.Implicits._, Searching._, Math._

  override def apply(io: IO): io.type = {
    val n, m = io.read[Int]
    val intervals: Seq[(Int, Int)] = io.read(n)
    val ans = intervals.foldLeft(mutable.Set(1 to m : _*))({case (s, (i, j)) => s --= i to j})
    io.writeLine(ans.size).writeAll(ans)
  }
}
/****************************[Ignore Template Below]****************************************/
trait CodeForcesApp {
  lazy val isOnlineJudge: Boolean = sys.props.get("ONLINE_JUDGE").exists(_.toBoolean)
  def debug(x: => Any): Unit = if (!isOnlineJudge) println(x)
  def apply(io: IO): io.type
  def main(args: Array[String]): Unit = this(new IO(System.in, System.out)).close()
}
/***********************************[Scala I/O]*********************************************/
import java.io._, java.util.StringTokenizer
import scala.collection.generic.CanBuild

class IO(in: BufferedReader, out: BufferedWriter) extends Iterator[String] with AutoCloseable with Flushable {
  def this(reader: Reader, writer: Writer) = this(new BufferedReader(reader), new BufferedWriter(writer))
  def this(in: InputStream, out: OutputStream) = this(new InputStreamReader(in), new OutputStreamWriter(out))

  private[this] val tokenizers = Iterator.continually(in.readLine()).takeWhile(_ != null).map(new StringTokenizer(_)).buffered
  val printer = new PrintWriter(out, true)

  @inline private[this] def tokenizer() = {
    while(tokenizers.nonEmpty && !tokenizers.head.hasMoreTokens) tokenizers.next()
    tokenizers.headOption
  }

  def read[A](implicit read: IO.Read[A]): A = read.apply(this)
  def read[C[_], A: IO.Read](n: Int)(implicit b: CanBuild[A, C[A]]): C[A] = Iterator.fill(n)(read).to[C]

  def readTill(delim: String): String = tokenizer().get.nextToken(delim)
  def readTillEndOfLine(): String = readTill("\n\r")

  def readAll[A: IO.Read]: (Int, Vector[A]) = {
    val data = read[Vector[A]]
    (data.length, data)
  }

  override def next() = tokenizer().get.nextToken()
  override def hasNext = tokenizer().nonEmpty

  def write(obj: Any): this.type = {
    printer.print(obj)
    this
  }
  def writeLine(): this.type = {
    printer.println()
    this
  }
  def writeLine(obj: Any): this.type = {
    printer.println(obj)
    this
  }
  def writeAll(obj: Traversable[Any], separator: String = " "): this.type = write(obj mkString separator)
  def query[A: IO.Read](question: Any): A = writeLine(question).read

  override def flush() = printer.flush()
  def close() = {
    flush()
    in.close()
    printer.close()
  }
}
object IO {
  class Read[A](val apply: IO => A) {
    def map[B](f: A => B): Read[B] = new Read(apply andThen f)
  }

  object Read {
    implicit def collection[C[_], A: Read](implicit b: CanBuild[A, C[A]]) : Read[C[A]]         = new Read(r => r.read[C, A](r.read[Int]))
    implicit val string                                                   : Read[String]       = new Read(_.next())
    implicit val int                                                      : Read[Int]          = string.map(_.toInt)
    implicit val long                                                     : Read[Long]         = string.map(_.toLong)
    implicit val bigInt                                                   : Read[BigInt]       = string.map(BigInt(_))
    implicit val double                                                   : Read[Double]       = string.map(_.toDouble)
    implicit val bigDecimal                                               : Read[BigDecimal]   = string.map(BigDecimal(_))
    implicit def tuple2[A: Read, B: Read]                                 : Read[(A, B)]       = new Read(r => (r.read[A], r.read[B]))
    implicit def tuple3[A: Read, B: Read, C: Read]                        : Read[(A, B, C)]    = new Read(r => (r.read[A], r.read[B], r.read[C]))
    implicit def tuple4[A: Read, B: Read, C: Read, D: Read]               : Read[(A, B, C, D)] = new Read(r => (r.read[A], r.read[B], r.read[C], r.read[D]))
    implicit val boolean                                                  : Read[Boolean]      = string map {s =>
      s.toLowerCase match {
        case "yes" | "true" | "1" => true
        case "no" | "false" | "0" => false
        case _ => s.toBoolean
      }
    }
  }
}

object Main {
    import java.io._
    import java.util.StringTokenizer

    import scala.collection.mutable
    import scala.util.Sorting
    import math.{abs, max, min}
    import scala.collection.mutable.{ArrayBuffer, ListBuffer}
    import scala.reflect.ClassTag

  val MOD = 1000000007
  val out = new PrintWriter(System.out)

  def solve(): Unit = {
    val sc = new InputReader(System.in)
    val N, M = sc.nextInt()
    val used = Array.ofDim[Boolean](M)
    rep(N) { _ =>
      val l, r = sc.nextInt() - 1
      l to r foreach (j => used(j) = true)
    }

    val cnt = M - used.count(identity)
    out.println(cnt)
    out.println((used.zipWithIndex filterNot (_._1) map (_._2 + 1)).mkString(" "))
  }

  def main(args: Array[String]): Unit = {
    solve()
    out.flush()
  }

  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = _

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  def rep(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }
  def rep_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while(i >= offset) { f(i); i -= 1 }
  }

  def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    rep(n)(i => res(i) = f(i))
    res
  }

  implicit class ArrayOpts[A](val as: Array[A]) extends AnyVal {
    // todo Orderingだとboxing発生するので自作Orderを用意したい
    def maxByOpt[B: Ordering](f: A => B): Option[A] = {
      if (as.nonEmpty) Some(as.maxBy(f)) else None
    }

    def grpBy[K](f: A => K): mutable.Map[K, ArrayBuffer[A]] = {
      val map = mutable.Map.empty[K, ArrayBuffer[A]]
      rep(as.length)(i => map.getOrElseUpdate(f(as(i)), ArrayBuffer()) += as(i))
      map
    }

    def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
      var sum = num.zero
      rep(as.length)(i => sum = num.plus(sum, f(as(i))))
      sum
    }

    def minByEx[B](f: A => B, ixRange: Range = as.indices)(implicit cmp: Ordering[B]): (A, B) = {
      limit(f, ixRange)(cmp.lt)
    }

    def maxByEx[B](f: A => B, ixRange: Range = as.indices)(implicit cmp: Ordering[B]): (A, B) = {
      limit(f, ixRange)(cmp.gt)
    }

    private def limit[B](f: A => B, ixRange: Range)(cmp: (B, B) => Boolean): (A, B) = {
      var limA = as(ixRange.head)
      var limB = f(limA)

      for (i <- ixRange.tail) {
        val a = as(i)
        val b = f(a)
        if (cmp(b, limB)) {
          limA = a
          limB = b
        }
      }
      (limA, limB)
    }
  }

  implicit class IterableOpts[A](val as: Iterable[A]) extends AnyVal {
    def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
      as.foldLeft(num.zero)((acc, a) => num.plus(acc, f(a)))
    }
  }
}

object CF501A extends App {

  import java.io.PrintWriter
  import java.util.Scanner

  val in = new Scanner(System.in)
  val out = new PrintWriter(System.out)

  def solve = {
    val n = in.nextInt
    val m = in.nextInt

    var points = (1 to m).toList
    var segments = (0 until n).map(_ => (in.nextInt, in.nextInt)).toList

    for (segment <- segments) {
      points = points.filter(x => x < segment._1 || x > segment._2)
    }

    out.println(points.length)
    out.println(points.mkString(" "))
  }

  solve
  out.flush
  out.close
}

import scala.collection.mutable
import scala.io.StdIn

object A {
  def main(args: Array[String]): Unit = {
    val List(n, m) = StdIn.readLine().split(" ").map(_.toInt).toList

    var s = new mutable.HashSet[Int]()
    for (i <- 1 to n) {
      val List(b, e) = StdIn.readLine().split(" ").map(_.toInt).toList
      for (j <- b to e) {
        s += j
      }
    }

    var res = new mutable.TreeSet[Int]()
    for (i <- 1 to m) {
      if (!(s contains i)) {
        res += i
      }
    }

    println(res.size)
    if (res.nonEmpty) {
      println(res.mkString(" "))
    }
  }
}


import java.io._
import java.util.StringTokenizer
import scala.collection.mutable
import scala.collection.mutable._
import scala.collection.immutable._
import scala.util.Sorting.quickSort
import scala.math._

object sample extends App {
    val writer =  new PrintWriter(System.out, false)
    val reader = new BufferedReader(new InputStreamReader(System.in))
    var st = new StringTokenizer("")
    def next(): String = {while (!st.hasMoreTokens) {st = new StringTokenizer(reader.readLine())};st.nextToken()}
    def readInt(): Int = next().toInt
    def readLong(): Long = next().toLong
    def readString(): String = next()

    case class myType(var social: Int, var cp:  Int, var ind: Int)extends Ordered[myType] {
        override def compare(that: myType): Int = {
            if (social < that.social)
                return -1
            else if (social == that.social)
                return 0
            else
                return 1
        }
    }
    val rem = 1000000007

    val t = readInt()
    for (tt <- 1 to t) {
        val n = readInt()
        val m = readInt()
        val mark = new Array[Boolean](n+1)
        for (i <- 1 to m){
            readInt()
            mark(readInt()) = true
            readInt()
        }
        var root = 0
        for (i <- 1 to n){
            if (!mark(i))
                root = i
        }
        for (i <- 1 to n){
            if (root != i) {
                writer.print(root)
                writer.print(" ")
                writer.println(i)
            }
        }
    }
    writer.flush()
}

import scala.collection.mutable.ListBuffer
import scala.io.StdIn.readLine

object OmkarAndHeavenlyTree extends App {
  val t = readLine.trim.toInt
  for(_ <- 0 until t) {
    val n::m::_ = readLine.split(' ').toList.map(_.toInt)
    val seen : ListBuffer[Int] = ListBuffer()
    for(_ <- 1 to m) {
      val _::b::_::_ = readLine.split(' ').toList.map(_.toInt)
      seen += b
    }
    val all = (1 to n).toSet
    val possible = all.diff(seen.toSet).head
    val nodes = (all - possible).toList
    for (n <- nodes) {
      println(n + " " + possible)
    }
  }
}