#include<bits/stdc++.h>
using namespace std;
const int MAXN = 305;
const int P = 1e9 + 7;
typedef long long ll;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
bool vis[MAXN * 2];
int n, a[MAXN * 2], dp[MAXN * 2][MAXN][MAXN];
void update(int &x, int y) {
	x += y;
	if (x >= P) x -= P;
}
int main() {
	read(n);
	for (int i = 1; i <= n * 2; i++) {
		read(a[i]);
		if (a[i] == -1) a[i] = 0;
	}
	for (int i = 1; i <= n * 2; i += 2) {
		if (a[i] != 0 && a[i + 1] != 0) {
			int x = a[i], y = a[i + 1];
			for (int j = 1; j <= n * 2; j++)
				a[j] -= (a[j] >= x) + (a[j] >= y);
			for (int j = i; j <= n * 2; j++)
				a[j] = a[j + 2];
			n--, i -= 2;
		}
	}
	int now = 0, ans = 1;
	for (int i = 1; i <= n * 2; i += 2) {
		vis[a[i]] = vis[a[i + 1]] = true;
		if (a[i] == 0 && a[i + 1] == 0) ans = 1ll * ans * ++now % P;
	}
	dp[1][0][0] = 1;
	for (int i = 1; i <= n * 2; i++) {
		for (int j = 0; j <= n; j++)
		for (int k = 0; j + k <= n; k++) {
			int tmp = dp[i][j][k];
			if (tmp == 0) continue;
			if (vis[i]) {
				update(dp[i + 1][j][k + 1], tmp);
				if (j) update(dp[i + 1][j - 1][k], 1ll * j * tmp % P);
			} else {
				update(dp[i + 1][j][k + 1], tmp);
				update(dp[i + 1][j + 1][k], tmp);
				if (k) update(dp[i + 1][j][k - 1], tmp);
			}
		}
	}
	cout << 1ll * ans * dp[n * 2 + 1][0][0] % P << endl;
	return 0;
}