#include <cstdio>
#include <algorithm>

typedef long long LL;
const int Mod = 1000000007;
const int MN = 305;

inline void Add(int &x, int y) { x -= (x += y) >= Mod ? Mod : 0; }

int N, Z, A[MN * 2], B[MN * 2], C[MN * 2], D[MN * 2];
int f[MN][MN], g[MN][MN];

int main() {
	scanf("%d", &N);
	for (int i = 1; i <= 2 * N; ++i) {
		scanf("%d", &A[i]);
		if (~i & 1 && ~A[i] && ~A[i - 1]) C[A[i - 1]] = C[A[i]] = 1;
	}
	for (int i = 1; i <= 2 * N; ++i) D[i] = D[i - 1] + !C[i];
	for (int i = 1; i <= 2 * N; ++i) if (~A[i] && !C[A[i]]) B[D[A[i]]] = 1, --Z;
	Z += N = D[2 * N] / 2;
	f[0][0] = 1;
	for (int i = 1; i <= Z; ++i) f[0][0] = (LL)f[0][0] * i % Mod;
	for (int i = 2 * N; i >= 1; --i) {
		for (int j = 0; j <= N; ++j)
			for (int k = 0; k <= N - j; ++k)
				g[j][k] = 0;
		for (int j = 0; j <= N; ++j)
			for (int k = 0; j + k <= N; ++k)
				if (B[i]) {
					if (j) Add(g[j - 1][k], f[j][k]);
					if (j + k < N) Add(g[j][k + 1], f[j][k]);
				} else {
					if (j) Add(g[j - 1][k], f[j][k]);
					if (k) g[j][k - 1] = (g[j][k - 1] + (LL)f[j][k] * k) % Mod;
					if (j + k < N) Add(g[j + 1][k], f[j][k]);
				}
		std::swap(f, g);
	}
	printf("%d\n", f[0][0]);
	return 0;
}

// Luogu : PinkRabbit