output_description: Print the smallest number of yen you have to spend to buy exactly N liters of
  ice tea.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      Q H S D
      N
attempt: import bisect
  import sys
  from math import atan
  
  
  def lis(L):
      if not L:
          return 0
      seq = [L[0]]
      for i in L[1:]:
          if seq[-1] < i:
              seq.append(i)
          else:
              seq[bisect.bisect_left(seq, i)] = i
      return len(seq)
  
  
  def mhd(x, y):
      return abs(x) + abs(y)
  
  
  x1, y1, x2, y2 = map(int, sys.stdin.readline().split())
  
  N = int(sys.stdin.readline())
  
  if x1 == x2 or y1 == y2:
      if x1 == x2:
          if y1 > y2:
              y1, y2 = y2, y1
          for _ in range(N):
              X, Y = map(int, sys.stdin.readline().split())
              if X != x1:
                  continue
              else:
                  if y1 <= Y <= y2:
                      print(100 * mhd(0, y1 - y2) - 20 + 40 * atan(1))
                      sys.exit()
                  else:
                      print(100 * mhd(0, y1 - y2))
                      sys.exit()
      else:
          if x1 > x2:
              x1, x2 = x2, x1
          for _ in range(N):
              X, Y = map(int, sys.stdin.readline().split())
              if Y != y1:
                  continue
              else:
                  if x1 <= X <= x2:
                      print(100 * mhd(x1 - x2, 0) - 20 + 40 * atan(1))
                      sys.exit()
                  else:
                      print(100 * mhd(x1 - x2, 0))
                      sys.exit()
  if x1 > x2:
      x1, x2 = x2, x1
      y1, y2 = y2, y1
  
  geta = 10**9 + 7
  B = []
  if y1 < y2:
      for _ in range(N):
          X, Y = map(int, sys.stdin.readline().split())
          if x1 <= X <= x2 and y1 <= Y <= y2:
              B.append(X * geta + Y)
      B.sort()
      B = [b % geta for b in B]
      lb = lis(B)
      if lb == min(abs(x1 - x2), abs(y1 - y2)) + 1:
          print(
              100 * mhd(x1 - x2, y1 - y2)
              + (lb - 1) * (20 * atan(1) - 20)
              + 40 * atan(1)
              - 20
          )
      else:
          print(100 * mhd(x1 - x2, y1 - y2) + lb * (20 * atan(1) - 20))
  
  else:
      for _ in range(N):
          X, Y = map(int, sys.stdin.readline().split())
          if x1 <= X <= x2 and y2 <= Y <= y1:
              B.append(X * geta - Y)
      B.sort()
      B = [b % geta for b in B]
      lb = lis(B)
      if lb == min(abs(x1 - x2), abs(y1 - y2)) + 1:
          print(
              100 * mhd(x1 - x2, y1 - y2)
              + (lb - 1) * (20 * atan(1) - 20)
              + 40 * atan(1)
              - 20
          )
      else:
          print(100 * mhd(x1 - x2, y1 - y2) + lb * (20 * atan(1) - 20))
  
problem_description: Statement
  
  You've come to your favorite store Infinitesco to buy some ice tea.
  
  The store sells ice tea in bottles of different volumes at different costs.
  Specifically, a 0.25-liter bottle costs Q yen, a 0.5-liter bottle costs H yen,
  a 1-liter bottle costs S yen, and a 2-liter bottle costs D yen. The store has
  an infinite supply of bottles of each type.
  
  You want to buy exactly N liters of ice tea. How many yen do you have to
  spend?
samples: [{"input": "20 30 70 90\n    3", "output": "150\n    \n\nBuy one 2-liter bottle and two 0.5-liter bottles. You'll get 3 liters for 90 +\n30 + 30 = 150 yen.\n\n* * *"}, {"input": "10000 1000 100 10\n    1", "output": "100\n    \n\nEven though a 2-liter bottle costs just 10 yen, you need only 1 liter. Thus,\nyou have to buy a 1-liter bottle for 100 yen.\n\n* * *"}, {"input": "10 100 1000 10000\n    1", "output": "40\n    \n\nNow it's better to buy four 0.25-liter bottles for 10 + 10 + 10 + 10 = 40 yen.\n\n* * *"}, {"input": "12345678 87654321 12345678 87654321\n    123456789", "output": "1524157763907942"}]