module mod_two_dim_merge_sort
  implicit none
  integer, private, parameter :: intkind = 4
contains
  logical function less(a, b) result(res)
    integer(intkind), intent(in) :: a(:), b(:)
    res = a(1) < b(1) .or. (a(1) == b(1) .and. a(2) <= b(2))
  end
  subroutine merge_sort(a)
    integer(intkind), intent(inout) :: a(:, :)
    integer :: n, m, l, i, u
    n = size(a, 1)
    m = n
    l = 1
    do while (m > 1)
      do i = 1, m / 2
        u = min(2 * i * l, n)
        call merger(a(2 * (i - 1) * l + 1:(2 * i - 1) * l, :), &
        a((2 * i - 1) * l + 1:u, :))
      end do
      l = 2 * l
      m = (m + 1) / 2
    end do
  end
  subroutine merger(a1, a2)
    integer(intkind), intent(inout) :: a1(:, :), a2(:, :)
    integer(intkind) :: a(size(a1, 1) + size(a2, 1), size(a1, 2))
    integer :: i1, i2, n1, n2
    i1 = 1
    i2 = 1
    n1 = size(a1, 1)
    n2 = size(a2, 1)
    do while (i1 <= n1 .and. i2 <= n2)
      if (less(a1(i1, :), a2(i2, :))) then
        a(i1 + i2 - 1, :) = a1(i1, :)
        i1 = i1 + 1
      else
        a(i1 + i2 - 1, :) = a2(i2, :)
        i2 = i2 + 1
       end if
    end do
    if (i1 <= n1) then
      a(i1 + i2 - 1:n1 + n2, :) = a1(i1:n1, :)
    else
      a(i1 + i2 - 1:n1 + n2, :) = a2(i2:n2, :)
    end if
    a1 = a(1:n1, :)
    a2 = a(n1 + 1:n1 + n2, :)
  end
end module mod_two_dim_merge_sort
module mod_segment_tree
  implicit none
  integer, private, parameter :: intkind = 4
  type segment_tree
    integer(intkind) :: default = 0
    integer :: n, p
    integer(intkind), private, allocatable :: body(:)
  contains
    procedure :: init => init
    procedure :: update => update
    procedure :: query => query
  end type
  interface segment_tree
    module procedure :: newst0
  end interface segment_tree
contains
  integer(intkind) function op(x, y) result(res)
    integer(intkind), intent(in) :: x, y
    res = max(x, y)
  end
  type(segment_tree) function newst0(n, def) result(res)
    integer, intent(in) :: n
    integer(intkind), optional, intent(in) :: def
    integer :: p
    p = 1
    do while (p < n)
      p = lshift(p, 1)
    end do
    if (present(def)) res%default = def
    res%n = n
    res%p = p
    allocate(res%body(2 * p - 1))
    res%body = res%default
  end
  subroutine init(this, n, def)
    class(segment_tree), intent(inout) :: this
    integer, intent(in) :: n
    integer(intkind), optional, intent(in) :: def
    integer :: p
    p = 1
    do while (p < n)
      p = lshift(p, 1)
    end do
    if (present(def)) this%default = def
    this%n = n
    this%p = p
    allocate(this%body(2 * p - 1))
    this%body = this%default
  end
  subroutine update(this, i, v)
    class(segment_tree), intent(inout) :: this
    integer, intent(in) :: i
    integer(intkind), optional, intent(in) :: v
    integer :: x
    x = i + this%p - 1
    this%body(x) = merge(v, this%default, present(v))
    do while (x > 1)
      x = x / 2
      this%body(x) = op(this%body(2 * x), this%body(2 * x + 1))
    end do
  end
  integer(intkind) function query(this, a, b) result(res)
    class(segment_tree), intent(in) :: this
    integer, intent(in) :: a, b
    integer :: l, r
    res = this%default
    l = a + this%p - 1
    r = b + this%p - 1
    do while (l <= r)
      if (mod(l, 2) == 1) then
        res = op(res, this%body(l))
        l = l + 1
      end if
      if (mod(r, 2) == 0) then
        res = op(res, this%body(r))
        r = r - 1
      end if
      l = l / 2
      r = r / 2
    end do
  end
end module mod_segment_tree
program removing_robots
  use mod_segment_tree
  use mod_two_dim_merge_sort
  implicit none
  integer(8) :: modu = 998244353
  integer :: n, x(200000, 2) = 0, y, i, j, l, r, m, p(200000) = 0
  integer(8) :: dp(200001) = 0
  type(segment_tree) :: st
  read(*,*) n
  st = segment_tree(n)
  do i = 1, n
    read(*,*) x(i, 1:2)
    call st%update(i, i)
  end do
  call merge_sort(x(1:n, :))
  do i = n, 1, -1
    l = i
    r = n + 1
    y = x(i, 1) + x(i, 2)
    do while (r - l > 1)
      m = (l + r) / 2
      if (x(m, 1) < y) then
        l = m
      else
        r = m
      end if
    end do
    m = st%query(i, l)
    call st%update(i, m)
    p(i) = m
  end do
  dp(n + 1) = 1
  do i = n, 1, -1
    dp(i) = mod(dp(i + 1) + dp(p(i) + 1), modu)
  end do
  write(*,'(i0)') dp(1)
end program removing_robots