import algorithm, math, sets, sequtils, strutils, tables
when (NimMajor, NimMinor) == (0, 13):
  import future
else:
  import sugar

let read* = iterator: string {.closure.} =
  while true: (for s in stdin.readLine.split: yield s)

template input*(T: static[typedesc]): untyped = 
  when T is int: read().parseInt
  elif T is float: read().parseFloat
  elif T is string: read()

type
  MergeOperator*[T] = proc(a: T, b: T): T
  SegmentTree*[T] = object
    node: seq[T]
    identityElement: T
    internalNodeCount: Natural
    merge: MergeOperator[T]
 
proc initSegmentTree*[T](n: Natural, identityElement: T, merge: MergeOperator[T]): SegmentTree[T] =
  var n = nextPowerOfTwo(n)
  result.node = newSeqWith(2 * n, identityElement)
  result.identityElement = identityElement
  result.internalNodeCount = n - 1
  result.merge = merge

proc build*[T](self: var SegmentTree[T], data: openarray[T]) =
  for i in 1 .. data.high:
    self.node[self.internalNodeCount + i] = data[i]
  for i in countdown(self.internalNodeCount, 1):
    self.node[i] = self.merge(self.node[2 * i], self.node[2 * i + 1])

proc update*[T](self: var SegmentTree[T], x: Natural, value: T) =
  var i = x + self.internalNodeCount
  self.node[i] = value
  while i > 1:
    i = i shr 1
    self.node[i] = self.merge(self.node[2 * i], self.node[2 * i + 1])

proc fold*[T](self: var SegmentTree[T], l: Natural, r: Natural): T =
  var l = l + self.internalNodeCount
  var r = r + self.internalNodeCount + 1
  var leftResult = self.identityElement
  var rightResult = self.identityElement
  while l < r:
    if (l and 1) == 1:
      leftResult = self.merge(leftResult, self.node[l])
      inc l
    if (r and 1) == 1:
      dec r
      rightResult = self.merge(self.node[r], rightResult)
    l = l shr 1
    r = r shr 1
  result = self.merge(leftResult, rightResult)

# -------------------------------------------------- #

proc initPrimeList(N: int): seq[int] =
  result = newSeq[int]()
  var isPrime = newseq[bool](N + 1)
  for i in countup(2, N):
    isPrime[i] = true
  for i in countup(2, N.float.sqrt.int):
    if isPrime[i]:
      var j = 2
      while i * j <= N:
        isPrime[i * j] = false
        j += 1
  for p in countup(2, N):
    if isPrime[p]:
      result.add(p)

proc divisors(n: int, ps: seq[int]): HashSet[int] =
  result = initSet[int]()
  for m in 1 .. n:
    if m * m > n:
      break
    if n mod m == 0:
      result.incl(m)
      if m * m < n:
        result.incl(n div m)

let N, M = input(int)
let primes = initPrimeList(N)
var D = newSeqWith(M + 1, initSet[int]())
for i in 1 .. M:
  D[i] = divisors(i, primes)

var seg = initSegmentTree[HashSet[int]](
  M, initSet[int](), (A: HashSet[int], B: HashSet[int]) => (A + B)
)
seg.build(D)

var res = newSeq[int](M + 1)
for i in 1 .. N:
  let L, R = input(int)
  let ds = seg.fold(L, R)
  for d in ds:
    res[d] += 1
echo res[1 .. M].mapIt($it).join("\n")