import scala.collection.mutable.{TreeSet, TreeMap}

object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val h, w = sc.nextInt()
  val ab = Array.fill(h)((sc.nextInt()-1, sc.nextInt()))

  val s = TreeMap[Int, Int]()
  val v = TreeSet[(Int, Int)]()
  for (i <- 0 until w) {
    s += i -> i
    v += ((0, i))
  }

  val pw = new java.io.PrintWriter(Console.out)
  for (k <- 0 until h) {
    val (a, b) = ab(k)
    val it = s.keysIteratorFrom(a)
    var mr = -1
    var continue = true
    while (it.hasNext && continue) {
      val e = it.next()
      if (e > b) {
        continue = false
      } else {
        mr = mr.max(s(e))
        v -= ((e - s(e), e))
        s -= e
      }
    }

    if (mr != -1 && b < w) {
      s += b -> mr
      v += ((b - mr, b))
    }

    if (v.isEmpty) {
      pw.println(-1)
    } else {
      pw.println(v.head._1 + k + 1)
    }
  }
  pw.flush()
}
