output_description: Print the number of different sequences that B_1, B_2, ..., B_N can be, modulo
  10^9 + 7.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
      A_1 A_2 ... A_{2N}
attempt: n = int(input())
  a = [int(i) for i in input().split()]
  b = []
  d = []
  for i in range(len(a)):
    b.append(a[2i]-a[2i+1])
  c = [i for i in a.split() if i != '-1']
  c = list(set(range(1,len(a)+1) ^ set(c))
  for i in range(len(b)):
    if b[i]-1 == a[2*i]:
      d.append([i for i in c if i < a[2*i]] + [a[2*i]])
    elif b[i]+a[2*i] == -1:
      d.append([i for i in c if i < a[2*i+1]] + [a[2*i]+1])
    elif b[i] == 0:
      d.append([i for i in c if i != max(c)])
  f = 1
  for i in d:
    f *= len(i)
  for i in range(len(c)):
    if [e for i in d for e in i].count(c[i]) >= 2:
      g = 1
      for j in d:
        g *= len(j)-j.count(c[i])
      f -= g
  print(f)
  
problem_description: Statement
  
  There is a sequence of length 2N: A_1, A_2, ..., A_{2N}. Each A_i is either -1
  or an integer between 1 and 2N (inclusive). Any integer other than -1 appears
  at most once in {A_i}.
  
  For each i such that A_i = -1, Snuke replaces A_i with an integer between 1
  and 2N (inclusive), so that {A_i} will be a permutation of 1, 2, ..., 2N.
  Then, he finds a sequence of length N, B_1, B_2, ..., B_N, as B_i =
  min(A_{2i-1}, A_{2i}).
  
  Find the number of different sequences that B_1, B_2, ..., B_N can be, modulo
  10^9 + 7.
samples: [{"input": "3\n    1 -1 -1 3 6 -1", "output": "5\n    \n\nThere are six ways to make {A_i} a permutation of 1, 2, ..., 2N; for each of\nthem, {B_i} would be as follows:\n\n  * (A_1, A_2, A_3, A_4, A_5, A_6) = (1, 2, 4, 3, 6, 5): (B_1, B_2, B_3) = (1, 3, 5)\n  * (A_1, A_2, A_3, A_4, A_5, A_6) = (1, 2, 5, 3, 6, 4): (B_1, B_2, B_3) = (1, 3, 4)\n  * (A_1, A_2, A_3, A_4, A_5, A_6) = (1, 4, 2, 3, 6, 5): (B_1, B_2, B_3) = (1, 2, 5)\n  * (A_1, A_2, A_3, A_4, A_5, A_6) = (1, 4, 5, 3, 6, 2): (B_1, B_2, B_3) = (1, 3, 2)\n  * (A_1, A_2, A_3, A_4, A_5, A_6) = (1, 5, 2, 3, 6, 4): (B_1, B_2, B_3) = (1, 2, 4)\n  * (A_1, A_2, A_3, A_4, A_5, A_6) = (1, 5, 4, 3, 6, 2): (B_1, B_2, B_3) = (1, 3, 2)\n\nThus, there are five different sequences that B_1, B_2, B_3 can be.\n\n* * *"}, {"input": "4\n    7 1 8 3 5 2 6 4", "output": "1\n    \n\n* * *"}, {"input": "10\n    7 -1 -1 -1 -1 -1 -1 6 14 12 13 -1 15 -1 -1 -1 -1 20 -1 -1", "output": "9540576\n    \n\n* * *"}, {"input": "20\n    -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 6 -1 -1 -1 -1 -1 7 -1 -1 -1 -1 -1 -1 -1 -1 -1 34 -1 -1 -1 -1 31 -1 -1 -1 -1 -1 -1 -1 -1", "output": "374984201"}]