output_description: Print the minimum possible number of subarrays after division of A.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
      A_1 A_2 ... A_N
attempt: n, l, T = map(int, input().split())
  s = [0 for i in range(n)]
  for i in range(n):
      s[i] = list(map(int, input().split()))
  
  
  def f(w):
      if w == 1:
          return 1
      elif w == 2:
          return -1
  
  
  t = 0
  d = l
  i_d = []
  
  while t < T:
      for i in range(n):
          if i < n - 1:
              if s[i][0] < s[i + 1][0] and s[i][1] == 1 and s[i + 1][1] == 2:
                  if s[i + 1][0] - s[i][0] < d:
                      d = s[i + 1][0] - s[i][0]
  
              elif s[i][0] > s[i + 1][0] and s[i][1] == 1 and s[i + 1][1] == 2:
                  if s[i + 1][0] + l - s[i][0] < d:
                      d = s[i + 1][0] + l - s[i][0]
  
          elif i == n - 1:
              if s[i][0] < s[0][0] and s[i][1] == 1 and s[0][1] == 2:
                  if s[0][0] - s[i][0] < d:
                      d = s[0][0] - s[i][0]
  
              elif s[i][0] > s[0][0] and s[i][1] == 1 and s[0][1] == 2:
                  if s[0][0] + l - s[i][0] < d:
                      d = s[0][0] + l - s[i][0]
  
      for i in range(n):
          if i < n - 1:
              if s[i][0] < s[i + 1][0] and s[i][1] == 1 and s[i + 1][1] == 2:
                  if s[i + 1][0] - s[i][0] == d:
                      i_d.append(i)
              elif s[i][0] > s[i + 1][0] and s[i][1] == 1 and s[i + 1][1] == 2:
                  if s[i + 1][0] + l - s[i][0] == d:
                      i_d.append(i)
  
          elif i == n - 1:
              if s[i][0] < s[0][0] and s[i][1] == 1 and s[0][1] == 2:
                  if s[0][0] - s[i][0] == d:
                      i_d.append(i)
  
              elif s[i][0] > s[0][0] and s[i][1] == 1 and s[0][1] == 2:
                  if s[0][0] + l - s[i][0] == d:
                      i_d.append(i)
  
      for j in range(n):
          if t + d / 2 <= T:
              s[j][0] += f(s[j][1]) * (d / 2)
              if s[j][0] >= l:
                  s[j][0] -= l
              elif s[j][0] < 0:
                  s[j][0] += l
  
          else:
              s[j][0] += f(s[j][1]) * (T - t)
              if s[j][0] >= l:
                  s[j][0] -= l
              elif s[j][0] < 0:
                  s[j][0] += l
      for j in i_d:
          if j < n - 1:
              s[j][1], s[j + 1][1] = s[j + 1][1], s[j][1]
          else:
              s[j][1], s[0][1] = s[0][1], s[j][1]
      t = t + d / 2
      i_d.clear()
      d = l
  
  for i in range(n):
      print(s[i][0])
  
problem_description: Statement
  
  You are given an array A of length N. Your task is to divide it into several
  contiguous subarrays. Here, all subarrays obtained must be sorted in either
  non-decreasing or non-increasing order. At least how many subarrays do you
  need to divide A into?
samples: [{"input": "6\n    1 2 3 2 2 1", "output": "2\n    \n\nOne optimal solution is to divide the array into [1,2,3] and [2,2,1].\n\n* * *"}, {"input": "9\n    1 2 1 2 1 2 1 2 1", "output": "5\n    \n\n* * *"}, {"input": "7\n    1 2 3 2 1 999999999 1000000000", "output": "3"}]