/* Header {{{ */
#include <bits/stdc++.h>
using namespace std;

typedef long long readtype;
typedef long long var;
typedef long double let;

readtype read() {
  readtype a = 0, c = getchar(), s = 0;
  while (!isdigit(c)) s |= c == '-', c = getchar();
  while (isdigit(c)) a = a * 10 + c - 48, c = getchar();
  return s ? -a : a;
}
/* }}} */

const int N = 304;
const int MOD = 1e9 + 7;

int a[N << 1];
bool v[N << 1], mark[N << 1];
int f[N << 1][N][N];

int main() {
  int n = read() * 2;
  for (int i = 1; i <= n; ++i) a[i] = read();
  for (int i = 1; i <= n; ++i) {
    if (a[i] != -1) v[a[i]] = true;
  }

  int have = 0;
  for (int i = 1; i <= n; i += 2) {
    if (a[i] == -1 && a[i + 1] == -1) ++have;
    if (a[i] != -1 && a[i + 1] != -1)
      mark[a[i]] = mark[a[i + 1]] = true;
  }

  f[n + 1][0][0] = 1;
  for (int i = n; i >= 1; --i) {
    if (mark[i]) {
      for (int j = 0; j <= n; ++j)
        for (int k = 0; k <= n; ++k) f[i][j][k] = f[i + 1][j][k];
      continue;
    }

    for (int j = 0; j <= n / 2; ++j) {
      for (int k = 0; k <= n / 2; ++k) {
        if (!f[i + 1][j][k]) continue;
        if (v[i]) {
          if (j) (f[i][j - 1][k] += f[i + 1][j][k]) %= MOD;
          (f[i][j][k + 1] += f[i + 1][j][k]) %= MOD;
        } else {
          if (j) (f[i][j - 1][k] += f[i + 1][j][k]) %= MOD;
          if (k) (f[i][j][k - 1] += (1ll * k * f[i + 1][j][k]) % MOD) %= MOD;
          (f[i][j + 1][k] += f[i + 1][j][k]) %= MOD;
        }
      }
    }
  }

  var res = f[1][0][0];
  for (int i = 1; i <= have; ++i) (res *= i) %= MOD;
  printf("%lld\n", res);
  return 0;
}
