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

import scala.collection.immutable.TreeMap

/**
  * @author antipov.
  *         15.07.2016 14:47.
  */
object A extends App {
  object Reader {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val out = new PrintWriter(System.out)
  }

  val sc: Scanner = new Scanner(System.in)
  def readInt(): Int = sc.nextInt()
  def readLong(): Long = sc.nextLong()

  case class Edge(var from: Long, var to: Long) extends Comparable[Edge] {
    if(from > to) {
      val tmp = from
      from = to
      to = tmp
    }

    override def compareTo(o: Edge): Int =
      if (this.from != o.from) this.from compareTo o.from
      else this.to compareTo o.to

    override def toString: String = "Edge(" + from + ", " + to + ")"
  }

  val q = sc.nextInt()
  var added = new TreeMap[Edge, Long]() withDefaultValue 0L

  (0 until q).foreach(i => {
    val (t, v, u) = (readLong(), readLong(), readLong())
    val edges = convert(path(v, u))
    if(t == 1) {
      val w = readLong()
      edges foreach(e => added = added + (e -> (added(e) + w)))
    } else
      println(edges map (e => added(e)) sum)
  })

  def convert(path: List[Long]): List[Edge] = {
    def convert(path: List[Long], acc: List[Edge]): List[Edge] = path match {
      case List(x) => acc
      case x :: y :: xs => convert(path.tail, Edge(x, y) :: acc)
    }
    convert(path, Nil)
  }

  def path(v: Long, u: Long): List[Long] = {
    def path(v: Long, u: Long, accV: List[Long], accU: List[Long]): List[Long] = {
      if(v == u) accU.reverse ::: (v :: accV)
      else if(v > u) path(v / 2, u, v :: accV, accU)
      else path(v, u / 2, accV, u :: accU)
    }
    path(v, u, List(), List())
  }
}

import scala.collection._

object Main {

    var map = mutable.Map[Long, Long]().withDefaultValue(0L)

    def main(args: Array[String]): Unit = {
        var Q = readInt()
        for(_ <- 0 until Q) {

            val a: Array[Long] = readLine().split(" ").map(_.toLong)

            val u: Long = a(1)
            val v: Long = a(2)

            val lca: Long = LCA(u, v)

            if (a(0) == 1) {
                val cost: Long = a(3)
                update(u, lca, cost)
                update(v, lca, cost)
            } else {
                val ret = getCost(u, lca, 0) + getCost(v, lca, 0)
                println(ret)
            }
        }
    }

    @annotation.tailrec
    def LCA(u: Long, v: Long): Long = {
        if (u == v) v
        else if (u > v) LCA(u / 2, v)
        else LCA(u, v / 2)
    }

    @annotation.tailrec
    def update(v: Long, lca: Long, cost: Long) {
        if (v > lca) {
            map(v) += cost
            update(v / 2, lca, cost)
        }
    }

    @annotation.tailrec
    def getCost(v: Long, lca: Long, acc: Long): Long = {
        if (v > lca) {
            map.get(v) match {
                case Some(cost) => getCost(v / 2, lca, acc + cost)
                case None => getCost(v / 2, lca, acc)
            }
        } else acc
    }
}

import scala.collection._

object Main {

    var map = mutable.Map[Long, Long]().withDefaultValue(0L)

    def main(args: Array[String]): Unit = {
        var Q = readInt()
        for(_ <- 0 until Q) {

            val a: Array[Long] = readLine().split(" ").map(_.toLong)

            val u: Long = a(1)
            val v: Long = a(2)

            val lca: Long = LCA(u, v)

            if (a(0) == 1) {
                val cost: Long = a(3)
                update(u, lca, cost)
                update(v, lca, cost)
            } else {
                val ret = getCost(u, lca, 0) + getCost(v, lca, 0)
                println(ret)
            }
        }
    }

    @annotation.tailrec
    def LCA(u: Long, v: Long): Long = {
        if (u == v) v
        else if (u > v) LCA(u / 2, v)
        else LCA(u, v / 2)
    }

    @annotation.tailrec
    def update(v: Long, lca: Long, cost: Long) {
        if (v > lca) {
            map(v) += cost
            update(v / 2, lca, cost)
        }
    }

    // @annotation.tailrec
    def getCost(v: Long, lca: Long, acc: Long): Long = {
        if (v > lca) {
            map.get(v).map(x => getCost(v / 2, lca, acc + x)).getOrElse(getCost(v / 2, lca, acc))
            // map.get(v) match {
            //     case Some(cost) => getCost(v / 2, lca, acc + cost)
            //     case None => getCost(v / 2, lca, acc)
            // }
        } else acc
    }
}

import scala.collection._
import java.util.StringTokenizer
import java.io._

object Main extends App {

    var map = mutable.Map[Long, Long]().withDefaultValue(0L)

    var Q = IO.nextInt
    (0 until Q).foreach { _ =>

      val (kindOf, u, v) = (IO.nextLong, IO.nextLong, IO.nextLong)
      val lca: Long = LCA(u, v)

      if (kindOf == 1) {
          val cost: Long = IO.nextLong
          update(u, lca, cost)
          update(v, lca, cost)
      } else {
          val ret = getCost(u, lca, 0) + getCost(v, lca, 0)
          println(ret)
      }
    }

    IO.close

    @annotation.tailrec
    def LCA(u: Long, v: Long): Long = {
        if (u == v) v
        else if (u > v) LCA(u / 2, v)
        else LCA(u, v / 2)
    }

    @annotation.tailrec
    def update(v: Long, lca: Long, cost: Long) {
        if (v > lca) {
            map(v) += cost
            update(v / 2, lca, cost)
        }
    }

    def getCost(v: Long, lca: Long, acc: Long): Long = {
      if (v > lca) map.get(v).map(x => getCost(v / 2, lca, acc + x)).getOrElse(getCost(v / 2, lca, acc))
      else acc
    }
}

object IO {
  val in = new BufferedReader(new InputStreamReader(System.in))
  val out = new PrintWriter(System.out)
  var tok = new StringTokenizer("")
  def nextToken() = {
    while (!tok.hasMoreTokens) {
      tok = new StringTokenizer(in.readLine())
    }
    tok.nextToken()
  }

  def nextInt = nextToken().toInt
  def nextLong = nextToken().toLong
  def println(a: Any) = out.println(a)
  def close = {
    in.close()
    out.close()
  }
}

import java.util.Scanner
import scala.collection._
import java.lang.Math._

/**
  * @author antipov.
  *         15.07.2016 14:47.
  */
object A extends App {
  val sc: Scanner = new Scanner(System.in)
  def readInt(): Int = sc.nextInt()
  def readLong(): Long = sc.nextLong()

  case class Edge(from: Long, to: Long) {
    require(from <= to)

    override def hashCode(): Int = {
      val prime = 31
      (prime + from.hashCode()) * prime + to.hashCode()
    }

    override def equals(obj: scala.Any): Boolean = obj match {
      case Edge(x, y) => x == from && y == to
      case _ => false
    }

    override def toString: String = "Edge(" + from + ", " + to + ")"
  }

  val q = sc.nextInt()
  val added = new mutable.HashMap[Edge, Long]() withDefaultValue 0L

  (0 until q).foreach(i => {
    val (t, v, u) = (readLong(), readLong(), readLong())
    val edges = convert(path(v, u))
    if(t == 1) {
      val w = readLong()
      edges foreach(e => added += ((e, added(e) + w)))
    } else
      println(edges map (e => added(e)) sum)
  })

  def convert(path: List[Long]): List[Edge] = {
    def convert(path: List[Long], acc: List[Edge]): List[Edge] = path match {
      case List(x) => acc
      case x :: y :: xs => convert(path.tail, Edge(min(x, y), max(x, y)) :: acc)
    }
    convert(path, Nil)
  }

  def path(v: Long, u: Long): List[Long] = {
    def path(v: Long, u: Long, accV: List[Long], accU: List[Long]): List[Long] = {
      if(v == u) accU.reverse ::: (v :: accV)
      else if(v > u) path(v / 2, u, v :: accV, accU)
      else path(v, u / 2, accV, u :: accU)
    }
    path(v, u, List(), List())
  }

}

import java.io._
import java.util.StringTokenizer
import scala.collection._

/**
  * @author antipov.
  *         15.07.2016 14:47.
  */
object A extends App {
  def readInt(): Int = IO.nextInt
  def readLong(): Long = IO.nextLong
  def println(a: Any) = IO.println(a)

  case class Edge(var from: Long, var to: Long) extends Comparable[Edge] {
    if(from > to) {
      val tmp = from
      from = to
      to = tmp
    }

    override def compareTo(o: Edge): Int =
      if (this.from != o.from) this.from compareTo o.from
      else this.to compareTo o.to

    override def toString: String = "Edge(" + from + ", " + to + ")"
  }

  val q = readInt
  var added = new immutable.TreeMap[Edge, Long]() withDefaultValue 0L

  (0 until q).foreach(i => {
    val (t, v, u) = (readLong, readLong, readLong)
    val edges = convert(path(v, u))
    if(t == 1) {
      val w = readLong
      edges.map (e => added = added + (e -> (added(e) + w)))
    } else
      println(edges map (e => added(e)) sum)
  })

  def convert(path: List[Long]): List[Edge] = {
    def convert(path: List[Long], acc: List[Edge]): List[Edge] = path match {
      case List(x) => acc
      case x :: y :: xs => convert(path.tail, Edge(x, y) :: acc)
    }
    convert(path, Nil)
  }

  def path(v: Long, u: Long): List[Long] = {
    def path(v: Long, u: Long, accV: List[Long], accU: List[Long]): List[Long] = {
      if(v == u) accU.reverse ::: (v :: accV)
      else if(v > u) path(v / 2, u, v :: accV, accU)
      else path(v, u / 2, accV, u :: accU)
    }
    path(v, u, List(), List())
  }

  IO.close
}

object IO {
  val in = new BufferedReader(new InputStreamReader(System.in))
  val out = new PrintWriter(System.out)
  var tok = new StringTokenizer("")
  def nextToken() = {
    while (!tok.hasMoreTokens) {
      tok = new StringTokenizer(in.readLine())
    }
    tok.nextToken()
  }

  def nextInt = nextToken().toInt
  def nextLong = nextToken().toLong
  def println(a: Any) = out.println(a)
  def close = {
    in.close()
    out.close()
  }
}

import java.io._
import java.util.StringTokenizer
import scala.collection._

/**
  * @author antipov.
  *         15.07.2016 14:47.
  */
object A extends App {
  def readInt(): Int = IO.nextInt
  def readLong(): Long = IO.nextLong
  def println(a: Any) = IO.println(a)

  case class Edge(var from: Long, var to: Long) extends Comparable[Edge] {
    if(from > to) {
      val tmp = from
      from = to
      to = tmp
    }

    override def compareTo(o: Edge): Int =
      if (this.from != o.from) this.from compareTo o.from
      else this.to compareTo o.to

    override def toString: String = "Edge(" + from + ", " + to + ")"
  }

  val q = readInt
  var added = new immutable.TreeMap[Edge, Long]() withDefaultValue 0L

  (0 until q).foreach(i => {
    val (t, v, u) = (readLong, readLong, readLong)
    val edges = convert(path(v, u))
    if(t == 1) {
      val w = readLong
      edges foreach (e => added = added + (e -> (added(e) + w)))
    } else
      println(edges map (e => added(e)) sum)
  })

  def convert(path: List[Long]): List[Edge] = {
    def convert(path: List[Long], acc: List[Edge]): List[Edge] = path match {
      case List(x) => acc
      case x :: y :: xs => convert(path.tail, Edge(x, y) :: acc)
    }
    convert(path, Nil)
  }

  def path(v: Long, u: Long): List[Long] = {
    def path(v: Long, u: Long, accV: List[Long], accU: List[Long]): List[Long] = {
      if(v == u) accU.reverse ::: (v :: accV)
      else if(v > u) path(v / 2, u, v :: accV, accU)
      else path(v, u / 2, accV, u :: accU)
    }
    path(v, u, List(), List())
  }

  IO.close
}

object IO {
  val in = new BufferedReader(new InputStreamReader(System.in))
  val out = new PrintWriter(System.out)
  var tok = new StringTokenizer("")
  def nextToken() = {
    while (!tok.hasMoreTokens) {
      tok = new StringTokenizer(in.readLine())
    }
    tok.nextToken()
  }

  def nextInt = nextToken().toInt
  def nextLong = nextToken().toLong
  def println(a: Any) = out.println(a)
  def close = {
    in.close()
    out.close()
  }
}

object Lorenzo {
    import io.StdIn.readLine
    import collection.mutable.ArrayBuffer
    var map = collection.mutable.HashMap[Long, Long]()

    def main(args: Array[String]){
        var price = 0L

        for(i <- 0 until readLine.trim.toInt){
            val ar = readLine.trim.split(" ")

            var al = ar.tail.map(_.toLong)
            if(ar(0) == "1")
            {

                var v = al(0)
                var u = al(1)
                var w = al(2)
                var path = getPath(v, u)
                updateMap(path, w)
                price+=getPrice(path)

            }
            else
            {
                var v = al(0)
                var u = al(1)
                var path = getPath(v, u)
                updateMap(path, 0L)
                println(getPrice(path))

            }

        }

    }

    def depth(v: Long): Long = {
        v.toBinaryString.length
    }

    def getPath(v: Long, u: Long): ArrayBuffer[Long] = {
        var ab = ArrayBuffer[Long]()

        var nv = v
        var nu = u

        val dv = depth(v)
        val du = depth(u)

        if(dv > du)
        {
            for(i <- 0 until (dv - du).toInt)
            {
                ab+=nv
                nv/=2
            }

        }
        if(dv < du)
        {
            for(i <- 0 until (du - dv).toInt)
            {
                ab+=nu
                nu/=2
            }

        }

        while(nv != nu)
        {
            ab+=nv
            ab+=nu
            nv/=2
            nu/=2
        }

        ab
    }

    def updateMap(ab: ArrayBuffer[Long], p: Long): Unit = {
        for(i <- ab)
        {
            if(map.isDefinedAt(i))
            {
                map(i)+=p
            }
            else
            {
                map(i) = p
            }
        }

    }

    def getPrice(ab: ArrayBuffer[Long]): Long = {
        ab.fold(0L){ (z, i) =>
            z + map(i)
        }

    }

}

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

object _697C extends CodeForcesApp {
  override def apply(io: IO) = {import io.{read, write}
    val costToParent = map[Long] to 0L

    @tailrec
    def increase(u: Long, v: Long, w: Long): Unit = {
      //debug(u, v, w)
      if (u > v) {
        costToParent(u) += w
        increase(u/2, v, w)
      } else if (u < v) {
        costToParent(v) += w
        increase(u, v/2, w)
      }
    }

    @tailrec
    def calc(u: Long, v: Long, acc: Long): Long = {
      if(u > v) {
        calc(u/2, v, acc + costToParent(u))
      } else if (v > u) {
        calc(u, v/2, acc + costToParent(v))
      } else {
        acc
      }
    }

    repeat(read[Int]) {
      read[Int] match {
        case 1 =>
          val v, u, w = read[Long]
          increase(u, v, w)
        case 2 =>
          val v, u = read[Long]
          val cost = calc(u, v, 0L)
          write(cost).writeLine()
      }
    }
    io
  }
}
/****************************[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
  }
  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 toYesNo = 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)
  }
  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 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 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 = 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
      }
    }
  }
}


import collection.mutable.MutableList

/**
 * Created by IntelliJ IDEA.
 * User: User
 * Date: 29.02.12
 * Time: 2:59
 * To change this template use File | Settings | File Templates.
 */
object C {
  def main(args: Array[String]) {
    val input = readLine
    val forbid = Map(((1 to readInt) map (_ => readLine)) flatMap (str => List(str(0) -> Some(str), str(1) -> Some(str))): _*) withDefaultValue None
    var currentPair: Option[String] = None
    var striked = 0
    var found = List(0, 0)
    for (c <- input) {
      forbid(c) match {
        case None => {
          currentPair = None
          striked += found.min
          found = List(0, 0)
        }
        case Some(str) => {
          val newFound = str.indexOf(c) match {
            case 0 => List(1, 0)
            case 1 => List(0, 1)
          }
          found = currentPair match {
            case Some(cur_str) => {
              if (str == cur_str) (found zip newFound) map (x => x._1 + x._2)
              else {
                striked += found.min
                currentPair = Some(str)
                newFound
              }
            }
            case None => {
              currentPair = Some(str)
              newFound
            }
          }
        }
      }
    }
    striked += (currentPair match {
      case None => 0
      case Some(str) => found.min
    })
    println(striked)
  }
}

object A {
  def main(args: Array[String]) {
    val input = readLine
    val forbid = Map(((1 to readInt) map (_ => readLine)) flatMap (str => List(str(0) -> Some(str), str(1) -> Some(str))): _*) withDefaultValue None
    var currentPair: Option[String] = None
    var striked = 0
    var found = List(0, 0)
    for (c <- input) {
      forbid(c) match {
        case None => {
          currentPair = None
          striked += found.min
          found = List(0, 0)
        }
        case Some(str) => {
          val newFound = str.indexOf(c) match {
            case 0 => List(1, 0)
            case 1 => List(0, 1)
          }
          found = currentPair match {
            case Some(cur_str) => {
              if (str == cur_str) (found zip newFound) map (x => x._1 + x._2)
              else {
                striked += found.min
                currentPair = Some(str)
                newFound
              }
            }
            case None => {
              currentPair = Some(str)
              newFound
            }
          }
        }
      }
    }
    striked += (currentPair match {
      case None => 0
      case Some(str) => found.min
    })
    println(striked)
  }
}


import java.util.Scanner

object D extends App {
  def cnt(t: Long) = t / x + t / y

  def bs(s: Long) = {
    var l = s * x * y / (x + y)
    var r = 2 * s * (x max y)

    while (r - l > 1) {
      val p = (l + r) / 2

//      val z = Seq(l, p, r)

      cnt(p) match {
        case c if c < s => l = p + 1
        case _ => r = p
      }

//      Console.err.println(z + " -> " + (z map cnt) + " by " + (l, r))
    }

//    val z = Seq(l, r)
//    Console.err.println(z + " -> " + (z map cnt))

    if (cnt(l) == s) l else r
  } ensuring {
    r => {
      val c = cnt(r)
//      Console.err.println("answer: " + r)
      s <= c && c <= s + 1
    }
  }

  val sc = new Scanner(System.in)

  val n = sc.nextInt()
  val (x, y) = n(sc.nextLong(), sc.nextLong())

  def gcd(a: Long, b: Long): Long = if (b == 0) a.abs else gcd(b, a % b)
  def n(x: Long, y: Long) = {
    val g = gcd(x, y)
    (x / g, y / g)
  }

  for (i <- 1 to n) {
    val s = sc.nextLong()

    def decide(t: Long): String = (t % x == 0, t % y == 0) match {
      case (true, true) => "Both"
      case (true, false) => "Vova"
      case (false, true) => "Vanya"
      case _ => decide(t - 1)
    }
    val ans = decide(bs(s))

    Console.println(ans)
  }
}

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

import scala.util.Sorting

object Solution {
  val INF: Long = 1e18.toLong;
  var x: Long = 0
  var y: Long = 0

  def countHits(num: Long): Long = num / y + num / x

  def solve(in: FastScanner, out: PrintWriter): Unit = {
    val n = in.nextInt()
    x = in.nextLong()
    y = in.nextLong()
    for (i <- 0 until n) {
      val a: Long = in.nextLong()
      var low: Long = 0
      var high: Long = INF
      while (high - low > 1) {
        val mid: Long = (low + high) / 2
        if (countHits(mid) >= a)
          high = mid
        else
          low = mid
      }
      if (high % y == 0 && high % x == 0)
        out.println("Both")
      else if (high % y == 0)
        out.println("Vanya")
      else
        out.println("Vova")
    }
  }

  def main(args: Array[String]): Unit = {
    val in = new FastScanner(System.in)
    val out = new PrintWriter(System.out)
    solve(in, out)
    out.flush()
  }

  class FastScanner(val in: InputStream) {
    var st: StringTokenizer = null
    var br = new BufferedReader(new InputStreamReader(in))

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

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

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

    def close(): Unit = {
      br.close()
    }
  }

}

import scala.collection._

object D 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, x, y) = readLongs(3)
  val as = Array.fill(n.toInt) { readLine.toInt }

  val perSecond = x + y
  val resolution = x * y
  val stepX = (resolution / x)
  val stepY = (resolution / y)

  Console.setOut(new java.io.BufferedOutputStream(Console.out))
  var c = 0
  for (a <- as) {

    def can(ticks: Long) = ticks / stepX + ticks / stepY >= a

    @annotation.tailrec
    def binSearch(low: Long, hi: Long): Long = {
      if (hi < low) low
      else {
        val mid = (low + hi) >>> 1
        if (can(mid)) binSearch(low, mid - 1)
        else binSearch(mid + 1, hi)
      }
    }

    val ticks = binSearch(0, Long.MaxValue - 1) - 1
    val stepsX = ticks / stepX
    val stepsY = ticks / stepY
    //println(ticks, stepsX, stepsY)

    var remain = a - stepsX - stepsY
    if (remain <= 0) println("Both")
    else {
      var px = stepsX * stepX
      var py = stepsY * stepY
      while (remain > 0) {
        c += 1
        //println(remain, px, py, c)
        val dx = px + stepX
        val dy = py + stepY
        if (dx == dy) {
          remain -= 2
          px += stepX
          py += stepY
          if (remain <= 0) println("Both")
        } else if (dx < dy) {
          val steps = ((dy - px) / stepX - 1) max 1
          remain -= steps
          px += stepX * steps
          if (remain <= 0) println("Vanya")
        } else {
          val steps = ((dx - py) / stepY - 1) max 1
          remain -= steps
          py += stepY * steps
          if (remain <= 0) println("Vova")
        }
      }
    }
  }

  Console.flush
}

object D {
  def main(args: Array[String]) = {
    val data = readLine().split(' ').map(t => t.toInt)
    val n = data(0)
    val x: Long = data(1)
    val y: Long = data(2)
    //println(x, y, n)
    for (e <- (1 to n).map(_ => readLine().toLong)) {
      println(solve(e, x, y))
    }
  }
  def gcd(a: Long, b: Long): Long = if (a == 0) b else gcd(b % a, a)
  def lcm(a: Long, b: Long) = a * b / gcd(a, b)
  def findMin(e: Long, sx: Long, sy: Long, begin: Long, end: Long): Long = {
    val mid = (begin + end) / 2
    if (begin == end) begin
    else if (mid / sx + mid / sy >= e) findMin(e, sx, sy, begin, mid)
    else findMin(e, sx, sy, mid + 1, end)
  }
  def solve(e: Long, x: Long, y: Long): String = {
    val z = lcm(x, y)
    val stepx = z / x
    val stepy = z / y

    val m = findMin(e, stepx, stepy, 0, e * stepx)
    if (m % stepx == 0) {
      if (m % stepy == 0) "Both"
      else "Vanya"
    } else "Vova"
  }
}

import scala.collection._

object D 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, x, y) = readLongs(3)
  val as = Array.fill(n.toInt) { readLine.toInt }

  val perSecond = x + y
  val resolution = BigInt(x * y)

  for (a <- as) {
    var remain = a % perSecond
    //if (remain < 0) remain += perSecond
   // println(remain)
    if (remain <= 0) println("Both")
    else {
      var px, py = 0L
      while (remain > 0) {
        val dx = (px + 1) * resolution / x
        val dy = (py + 1) * resolution / y
        if (dx == dy) {
          remain -= 2
          if (remain <= 0) println("Both")
        } else if (dx < dy) {
          remain -= 1
          px += 1
          if (remain <= 0) println("Vanya")
        } else {
          remain -= 1
          py += 1
          if (remain <= 0) println("Vova")
        }
      }
    }
  }
}

import scala.collection._

object D 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, x, y) = readInts(3)
  val as = Array.fill(n) { readLine.toInt }

  val perSecond = x + y
  val resolution = x * y

  for (a <- as) {
    var remain = a % perSecond
    if (remain == 0) println("Both")
    else {
      var px, py = 0L
      while (remain > 0) {
        val dx = (px + 1) * resolution / x
        val dy = (py + 1) * resolution / y
        if (dx == dy) {
          remain -= 2
          if (remain <= 0) println("Both")
        } else if (dx < dy) {
          remain -= 1
          px += 1
          if (remain <= 0) println("Vanya")
        } else {
          remain -= 1
          py += 1
          if (remain <= 0) println("Vova")
        }
      }
    }
  }
}

import scala.collection._

object D 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, x, y) = readLongs(3)
  val as = Array.fill(n.toInt) { readLine.toInt }

  val perSecond = x + y + 2
  val resolution = BigInt(x * y)

  for (a <- as) {
    var remain = a % perSecond
    if (remain == 0) println("Both")
    else {
      var px, py = 0L
      while (remain > 0) {
        val dx = (px + 1) * resolution / x
        val dy = (py + 1) * resolution / y
        if (dx == dy) {
          remain -= 2
          if (remain <= 0) println("Both")
        } else if (dx < dy) {
          remain -= 1
          px += 1
          if (remain <= 0) println("Vanya")
        } else {
          remain -= 1
          py += 1
          if (remain <= 0) println("Vova")
        }
      }
    }
  }
}

import scala.collection._

object D 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, x, y) = readLongs(3)
  val as = Array.fill(n.toInt) { readLine.toInt }

  val perSecond = x + y
  val resolution = x * y

  for (a <- as) {
    var remain = a % perSecond
    if (remain == 0) println("Both")
    else {
      var px, py = 0L
      while (remain > 0) {
        val dx = (px + 1) * resolution / x
        val dy = (py + 1) * resolution / y
        if (dx == dy) {
          remain -= 2
          if (remain <= 0) println("Both")
        } else if (dx < dy) {
          remain -= 1
          px += 1
          if (remain <= 0) println("Vanya")
        } else {
          remain -= 1
          py += 1
          if (remain <= 0) println("Vova")
        }
      }
    }
  }
}

import scala.collection._

object D 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, x, y) = readLongs(3)
  val as = Array.fill(n.toInt) { readLine.toInt }

  val perSecond = x + y + 2
  val resolution = x * y

  for (a <- as) {
    var remain = a % perSecond
    if (remain == 0) println("Both")
    else {
      var px, py = 0L
      while (remain > 0) {
        val dx = (px + 1) * resolution / x
        val dy = (py + 1) * resolution / y
        if (dx == dy) {
          remain -= 2
          if (remain <= 0) println("Both")
        } else if (dx < dy) {
          remain -= 1
          px += 1
          if (remain <= 0) println("Vanya")
        } else {
          remain -= 1
          py += 1
          if (remain <= 0) println("Vova")
        }
      }
    }
  }
}

import java.util.Scanner

object D extends App {
  def cnt(t: Long) = t / x + t / y - t / (x * y)

  def bs(s: Long) = {
    var l = s * x * y / (x + y)
    var r = (s + 2) * x * y / (x + y)

    while (r - l > 1) {
      val p = (l + r) / 2
      cnt(p) match {
        case c if c < s => l = p + 1
        case c if c > s => r = p - 1
        case _ => r = p
      }
    }

    if (cnt(l) == s) l else r
  } ensuring {
    r => {
      val c = cnt(r)
      s <= c && c <= s + 1
    }
  }

  val sc = new Scanner(System.in)

  val n = sc.nextInt()
  val x = sc.nextLong()
  val y = sc.nextLong()

  for (i <- 1 to n) {
    val s = sc.nextLong()

    val t = bs(s)

    Console.println {
      (t % x == 0, t % y == 0) match {
        case (true, true) => "Both"
        case (true, false) => "Vova"
        case (false, true) => "Vanya"
        case _ => throw new RuntimeException(t.toString)
      }
    }
  }
}

import java.util.Scanner

object D extends App {
  def cnt(t: Long) = t * x / (x * y) + t * y / (x * y)
  val sc = new Scanner(System.in)

  val n = sc.nextInt()
  val x = sc.nextLong()
  val y = sc.nextLong()

  for (i <- 1 to n) {
    val s = sc.nextLong()

    var t = s * x * y / (x + y)
    while (cnt(t) < s) t += 1

    Console.println {
      (t % x == 0, t % y == 0) match {
        case (true, true) => "Both"
        case (true, false) => "Vanya"
        case (false, true) => "Vasya"
        case _ => throw new RuntimeException(t.toString)
      }
    }
  }
}


import scala.io._
import java.util.StringTokenizer
import java.io.BufferedReader

object Main {

    def main(args: Array[String]): Unit = {
        val N = nextInt
        val K = nextInt
        (K+1) to 1 by -1 foreach println
        (K+2) to N foreach println
    }

    class Tokenizer(in: BufferedReader, splitOn: String = " \n\t\r\f")
    {
        private var tokenizer = new StringTokenizer("")
        def readLine() = in.readLine()
        def nextToken(): String = {
            while (!tokenizer.hasMoreTokens) {
                val line = readLine
                if (line == null) return null
                tokenizer = new StringTokenizer(line, splitOn)
            }
            tokenizer.nextToken
        }
        def next[A](f: String => A) = f(nextToken)
        def nextSeq[A](f: () => A, count: Int) = (for (i <- 0 until count) yield f())
    }

    implicit val tokenizer = new Tokenizer(Console.in)

    def nextInt()(implicit t: Tokenizer) = t.next(_.toInt)
    def nextLong()(implicit t: Tokenizer) = t.next(_.toLong)
    def nextDouble()(implicit t: Tokenizer) = t.next(_.toDouble)
    def nextBigInt()(implicit t: Tokenizer) = t.next(BigInt(_))
    def nextSeq[A](f: () => A, count: Int = nextInt())(implicit t: Tokenizer) =
        (for (i <- 0 until count) yield f())
}

import annotation.tailrec
import java.io._

object Easy {
  val reader = new BufferedReader(new InputStreamReader(System.in))
  def readInts = reader.readLine().split(" ").map(_.toInt)
  def readInt = reader.readLine().toInt

  val Array(n, k) = readInts
  def ans = ((n to (n - k + 1)).by(-1) ++ (1 to n - k)).mkString(" ")

  def main(args: Array[String]) {
    println(ans)
  }
}

object Main {
  def main(args: Array[String]) {
    val nm = readLine().split(" ").map(_.toInt)
    val n = nm(0)
    val m = nm(1)
    val a = (1 to n)
    val (head, tail) = a.splitAt(n - m - 1)
    println((head ++ tail.reverse).mkString(" "))
  }
}

import java.util.Scanner

object Main {

  def main(args: Array[String]): Unit = {
     var scan = new Scanner(System.in)
     val n = scan.nextInt()
     val k = scan.nextInt()
     val p = List.range(1, n + 1)
     val sorted = p.sorted(Ordering[Int].reverse)
     val (first, second) = sorted.splitAt(n - k - 1)
     val ans = second ::: first.sorted(Ordering[Int])
     val sb = new StringBuilder()
     ans.foreach(x => sb.append(x + " "))
     println(sb)
  }

}

object CF285A {
    def main(argv: Array[String]) {
        val in = new java.util.Scanner(System.in)
        val out = new java.io.PrintWriter(System.out)
        val n = in.nextInt
        val k = in.nextInt
        val d = n - k - 1
        val ans = (1 to d) ++ (n until d by -1)
        out.println(ans.mkString(" "))
        out.close
    }
}

import java.util.StringTokenizer

object _285A extends App {
  var token = new StringTokenizer("")
  def next = {
    while (!token.hasMoreTokens()) token = new StringTokenizer(readLine)
    token.nextToken()
  }
  val n = next.toInt
  val k = next.toInt
  val a = (1 to n).toArray

  def reverse(l: Int, r: Int): Unit = {
    if (l < r) {
      val cb = a(l)
      a(l) = a(r)
      a(r) = cb
      reverse(l + 1, r - 1)
    }
  }

  reverse(0, k)
  println(a.mkString(" "))
}

object Solution extends App {
  val in = scala.io.Source.stdin.getLines()
  val Array(n, k) = in.next().split(" ").map(_.toInt)
  val r = (n to n - k + 1 by -1).toList ::: (1 until (n - k + 1)).toList
  println(r.mkString(" "))
}

object A285 {

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

  def main(args: Array[String]): Unit = {
    val Array(n, k) = readInts(2)
    val in = (1 to n).toArray
    val res = in.takeRight(k).reverse ++ in.take(n-k)
    println(res.mkString(" "))
  }

  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 CF285A extends App {
  val in = new java.util.Scanner(System.in)
  val out = new java.io.PrintWriter(System.out)

  val n = in.nextInt
  val k = in.nextInt
  val e = n-k;
  val sol = (n until e by -1) ++ (1 to e)
  out.println(sol.mkString(" "))

  out.close
}

import java.util.Scanner
import java.io.PrintWriter
import scala.annotation.tailrec
import scala.collection.mutable
import scala.util.Random

object P285A extends App {
  val sc = new Scanner(System.in)
  val out = new PrintWriter(System.out)

  val N, K = sc.nextInt

  val answer = {
    List.range(N, N - K, -1) ++ List.range(1, N - K + 1)
  }.mkString(" ")

  out.println(answer)
  out.close
}

object SlightlyDecreasingPermutations extends App {
	var n: Int = 0;
	var k: Int = 0;
	val inputPattern = "(\\d+) (\\d+)".r;
	val inputPattern(tmpN,tmpK) = readLine;
	n = tmpN.toInt;
	k = tmpK.toInt;

//  StringBuilder sb = new StringBuilder(n*2);
	var s: StringBuilder = new StringBuilder();
	for (i <- n until n-k by -1) {
	  s.append(i+" ");
	}

	for (i <- 1 to n-k) {
	  s.append(i+" ");
	}

	println(s.substring(0, s.length()-1));
}

import java.util.StringTokenizer

object _285A extends App {
  var token = new StringTokenizer("")
  def next = {
    while (!token.hasMoreTokens()) token = new StringTokenizer(readLine)
    token.nextToken()
  }
  val n = next.toInt
  val k = next.toInt
  val a = (1 to n).toArray

  def reverse(l: Int, r: Int): Unit = {
    if (l < r) {
      val cb = a(l)
      a(l) = a(r)
      a(r) = cb
    }
  }

  reverse(0, k)
  println(a.mkString(" "))
}

object Solution extends App {
  val in = scala.io.Source.stdin.getLines()
  val Array(n, k) = in.next().split(" ").map(_.toInt)
  val r = (k + 1 to n).toList ::: (1 until (k)).toList ::: List(k)
  println(r.mkString(" "))
}

object Solution extends App {
  val in = scala.io.Source.stdin.getLines()
  val Array(n, k) = in.next().split(" ").map(_.toInt)
  val r = (n - k + 1 to n).toList ::: List(n - k) ::: (1 until (n - k)).toList
  println(r.mkString(" "))
}

object Solution extends App {
  val in = scala.io.Source.stdin.getLines()
  val Array(n, k) = in.next().split(" ").map(_.toInt)
  val r = (n to k + 2 by -1).toList ::: (1 until (k + 2)).toList
  println(r.mkString(" "))
}

object Solution extends App {
  val in = scala.io.Source.stdin.getLines()
  val Array(n, k) = in.next().split(" ").map(_.toInt)
  val r = (n - k + 1 to n).toList ::: (1 until (n - k)).toList ::: List(n - k)
  println(r.mkString(" "))
}

object Solution extends App {
  val in = scala.io.Source.stdin.getLines()
  val Array(n, k) = in.next().split(" ").map(_.toInt)
  val r = (1 until (n - k)).toList ::: (n - k + 1 to n).toList ::: List(n - k)
  println(r.mkString(" "))
}

import scala.io._
import java.util.StringTokenizer
import java.io.BufferedReader

object Main {

    def main(args: Array[String]): Unit = {
        val N = nextInt
        val K = nextInt
        1 to (N - K) foreach println
        N to K by -1 foreach println
    }

    class Tokenizer(in: BufferedReader, splitOn: String = " \n\t\r\f")
    {
        private var tokenizer = new StringTokenizer("")
        def readLine() = in.readLine()
        def nextToken(): String = {
            while (!tokenizer.hasMoreTokens) {
                val line = readLine
                if (line == null) return null
                tokenizer = new StringTokenizer(line, splitOn)
            }
            tokenizer.nextToken
        }
        def next[A](f: String => A) = f(nextToken)
        def nextSeq[A](f: () => A, count: Int) = (for (i <- 0 until count) yield f())
    }

    implicit val tokenizer = new Tokenizer(Console.in)

    def nextInt()(implicit t: Tokenizer) = t.next(_.toInt)
    def nextLong()(implicit t: Tokenizer) = t.next(_.toLong)
    def nextDouble()(implicit t: Tokenizer) = t.next(_.toDouble)
    def nextBigInt()(implicit t: Tokenizer) = t.next(BigInt(_))
    def nextSeq[A](f: () => A, count: Int = nextInt())(implicit t: Tokenizer) =
        (for (i <- 0 until count) yield f())
}

import scala.io._
import java.util.StringTokenizer
import java.io.BufferedReader

object Main {

    def main(args: Array[String]): Unit = {
        val N = nextInt
        val K = nextInt
        K to 1 by -1 foreach println
        (K+1) to N foreach println
    }

    class Tokenizer(in: BufferedReader, splitOn: String = " \n\t\r\f")
    {
        private var tokenizer = new StringTokenizer("")
        def readLine() = in.readLine()
        def nextToken(): String = {
            while (!tokenizer.hasMoreTokens) {
                val line = readLine
                if (line == null) return null
                tokenizer = new StringTokenizer(line, splitOn)
            }
            tokenizer.nextToken
        }
        def next[A](f: String => A) = f(nextToken)
        def nextSeq[A](f: () => A, count: Int) = (for (i <- 0 until count) yield f())
    }

    implicit val tokenizer = new Tokenizer(Console.in)

    def nextInt()(implicit t: Tokenizer) = t.next(_.toInt)
    def nextLong()(implicit t: Tokenizer) = t.next(_.toLong)
    def nextDouble()(implicit t: Tokenizer) = t.next(_.toDouble)
    def nextBigInt()(implicit t: Tokenizer) = t.next(BigInt(_))
    def nextSeq[A](f: () => A, count: Int = nextInt())(implicit t: Tokenizer) =
        (for (i <- 0 until count) yield f())
}


//package me.jetblack.cf

import java.util.Scanner

object PowerUsage extends App {

  val s = new Scanner(System.in)

  import s._

  val (n, p1, p2, p3, t1, t2) = (nextInt(), nextInt(), nextInt(), nextInt(), nextInt(), nextInt())
  var intervals = (0 until n).map(_ => (nextInt(), nextInt()))
  intervals = intervals ++ List((intervals.last._2, intervals.last._2))
  var pow = 0

  for (
    (i1, i2) :: (i3, i4) :: _ <- intervals.sliding(2).toList.map(_.toList)
  ) yield {
    pow += p1 * (i2 - i1)
    //pow += p1 * (i4 - i3)
    val d = i3 - i2
    if (d > t1) {
      pow += t1 * p1
      val d1 = d - t1
      if (d1 > t2) {
        pow += t2 * p2
        val d2 = (d1 - t2)
        pow += d2 * p3
      } else {
        pow += d1 * p2
      }
    } else {
      pow += d * p1
    }
  }

  println(pow)

}

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

object A {

  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 p1 = nextInt
    val p2 = nextInt
    val p3 = nextInt
    val t1 = nextInt
    val t2 = nextInt
    var result = 0
    var prev = 0
    for (i <- 0 until n) {
      val l = nextInt
      val r = nextInt
      if (i == 0) {
        prev = l
      }
      result += (r - l) * p1
      if (l - t1 > prev) {
        result += t1 * p1
        if (l - t1 - t2 > prev) {
          result += t2 * p2
          result += (l - t1 - t2 - prev) * p3
        } else {
          result += (l - prev - t1) * p2
        }
      } else {
        result += (l - prev) * p1
      }
      prev = r
    }
    out.println(result)
  }

  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 PowerUsage extends App {

  val s = new Scanner(System.in)

  import s._

  val (n, p1, p2, p3, t1, t2) = (nextInt(), nextInt(), nextInt(), nextInt(), nextInt(), nextInt())
  var intervals = (0 until n).map(_ => (nextInt(), nextInt()))
  if (intervals.size == 1) {
    intervals = intervals ++ List((intervals.head._2, intervals.head._2))
  }
  var pow = 0

  for (
    Seq((i1, i2), (i3, i4)) <- intervals.sliding(2).toSeq
  ) yield {
    pow += p1 * (i2 - i1)
    pow += p1 * (i4 - i3)
    val d = i3 - i2
    if (d > t1) {
      pow += t1 * p1
      val d1 = d - t1
      if (d1 > t2) {
        pow += t2 * p2
        val d2 = (d1 - t2)
        pow += d2 * p3
      } else {
        pow += d1 * p2
      }
    } else {
      pow += d * p1
    }
  }

  println(pow)

}


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

object _677C extends CodeForcesApp {
  override def apply(io: IO) = {
    val s = io[String]
    val num = s map {c =>
      if(c >= '0' && c <= '9') {
        c - '0' + 0
      } else if (c >= 'A' && c <= 'Z') {
        c - 'A' + 10
      } else if (c >= 'a' && c <= 'z') {
        c - 'a' + 36
      } else if (c == '-') {
        62
      } else {
        63
      }
    }
    val ans = num.foldLeft(BigInt(1)) {case (p, n) =>
      val zeroes = 6 - n.bitCount
      val choices = BigInt(3).modPow(zeroes, mod)
      (p * choices) mod mod
    }

    io += 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 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 = t.head.ensuring(t.size == 1)
    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
  }
  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 PairsExtensions[A, B, C[X] <: Traversable[X]](t: C[(A, B)]) {
    def toUniqueMap: Map[A, B] = t.groupByIdentifier(_._1).mapValues(_._2)
    def toMultiMap(implicit b: C of B): Map[A, C[B]] = t.groupBy(_._1).mapValues(_.map(_._2).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 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 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 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
  }
  implicit class LongExtensions(val x: Long) extends AnyVal {
    def bitCount: Int = java.lang.Long.bitCount(x)
  }
  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(n.min(x, y), n.max(x, y), n.one)
  }
  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] = Dict.empty[K, V] withDefaultValue default // also to(Dict.empty[K2, V])
  }
  def memoize[A, B](f: A => B): collection.Map[A, B] = new mutable.HashMap[A, B]() {
    override def apply(key: A) = getOrElseUpdate(key, f(key))
  }
  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
  }
  @inline 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)
  type of[C[_], A] = scala.collection.generic.CanBuild[A, C[A]]
  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 PrintWriter(out, true) with Iterator[String] {
  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

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

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

  def vector[A: IO.Read](n: Int): Vector[A] = apply[Vector, A](n)

  def till(delim: String): String = tokenizer().get.nextToken(delim)
  def tillEndOfLine(): String = till("\n\r")

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

  var separator = " "
  private[this] var isNewLine = true

  def +=[A](x: A)(implicit write: IO.Write[A]): this.type = {
    write(this)(x)
    this
  }
  def ++=[A: IO.Write](xs: Traversable[A]): this.type = (this += xs.size) appendNewLine xs

  def appendNewLine[A: IO.Write](x: A): this.type = {
    println()
    this += x
  }

  override def print(obj: String) = {
    if (isNewLine) isNewLine = false else super.print(separator)
    super.print(obj)
  }
  override def println() = if (!isNewLine) {
    super.println()
    isNewLine = true
  }
  override def close() = {
    flush()
    in.close()
    super.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[C, A](r[Int]))
    implicit val string                                       : Read[String]       = new Read(_.next())
    implicit val char                                         : Read[Char]         = string.map(_.toTraversable.onlyElement)
    implicit val boolean                                      : Read[Boolean]      = string.map(_.toBoolean)
    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[A], r[B]))
    implicit def tuple3[A: Read, B: Read, C: Read]            : Read[(A, B, C)]    = new Read(r => (r[A], r[B], r[C]))
    implicit def tuple4[A: Read, B: Read, C: Read, D: Read]   : Read[(A, B, C, D)] = new Read(r => (r[A], r[B], r[C], r[D]))
  }
  trait Write[-A] {
    def apply(out: PrintWriter)(x: A): Unit
  }
  trait DefaultWrite {
    implicit def any[A]: Write[A] = Write(_.toString)
  }
  object Write extends DefaultWrite {
    def apply[A](f: A => String) = new Write[A] {
      override def apply(out: PrintWriter)(x: A) = out.print(f(x))
    }
    implicit val boolean: Write[Boolean] = Write(b => if (b) "YES" else "NO")
    implicit def tuple2[A, B]: Write[(A, B)] = Write {case (a, b) => s"$a $b"}
    implicit def array[A]: Write[Array[A]] = Write(_ mkString " ")
    implicit def iterable[A](implicit write: Write[A]): Write[Traversable[A]] = new Write[Traversable[A]] {
      override def apply(out: PrintWriter)(xs: Traversable[A]) = {
        xs foreach write(out)
        out.println()
      }
    }
  }
}

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

object _677C extends CodeForcesApp {
  override def apply(io: IO) = {
    val s = io[String]
    val num = s map {c =>
      if(c >= '0' && c <= '9') {
        c - '0' + 0
      } else if (c >= 'A' && c <= 'Z') {
        c - 'A' + 10
      } else if (c >= 'a' && c <= 'z') {
        c - 'a' + 36
      } else if (c == '-') {
        62
      } else {
        63
      }
    }
    val zeroes = num.sumWith(i => 6 - i.bitCount)
    io += BigInt(3).modPow(zeroes, mod)
  }
}
/****************************[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 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 = t.head.ensuring(t.size == 1)
    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
  }
  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 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
  }
  implicit class IntExtensions(val x: Int) extends AnyVal {
    def bitCount: Int = java.lang.Integer.bitCount(x)
  }
  implicit class LongExtensions(val x: Long) extends AnyVal {
    def bitCount: Int = java.lang.Long.bitCount(x)
  }
  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(n.min(x, y), n.max(x, y), 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] = Dict.empty[K, V] withDefaultValue default // also to(Dict.empty[K2, V])
  }
  def memoize[A, B](f: A => B): collection.Map[A, B] = new mutable.HashMap[A, B]() {
    override def apply(key: A) = getOrElseUpdate(key, f(key))
  }
  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
  }
  @inline 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)
  type of[C[_], A] = scala.collection.generic.CanBuild[A, C[A]]
  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 PrintWriter(out, true) with Iterator[String] {
  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

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

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

  def till(delim: String): String = tokenizer().get.nextToken(delim)
  def tillEndOfLine(): String = till("\n\r")

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

  var separator = " "
  private[this] var isNewLine = true

  def +=[A](x: A)(implicit write: IO.Write[A]): this.type = {
    write(this)(x)
    this
  }
  def ++=[A: IO.Write](xs: Traversable[A]): this.type = (this += xs.size) appendNewLine xs

  def appendNewLine[A: IO.Write](x: A): this.type = {
    println()
    this += x
  }

  override def print(obj: String) = {
    if (isNewLine) isNewLine = false else super.print(separator)
    super.print(obj)
  }
  override def println() = if (!isNewLine) {
    super.println()
    isNewLine = true
  }
  override def close() = {
    flush()
    in.close()
    super.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[C, A](r[Int]))
    implicit val string                                       : Read[String]       = new Read(_.next())
    implicit val char                                         : Read[Char]         = string.map(_.toTraversable.onlyElement)
    implicit val boolean                                      : Read[Boolean]      = string.map(_.toBoolean)
    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[A], r[B]))
    implicit def tuple3[A: Read, B: Read, C: Read]            : Read[(A, B, C)]    = new Read(r => (r[A], r[B], r[C]))
    implicit def tuple4[A: Read, B: Read, C: Read, D: Read]   : Read[(A, B, C, D)] = new Read(r => (r[A], r[B], r[C], r[D]))
  }
  trait Write[-A] {
    def apply(out: PrintWriter)(x: A): Unit
  }
  trait DefaultWrite {
    implicit def any[A]: Write[A] = Write(_.toString)
  }
  object Write extends DefaultWrite {
    def apply[A](f: A => String) = new Write[A] {
      override def apply(out: PrintWriter)(x: A) = out.print(f(x))
    }
    implicit val boolean: Write[Boolean] = Write(b => if (b) "YES" else "NO")
    implicit def tuple2[A, B]: Write[(A, B)] = Write {case (a, b) => s"$a $b"}
    implicit def array[A]: Write[Array[A]] = Write(_ mkString " ")
    implicit def iterable[A](implicit write: Write[A]): Write[Traversable[A]] = new Write[Traversable[A]] {
      override def apply(out: PrintWriter)(xs: Traversable[A]) = {
        xs foreach write(out)
        out.println()
      }
    }
  }
}


/**
 * Author: Oleg Nizhnik
 * Date  : 14.04.2015
 * Time  : 16:01
 */

import scala.io.StdIn

object A extends App {
  val studs = StdIn.readInt() match {
    case 1 | 2 => List(1)
    case 3 => List(1, 3)
    case 4 => List(3, 1, 4, 2)
    case n if n % 2 == 1 => 1 to 2 * n by 2 map (_ % n + 1)
    case n => (1 to n by 2) ++ (2 to n by 2)
  }
  println(studs.length)
  println(studs mkString " ")
}

object A524 extends App{

 var k = readInt
 var str = new StringBuilder
 k
  match {
   case 1 | 2 => println(1); println(1)
   case 3 => println(2); println(1 + " " + 3)
   case 4 => println(4); println("3 1 4 2")
   case 5 => println(5); println("1 4 2 5 3")
   case _ =>
     if (k % 2 == 0) {
       str.append(k + "\n")
       for (i <- 1 until k / 2 + 1)
         str.append(i + " " + (k/2 + i) + " ")
     }
     else {
       k -= 1
       str.append((k + 1) + "\n" + (k + 1) + " ")
       for (i <- 1 until k / 2 + 1)
         str.append(i + " " + (k/2 + i) + " ")
     }

     println(str.toString)
 }
}

import java.io._

object Main {

  val in = new BufferedReader(new InputStreamReader(System.in))
  val out = new PrintWriter(System.out)

  sys.addShutdownHook(out.close())

  @inline def nextInt = in.readLine().toInt
  @inline def nextInts = in.readLine().split(" +").map(_.toInt)
  @inline def println[T](x: T) = out.println(x)
  @inline def print[T](x: T) = out.print(x)

  def main(args: Array[String]): Unit = {
    val n = nextInt

    if (n <= 2)
      println("1\n1")
    else if (n == 3)
      println("2\n1 3")
    else {
      println(n)
      for (i ← (n + 1) / 2 to 1 by -1) print(s"${i + i - 1} ")
      for (i ← n / 2 to 1 by -1) print(s"${i + i} ")
    }
  }
}

object A534 {

  import IO._

  def main(args: Array[String]): Unit = {
    val Array(n) = readInts(1)
    if(n <= 2) {
      println("1")
      println("1")
    } else if(n == 3){
      println("2")
      println("1 3")
    } else if(n == 4){
      println("4")
      println("3 1 4 2")
    } else {
      println(n)
      println(((1 to n by 2) ++ (2 to n by 2)).mkString(" "))
    }
  }

  object IO {
    @inline def read: String = scala.io.StdIn.readLine

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

    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))
    }
  }

}

/**
 *
 * Created by ronaflx on 15-4-3.
 */

import java.io._
import java.util.StringTokenizer;
import Ordering.Implicits._;

object Codeforces {
  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)
    }
    st.nextToken
  }

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

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

  def upperBound[T: Ordering](array: Array[T], value: T) = {
    var low = 0
    var high = array.length
    var res = array.length
    while (low <= high) {
      val mid = (low + high) / 2
      if (value < array(mid)) {
        res = mid
        high = mid - 1
      } else {
        low = mid + 1
      }
    }
    res
  }

  def solve(): Unit = {
    val n = nextInt
    println(if (n <= 3) (n + 1) / 2 else n)
    for (i <- Range(if ((n & 1) == 1) n else n - 1, 0, -2))
      print(i + " ")
    if (n >= 4) for (i <- Range(if ((n & 1) == 0) n else n - 1, 0, -2)) print(i + " ")
  }

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

object _534_A extends App {
  import java.util.Scanner

  import scala.collection.mutable

  lazy val file = getClass.getResourceAsStream(s"${getClass.getSimpleName.replace("$", "").last}.in")
  val in = if (submit) new Scanner(System.in) else new Scanner(file)

  while(in.hasNext) println(apply(parseInput))
  /******************************************************************************************************/
  def submit = true        // THIS MUST BE TRUE WHEN YOU SUBMIT !!!!

  type Input = Int

  def parseInput: Input = {
    import in._
    nextInt()
  }

  def apply(input: Input) = {
    val solution = input match {
      case 1 => List(1)
      case 2 => List(1)
      case 3 => List(1, 3)
      case 4 => List(3, 1, 4, 2)
      case n => List.tabulate((n+1)/2)(i => 2*i + 1) ++ List.tabulate(n/2)(i => 2*i + 2)
    }
    s"${solution.size}\n${solution mkString " "}"
  }
}

object A524 extends App{

 var k = readInt
 var str = new StringBuilder
 k
  match {
   case 1 | 2 => println(1); println(1)
   case 3 | 4 => println(2); println(1 + " " + 3)
   case 5 => println(5); println("1 4 2 5 3")
   case _ =>
     if (k % 2 == 0) {
       str.append(k + "\n")
       for (i <- 1 until k / 2 + 1)
         str.append(i + " " + (k/2 + i) + " ")
     }
     else {
       k -= 1
       str.append((k + 1) + "\n" + (k + 1) + " ")
       for (i <- 1 until k / 2 + 1)
         str.append(i + " " + (k/2 + i) + " ")
     }

     println(str.toString)
 }
}

import java.io._

object Main {

  val in = new BufferedReader(new InputStreamReader(System.in))
  val out = new PrintWriter(System.out)

  sys.addShutdownHook(out.close())

  @inline def nextInt = in.readLine().toInt
  @inline def nextInts = in.readLine().split(" +").map(_.toInt)
  @inline def println[T](x: T) = out.println(x)
  @inline def print[T](x: T) = out.print(x)

  def main(args: Array[String]): Unit = {
    val n = nextInt

    val used = collection.mutable.Set[Int](1)
    var ans: List[Int] = 1 :: Nil

    for (i ← 1 to n) {
      for (j ← 1 to n) {
        if (!(used contains j) && Math.abs(j - ans.head) > 1) {
          used += j
          ans = j :: ans
        }
      }
    }

    println(ans.length)
    println(ans.mkString(" "))
  }
}

import java.io._

object Main {

  val in = new BufferedReader(new InputStreamReader(System.in))
  val out = new PrintWriter(System.out)

  sys.addShutdownHook(out.close())

  @inline def nextInt = in.readLine().toInt
  @inline def nextInts = in.readLine().split(" +").map(_.toInt)
  @inline def println[T](x: T) = out.println(x)
  @inline def print[T](x: T) = out.print(x)

  def main(args: Array[String]): Unit = {
    val n = nextInt

    val used = collection.mutable.Set[Int](1)
    var ans: List[Int] = 1 :: Nil

    for (i ← 1 to n) {
      var done = false
      for (j ← 1 to n) {
        if (!done && !(used contains j) && Math.abs(j - ans.head) > 1) {
          used += j
          done = true
          ans = j :: ans
        }
      }
    }

    println(ans.length)
    println(ans.mkString(" "))
  }
}

/**
 * Author: Oleg Nizhnik
 * Date  : 14.04.2015
 * Time  : 16:01
 */
import scala.io.StdIn

object A extends App {
  val studs = StdIn.readInt() match {
    case 1 | 2 => Nil
    case 3 => List(1, 3)
    case 4 => List(3, 1, 4, 2)
    case n if n % 2 == 1 => 1 to 2 * n by 2 map (_ % n)
    case n => (1 to n by 2) ++ (2 to n by 2)
  }
  println(studs.length)
  println(studs mkString " ")
}

/**
 * Author: Oleg Nizhnik
 * Date  : 14.04.2015
 * Time  : 16:01
 */

import scala.io.StdIn

object A extends App {
  val studs = StdIn.readInt() match {
    case 1 => Nil
    case 2 => List(1)
    case 3 => List(1, 3)
    case 4 => List(3, 1, 4, 2)
    case n if n % 2 == 1 => 1 to 2 * n by 2 map (_ % n + 1)
    case n => (1 to n by 2) ++ (2 to n by 2)
  }
  println(studs.length)
  println(studs mkString " ")
}

/**
 * Author: Oleg Nizhnik
 * Date  : 14.04.2015
 * Time  : 16:01
 */
import scala.io.StdIn

object A extends App {
  val studs = StdIn.readInt() match {
    case 1 | 2 => Nil
    case 3 => List(1, 3)
    case 4 => List(3, 1, 4, 2)
    case n if n % 2 == 1 => 1 to 2 * n by 2 map (_ % n + 1)
    case n => (1 to n by 2) ++ (2 to n by 2)
  }
  println(studs.length)
  println(studs mkString " ")
}

/**
 *
 * Created by ronaflx on 15-4-3.
 */

import java.io._
import java.util.StringTokenizer;
import Ordering.Implicits._;

object Codeforces {
  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)
    }
    st.nextToken
  }

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

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

  def upperBound[T: Ordering](array: Array[T], value: T) = {
    var low = 0
    var high = array.length
    var res = array.length
    while (low <= high) {
      val mid = (low + high) / 2
      if (value < array(mid)) {
        res = mid
        high = mid - 1
      } else {
        low = mid + 1
      }
    }
    res
  }

  def solve(): Unit = {
    val n = nextInt
    println(if (n <= 4) (n + 1) / 2 else n)
    for (i <- Range(1, n + 1, 2))
      print(i + " ")
    if (n > 4) for (i <- Range(2, n + 1, 2)) print(i + " ")
  }

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

/**
 *
 * Created by ronaflx on 15-4-3.
 */

import java.io._
import java.util.StringTokenizer;
import Ordering.Implicits._;

object Codeforces {
  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)
    }
    st.nextToken
  }

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

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

  def upperBound[T: Ordering](array: Array[T], value: T) = {
    var low = 0
    var high = array.length
    var res = array.length
    while (low <= high) {
      val mid = (low + high) / 2
      if (value < array(mid)) {
        res = mid
        high = mid - 1
      } else {
        low = mid + 1
      }
    }
    res
  }

  def solve(): Unit = {
    val n = nextInt
    for (i <- Range(1, n + 1, 2))
      print(i + " ")
    if (n > 4) for (i <- Range(2, n + 1, 2)) print(i + " ")
  }

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

/**
 *
 * Created by ronaflx on 15-4-3.
 */

import java.io._
import java.util.StringTokenizer;
import Ordering.Implicits._;

object Codeforces {
  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)
    }
    st.nextToken
  }

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

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

  def upperBound[T: Ordering](array: Array[T], value: T) = {
    var low = 0
    var high = array.length
    var res = array.length
    while (low <= high) {
      val mid = (low + high) / 2
      if (value < array(mid)) {
        res = mid
        high = mid - 1
      } else {
        low = mid + 1
      }
    }
    res
  }

  def solve(): Unit = {
    val n = nextInt
    println(if (n <= 4) n / 2 else n)
    for (i <- Range(1, n + 1, 2))
      print(i + " ")
    if (n > 4) for (i <- Range(2, n + 1, 2)) print(i + " ")
  }

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

object _534_A extends App {
  import java.util.Scanner

  import scala.collection.mutable

  lazy val file = getClass.getResourceAsStream(s"${getClass.getSimpleName.replace("$", "").last}.in")
  val in = if (submit) new Scanner(System.in) else new Scanner(file)

  while(in.hasNext) println(apply(parseInput))
  /******************************************************************************************************/
  def submit = true        // THIS MUST BE TRUE WHEN YOU SUBMIT !!!!

  type Input = Int

  def parseInput: Input = {
    import in._
    nextInt()
  }

  def apply(input: Input) = {
    val solution = input match {
      case 1 => List(1)
      case 2 => List(1)
      case 3 => List(1, 3)
      case 4 => List(1, 4, 2)
      case n => List.tabulate((n+1)/2)(i => 2*i + 1) ++ List.tabulate(n/2)(i => 2*i + 2)
    }
    s"${solution.size}\n${solution mkString " "}"
  }
}

object _534_A extends App {
  import java.util.Scanner

  import scala.collection.mutable

  lazy val file = getClass.getResourceAsStream(s"${getClass.getSimpleName.replace("$", "").last}.in")
  val in = if (submit) new Scanner(System.in) else new Scanner(file)

  while(in.hasNext) println(apply(parseInput))
  /******************************************************************************************************/
  def submit = true        // THIS MUST BE TRUE WHEN YOU SUBMIT !!!!

  type Input = Int

  def parseInput: Input = {
    import in._
    nextInt()
  }

  def apply(input: Input) = {
    val solution = input match {
      case 1 => List(1)
      case 2 => List(1)
      case 3 => List(1, 3)
      case 4 => List(1, 4, 2, 3)
      case n => List.tabulate((n+1)/2)(i => 2*i + 1) ++ List.tabulate(n/2)(i => 2*i + 2)
    }
    s"${solution.size}\n${solution mkString " "}"
  }
}