output_description: Print |a - b|.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
      P_1 P_2 ... P_N
      Q_1 Q_2 ... Q_N
attempt: n = int(input())
  p = list(map(int, input().split()))
  q = list(map(int, input().split()))
  a = 1
  b = 1
  n1 = 1
  for i in range(n):
      n1 = n1 * (i + 1)
  for i in range(n):
      t = 0
      i1 = 1
      for j in range(i + 1):
          i1 = i1 * (n - j)
      for j in range(n):
          if i < j and p[i] > p[j]:
              t += 1
      a += t * n1 // i1
  for i in range(n):
      t = 0
      i1 = 1
      for j in range(i + 1):
          i1 = i1 * (n - j)
      for j in range(n):
          if i < j and q[i] > q[j]:
              t += 1
      b += t * n1 // i1
  c = a - b
  if c > 0:
      print(c)
  else:
      print(-c)
  
problem_description: Statement
  
  We have two permutations P and Q of size N (that is, P and Q are both
  rearrangements of (1,~2,~...,~N)).
  
  There are N! possible permutations of size N. Among them, let P and Q be the
  a-th and b-th lexicographically smallest permutations, respectively. Find |a -
  b|.
samples: [{"input": "3\n    1 3 2\n    3 1 2", "output": "3\n    \n\nThere are 6 permutations of size 3: (1,~2,~3), (1,~3,~2), (2,~1,~3),\n(2,~3,~1), (3,~1,~2), and (3,~2,~1). Among them, (1,~3,~2) and (3,~1,~2) come\n2-nd and 5-th in lexicographical order, so the answer is |2 - 5| = 3.\n\n* * *"}, {"input": "8\n    7 3 5 4 2 1 6 8\n    3 8 2 5 4 6 7 1", "output": "17517\n    \n\n* * *"}, {"input": "3\n    1 2 3\n    1 2 3", "output": "0"}]